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