Total Complexity | 7 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | class TraversableObject implements Iterator, Countable |
||
18 | { |
||
19 | private int $position = 0; |
||
20 | |||
21 | public function __construct(protected array $data) |
||
22 | { |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * @throws Exception |
||
27 | */ |
||
28 | public function count(): int |
||
29 | { |
||
30 | throw new Exception('Count called on object that should only be traversed.'); |
||
31 | } |
||
32 | |||
33 | public function current(): mixed |
||
34 | { |
||
35 | return $this->data[$this->position]; |
||
36 | } |
||
37 | |||
38 | public function next(): void |
||
41 | } |
||
42 | |||
43 | public function key(): int |
||
46 | } |
||
47 | |||
48 | public function valid(): bool |
||
51 | } |
||
52 | |||
53 | public function rewind(): void |
||
56 | } |
||
57 | } |
||
58 |