| Total Complexity | 8 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | abstract class AIterator implements \ArrayAccess, \IteratorAggregate, \Countable |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * Iterable variable |
||
| 15 | * @var array<string|int, string|int|float|bool|null> |
||
| 16 | */ |
||
| 17 | protected array $iterable = []; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Name of iterable variable; |
||
| 21 | * @return string |
||
| 22 | */ |
||
| 23 | abstract protected function getIterableName(): string; |
||
| 24 | |||
| 25 | 6 | public function getIterator(): \Traversable |
|
| 26 | { |
||
| 27 | 6 | return new \ArrayIterator($this->{$this->getIterableName()}); |
|
| 28 | } |
||
| 29 | |||
| 30 | 2 | public function offsetExists($offset): bool |
|
| 31 | { |
||
| 32 | 2 | return isset($this->{$this->getIterableName()}[$offset]); |
|
| 33 | } |
||
| 34 | |||
| 35 | #[\ReturnTypeWillChange] |
||
| 36 | 1 | public function offsetGet($offset) |
|
| 37 | { |
||
| 38 | 1 | return $this->offsetExists($offset) ? $this->{$this->getIterableName()}[$offset] : null ; |
|
| 39 | } |
||
| 40 | |||
| 41 | 2 | public function offsetSet($offset, $value): void |
|
| 44 | 2 | } |
|
| 45 | |||
| 46 | 1 | public function offsetUnset($offset): void |
|
| 47 | { |
||
| 48 | 1 | if ($this->offsetExists($offset)) { |
|
| 49 | 1 | unset($this->{$this->getIterableName()}[$offset]); |
|
| 50 | } |
||
| 51 | 1 | } |
|
| 52 | |||
| 53 | 2 | public function count(): int |
|
| 56 | } |
||
| 57 | } |
||
| 58 |