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

NodeInfo::getParentId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 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