Slice   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 30
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 18 4
1
<?php
2
3
namespace Vine\Commands;
4
5
use Vine\Node;
6
use Vine\NodeCollection;
7
8
class Slice
9
{
10
    /**
11
     * Slice a node from the tree and return a new tree structure where
12
     * the children from this node get the parent of the extracted Node
13
     * as their parent
14
     *
15
     * @param NodeCollection $nodeCollection
16
     * @param Node[] $sliceNodes
17
     * @return NodeCollection
18
     */
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)
0 ignored issues
show
Bug introduced by
The method children cannot be called on $node (of type array<integer,object<Vine\Node>>).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
26
            {
27 15
                ($node->isRoot())
0 ignored issues
show
Bug introduced by
The method isRoot cannot be called on $node (of type array<integer,object<Vine\Node>>).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
28
                    ? $child->moveToRoot()
29 15
                    : $child->move($node->parent());
0 ignored issues
show
Bug introduced by
The method parent cannot be called on $node (of type array<integer,object<Vine\Node>>).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
30
            }
31
32 18
            $node->remove();
0 ignored issues
show
Bug introduced by
The method remove cannot be called on $node (of type array<integer,object<Vine\Node>>).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
33
        }
34
35 24
        return $nodeCollection;
36
    }
37
}
38