| Total Complexity | 6 |
| Total Lines | 60 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | class IndexedArrayIterator implements SequenceIteratorInterface |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * @var IndexedArrayInterface<T> indexed array for iterating |
||
| 20 | */ |
||
| 21 | protected IndexedArrayInterface $array; |
||
| 22 | /** |
||
| 23 | * @var int current iteration index |
||
| 24 | */ |
||
| 25 | protected int $currentIndex; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * IndexedArrayIterator constructor. |
||
| 29 | * |
||
| 30 | * @param IndexedArrayInterface<T> $array indexed array to iterate |
||
| 31 | */ |
||
| 32 | 3 | public function __construct(IndexedArrayInterface $array) |
|
| 33 | { |
||
| 34 | 3 | $this->array = $array; |
|
| 35 | 3 | $this->currentIndex = 0; |
|
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * {@inheritDoc} |
||
| 40 | */ |
||
| 41 | 3 | public function current() |
|
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * {@inheritDoc} |
||
| 48 | */ |
||
| 49 | 3 | public function next(): void |
|
| 50 | { |
||
| 51 | 3 | $this->currentIndex++; |
|
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * {@inheritDoc} |
||
| 56 | */ |
||
| 57 | 3 | public function key(): int |
|
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * {@inheritDoc} |
||
| 64 | */ |
||
| 65 | 3 | public function valid(): bool |
|
| 66 | { |
||
| 67 | 3 | return isset($this->array[$this->currentIndex]); |
|
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * {@inheritDoc} |
||
| 72 | */ |
||
| 73 | 3 | public function rewind(): void |
|
| 76 | } |
||
| 77 | } |
||
| 78 |