| Total Complexity | 11 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Coverage | 75% |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 21 | class ArrayNode extends Node implements \IteratorAggregate, \Countable |
||
| 22 | { |
||
| 23 | private array $value = []; |
||
| 24 | private bool $isNative = true; |
||
| 25 | |||
| 26 | 343 | public function __construct(array $defaultValues = []) |
|
| 27 | { |
||
| 28 | 343 | foreach ($defaultValues as $v) { |
|
| 29 | $this->add($v); |
||
| 30 | } |
||
| 31 | } |
||
| 32 | |||
| 33 | 341 | public function add(mixed $item): void |
|
| 34 | { |
||
| 35 | 341 | if ($item instanceof Node) { |
|
| 36 | 202 | $item->setParent($this); |
|
| 37 | 202 | $this->isNative = false; |
|
| 38 | } |
||
| 39 | |||
| 40 | 341 | $this->value[] = $item; |
|
| 41 | } |
||
| 42 | |||
| 43 | public function count(): int |
||
| 44 | { |
||
| 45 | return count($this->value); |
||
| 46 | } |
||
| 47 | |||
| 48 | public function getIterator(): \Iterator |
||
| 51 | } |
||
| 52 | |||
| 53 | 343 | public function getNativeValue(): array |
|
| 54 | { |
||
| 55 | 343 | if (!$this->isNative) { |
|
| 56 | 202 | $this->resolve(); |
|
| 57 | } |
||
| 58 | |||
| 59 | 343 | return $this->value; |
|
| 60 | } |
||
| 61 | |||
| 62 | 202 | private function resolve(): void |
|
| 68 | } |
||
| 69 | } |
||
| 70 |