Move   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 18
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 8 2
1
<?php
2
3
namespace Vine\Commands;
4
5
use Vine\Node;
6
7
class Move
8
{
9
    /**
10
     * Move a child node to a different parent
11
     *
12
     * @param Node $node
13
     * @param Node $parent
14
     * @return Node
15
     */
16 21
    public function __invoke(Node $node, Node $parent): Node
17
    {
18 21
        if(!$node->isRoot()) $node->parent()->remove($node);
0 ignored issues
show
Documentation introduced by
$node is of type object<Vine\Node>, but the function expects a null|object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
19
20 21
        $parent->addChildren($node);
0 ignored issues
show
Documentation introduced by
$node is of type object<Vine\Node>, but the function expects a array|object<Vine\NodeCollection>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
21
22 21
        return $node;
23
    }
24
}
25