Node   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createFromPath() 0 7 1
A createFromMatrix() 0 10 2
1
<?php
2
/**
3
 * Node.php
4
 *
5
 * PHP version 5.6+
6
 *
7
 * @author Philippe Gaultier <[email protected]>
8
 * @copyright 2010-2016 Philippe Gaultier
9
 * @license http://www.sweelix.net/license license
10
 * @version XXX
11
 * @link http://www.sweelix.net
12
 * @package sweelix\tree
13
 */
14
15
namespace sweelix\tree;
16
17
/**
18
 * Node minimalist class to use the trait
19
 *
20
 * @author Philippe Gaultier <[email protected]>
21
 * @copyright 2010-2016 Philippe Gaultier
22
 * @license http://www.sweelix.net/license license
23
 * @version XXX
24
 * @link http://www.sweelix.net
25
 * @package sweelix\tree
26
 * @since XXX
27
 */
28
class Node
29
{
30
    use NodeTrait;
31
32
    /**
33
     * @param string $path node path in dot notation (1.1.2)
34
     * @return static
35
     * @since XXX
36
     */
37
    public static function createFromPath($path)
38
    {
39
        $node = new static();
40
        $node->nodePath = $path;
41
        $node->nodeMatrix = Helper::convertPathToMatrix($path);
0 ignored issues
show
Documentation Bug introduced by
It seems like \sweelix\tree\Helper::convertPathToMatrix($path) of type object<sweelix\tree\Matrix> is incompatible with the declared type array of property $nodeMatrix.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
42
        return $node;
43
    }
44
45
    /**
46
     * Create a node object from a matrix
47
     * @param array|Matrix $matrix node path in matrix notation [a, b, c, d]
48
     * @return static
49
     * @since XXX
50
     */
51
    public static function createFromMatrix($matrix)
52
    {
53
        $node = new static();
54
        if (is_array($matrix) === true) {
55
            $matrix = new Matrix($matrix);
56
        }
57
        $node->nodeMatrix = $matrix;
0 ignored issues
show
Documentation Bug introduced by
It seems like $matrix of type object<sweelix\tree\Matrix> is incompatible with the declared type array of property $nodeMatrix.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
58
        $node->nodePath = Helper::convertMatrixToPath($matrix);
59
        return $node;
60
    }
61
}
62