Completed
Push — develop ( 32afc4...f78f16 )
by Bartko
03:00
created

NodeInfo   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 130
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 7
Bugs 1 Features 2
Metric Value
wmc 14
c 7
b 1
f 2
lcom 1
cbo 0
dl 0
loc 130
ccs 38
cts 38
cp 1
rs 10

13 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A getId() 0 4 1
A getParentId() 0 4 1
A setLevel() 0 4 1
A getLevel() 0 4 1
A setLeft() 0 4 1
A getLeft() 0 4 1
A setRight() 0 4 1
A getRight() 0 4 1
A getScope() 0 4 1
A isRoot() 0 8 2
A setNeedUpdate() 0 4 1
A needUpdate() 0 4 1
1
<?php
2
namespace StefanoTree\NestedSet;
3
4
class NodeInfo
5
{
6
    private $id;
7
    private $parentId;
8
    private $level;
9
    private $left;
10
    private $right;
11
    private $scope;
12
13
    private $needUpdate = false;
14
15
    /**
16
     * NodeInfo constructor.
17
     * @param $id int
18
     * @param $parentId int
19
     * @param $level int
20
     * @param $left int
21
     * @param $right int
22
     * @param $scope null|int if scope is not used
23
     */
24 86
    public function __construct($id, $parentId, $level, $left, $right, $scope)
25
    {
26 86
        $this->id       = $id;
27 86
        $this->parentId = $parentId;
28 86
        $this->level    = $level;
29 86
        $this->left     = $left;
30 86
        $this->right    = $right;
31 86
        $this->scope    = $scope;
32 86
    }
33
34
    /**
35
     * @return int
36
     */
37 25
    public function getId()
38
    {
39 25
        return $this->id;
40
    }
41
42
    /**
43
     * @return int
44
     */
45 54
    public function getParentId()
46
    {
47 54
        return $this->parentId;
48
    }
49
50
    /**
51
     * @param $level int
52
     */
53 7
    public function setLevel($level)
54
    {
55 7
        $this->level = $level;
56 7
    }
57
58
    /**
59
     * @return int
60
     */
61 62
    public function getLevel()
62
    {
63 62
        return $this->level;
64
    }
65
66
    /**
67
     * @param $left int
68
     */
69 7
    public function setLeft($left)
70
    {
71 7
        $this->left = $left;
72 7
    }
73
74
    /**
75
     * @return int
76
     */
77 77
    public function getLeft()
78
    {
79 77
        return $this->left;
80
    }
81
82
    /**
83
     * @param $right int
84
     */
85 7
    public function setRight($right)
86
    {
87 7
        $this->right = $right;
88 7
    }
89
90
    /**
91
     * @return int
92
     */
93 77
    public function getRight()
94
    {
95 77
        return $this->right;
96
    }
97
98
    /**
99
     * @return int|null
100
     */
101 53
    public function getScope()
102
    {
103 53
        return $this->scope;
104
    }
105
106
    /**
107
     * @return bool
108
     */
109 17
    public function isRoot()
110
    {
111 17
        if (0 == $this->getParentId()) {
112 13
            return true;
113
        } else {
114 16
            return false;
115
        }
116
    }
117
118
    /**
119
     * @param $bool bool
120
     */
121 7
    public function setNeedUpdate($bool)
122
    {
123 7
        $this->needUpdate = (bool) $bool;
124 7
    }
125
126
    /**
127
     * @return bool
128
     */
129 5
    public function needUpdate()
130
    {
131 5
        return $this->needUpdate;
132
    }
133
}
134