1 | <?php |
||
2 | |||
3 | namespace Seboettg\Collection\NativePhp; |
||
4 | |||
5 | use ReturnTypeWillChange; |
||
6 | |||
7 | trait IteratorTrait |
||
8 | { |
||
9 | private int $offset = 0; |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
10 | /** |
||
11 | * {@inheritdoc} |
||
12 | */ |
||
13 | #[ReturnTypeWillChange] |
||
14 | 20 | public function current() |
|
15 | { |
||
16 | 20 | return $this->valid() ? $this->array[$this->offset] : false; |
|
17 | } |
||
18 | |||
19 | 2 | public function key(): int |
|
20 | { |
||
21 | 2 | return $this->offset; |
|
22 | } |
||
23 | |||
24 | /** |
||
25 | * {@inheritdoc} |
||
26 | */ |
||
27 | 18 | public function next(): void |
|
28 | { |
||
29 | 18 | ++$this->offset; |
|
30 | 18 | } |
|
31 | |||
32 | 20 | public function valid(): bool |
|
33 | { |
||
34 | 20 | return isset($this->array[$this->offset]); |
|
35 | } |
||
36 | |||
37 | 19 | public function rewind(): void |
|
38 | { |
||
39 | 19 | $this->offset = 0; |
|
40 | 19 | } |
|
41 | } |
||
42 |