Conditions | 4 |
Paths | 4 |
Total Lines | 16 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
34 | 7 | public function modify(NodeInterface $tree): NodeInterface |
|
35 | { |
||
36 | /** @var \loophp\phptree\Node\NaryNodeInterface $item */ |
||
37 | 7 | foreach ($this->traverser->traverse($tree) as $item) { |
|
38 | 7 | $capacity = $item->capacity(); |
|
39 | |||
40 | 7 | if (false === $item->isLeaf()) { |
|
41 | 7 | $children = iterator_to_array($item->children()); |
|
42 | |||
43 | 7 | while ($item->degree() !== $capacity) { |
|
44 | 5 | $item->add(current($children)->clone()); |
|
45 | } |
||
46 | } |
||
47 | } |
||
48 | |||
49 | 7 | return $tree; |
|
50 | } |
||
52 |