NodeInfo   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 108
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 26
c 2
b 0
f 0
dl 0
loc 108
rs 10
ccs 29
cts 29
cp 1
wmc 12

11 Methods

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