| Conditions | 5 |
| Paths | 5 |
| Total Lines | 21 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 34 | 7 | public function modify(NodeInterface $tree): NodeInterface |
|
| 35 | { |
||
| 36 | /** @var \loophp\phptree\Node\ValueNodeInterface $item */ |
||
| 37 | 7 | foreach ($this->traverser->traverse($tree) as $item) { |
|
| 38 | 7 | if (null === $parent = $item->getParent()) { |
|
| 39 | 7 | continue; |
|
| 40 | } |
||
| 41 | |||
| 42 | 7 | if (false === $item->isLeaf()) { |
|
| 43 | 4 | continue; |
|
| 44 | } |
||
| 45 | |||
| 46 | 7 | if (null !== $item->getValue()) { |
|
| 47 | 7 | continue; |
|
| 48 | } |
||
| 49 | |||
| 50 | 2 | $parent->remove($item); |
|
| 51 | 2 | $this->modify($parent); |
|
| 52 | } |
||
| 53 | |||
| 54 | 7 | return $tree; |
|
| 55 | } |
||
| 57 |