Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
16 | 27 | public function __invoke(NodeCollection $nodeCollection): NodeCollection |
|
17 | { |
||
18 | 27 | $flattened = []; |
|
19 | |||
20 | 27 | foreach($nodeCollection as $k => $node) |
|
21 | { |
||
22 | 27 | $flattened[] = $node; |
|
23 | |||
24 | 27 | if(!$node->children()->isEmpty()) |
|
25 | { |
||
26 | 27 | $flattened = array_merge($flattened, $this->__invoke($node->children())->all()); |
|
27 | } |
||
28 | } |
||
29 | |||
30 | 27 | return new NodeCollection(...$flattened); |
|
31 | } |
||
32 | } |
||
33 |