| Conditions | 4 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 4.0312 |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | 24 | public function __invoke(NodeCollection $nodeCollection, Node ...$sliceNodes): NodeCollection |
|
| 20 | { |
||
| 21 | // Check if current node is one of the passed nodes to be sliced out |
||
| 22 | 24 | foreach($sliceNodes as $node) |
|
| 23 | { |
||
| 24 | // Add children to parent of this node |
||
| 25 | 18 | foreach($node->children() as $child) |
|
|
|
|||
| 26 | { |
||
| 27 | 15 | ($node->isRoot()) |
|
| 28 | ? $child->moveToRoot() |
||
| 29 | 15 | : $child->move($node->parent()); |
|
| 30 | } |
||
| 31 | |||
| 32 | 18 | $node->remove(); |
|
| 33 | } |
||
| 34 | |||
| 35 | 24 | return $nodeCollection; |
|
| 36 | } |
||
| 37 | } |
||
| 38 |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.