| Total Complexity | 7 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 8 | final class NodeValueListBuilder |
||
| 9 | { |
||
| 10 | |||
| 11 | private $outerIndexes = []; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @var NodeValueInterface[] |
||
| 15 | 5 | */ |
|
| 16 | private $values = []; |
||
| 17 | 5 | ||
| 18 | 5 | public function addValue(NodeValueInterface $value, int $outerIndex): self |
|
| 19 | { |
||
| 20 | 5 | if ($this->valueExists($value, $outerIndex)) { |
|
| 21 | return $this; |
||
| 22 | } |
||
| 23 | 6 | ||
| 24 | $this->outerIndexes[] = $outerIndex; |
||
| 25 | 6 | $this->values[] = $value; |
|
| 26 | |||
| 27 | return $this; |
||
| 28 | } |
||
| 29 | |||
| 30 | public function build(): NodeValueListInterface |
||
| 31 | { |
||
| 32 | return new NodeValueList(new IndexMap(...$this->outerIndexes), ...$this->values); |
||
| 33 | } |
||
| 34 | |||
| 35 | private function valueExists(NodeValueInterface $value, int $outerIndex): bool |
||
| 50 | } |
||
| 51 | } |
||
| 52 |