| Conditions | 6 |
| Paths | 16 |
| Total Lines | 20 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | 12 | public function __invoke(Node $node, $key, $value = null, $down = true): array |
|
| 17 | { |
||
| 18 | 12 | $values = $value |
|
| 19 | 6 | ? [$node->entry($key) => $node->entry($value)] |
|
| 20 | 12 | : [$node->entry($key)]; |
|
| 21 | |||
| 22 | 12 | $nodes = $down ? $node->children() : [$node->parent()]; |
|
| 23 | |||
| 24 | 12 | foreach($nodes as $node) |
|
| 25 | { |
||
| 26 | // If node entry is empty, which means there is no parent, we bail out |
||
| 27 | 12 | if(!$node) break; |
|
| 28 | |||
| 29 | 12 | $values = $value |
|
| 30 | 6 | ? array_replace($values, $this->__invoke($node, $key, $value, $down)) // Respect the passed key values |
|
| 31 | 12 | : array_merge($values, $this->__invoke($node, $key, $value, $down)); // No key values specified so just append |
|
| 32 | } |
||
| 33 | |||
| 34 | 12 | return $values; |
|
| 35 | } |
||
| 36 | } |
||
| 37 |