ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCtrlArrayIterator.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
31 private array $data;
32
38 public function __construct(array $data)
39 {
40 $this->data = $data;
41 }
42
46 public function current(): ?string
47 {
48 if ($this->valid()) {
49 return current($this->data);
50 }
51
52 return null;
53 }
54
58 public function next(): void
59 {
60 next($this->data);
61 }
62
66 public function key(): ?string
67 {
68 if ($this->valid()) {
69 return key($this->data);
70 }
71
72 return null;
73 }
74
78 public function valid(): bool
79 {
80 $value = current($this->data);
81 $key = key($this->data);
82
83 if (null === $key) {
84 return false;
85 }
86
87 if (!is_string($value) || !is_string($key)) {
88 $this->next();
89 return $this->valid();
90 }
91
92 return true;
93 }
94
98 public function rewind(): void
99 {
100 reset($this->data);
101 }
102}
Class ilCtrlArrayIterator.
__construct(array $data)
ilCtrlArrayIterator Constructor
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...