Completed
Push — develop ( d0fbe3...729812 )
by Bartko
14:43
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 73
    public function __construct($id, $parentId, $level, $left, $right, $scope=null)
14
    {
15 73
        $this->id       = $id;
16 73
        $this->parentId = $parentId;
17 73
        $this->level    = $level;
18 73
        $this->left     = $left;
19 73
        $this->right    = $right;
20 73
        $this->scope    = $scope;
21 73
    }
22
23
    /**
24
     * @return int|null
25
     */
26 17
    public function getId()
27
    {
28 17
        return $this->id;
29
    }
30
31
    /**
32
     * @return int|null
33
     */
34 46
    public function getParentId()
35
    {
36 46
        return $this->parentId;
37
    }
38
39
    /**
40
     * @return int|null
41
     */
42 53
    public function getLevel()
43
    {
44 53
        return $this->level;
45
    }
46
47
    /**
48
     * @return int|null
49
     */
50 68
    public function getLeft()
51
    {
52 68
        return $this->left;
53
    }
54
55
    /**
56
     * @return int|null
57
     */
58 68
    public function getRight()
59
    {
60 68
        return $this->right;
61
    }
62
63
    /**
64
     * @return null|int
65
     */
66 53
    public function getScope()
67
    {
68 53
        return $this->scope;
69
    }
70
71
    /**
72
     * @return bool
73
     */
74 17
    public function isRoot()
75
    {
76 17
        if (0 == $this->getParentId()) {
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $this->getParentId() of type integer|null to 0; this is ambiguous as not only 0 == 0 is true, but null == 0 is true, too. Consider using a strict comparison ===.
Loading history...
77 13
            return true;
78
        } else {
79 16
            return false;
80
        }
81
    }
82
}
83