This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace ezTreeBuilder\Base; |
||
3 | |||
4 | /** |
||
5 | * Branch abstract class - Limited concern to \TreeBuilder\Tree |
||
6 | * |
||
7 | * @package ezTreeBuilder |
||
8 | * @author Adrian Tilita <[email protected]> |
||
9 | * @version 1.0 |
||
10 | * @abstract |
||
11 | */ |
||
12 | abstract class AbstractBranch |
||
13 | { |
||
14 | /** |
||
15 | * Container for current branch children |
||
16 | * @var array |
||
17 | */ |
||
18 | private $children = array(); |
||
19 | |||
20 | /** |
||
21 | * Reference to the current branch parent |
||
22 | * @var Branch |
||
23 | */ |
||
24 | private $parent; |
||
25 | |||
26 | /** |
||
27 | * The depth of the item |
||
28 | * @var int |
||
29 | */ |
||
30 | private $depth; |
||
31 | |||
32 | /** |
||
33 | * The left number of the branch |
||
34 | * @var int |
||
35 | */ |
||
36 | private $left; |
||
37 | |||
38 | /** |
||
39 | * The right number of the branch |
||
40 | * @var int |
||
41 | */ |
||
42 | private $right; |
||
43 | |||
44 | /** |
||
45 | * Establish if the item is a leaf |
||
46 | * @var boolean |
||
47 | */ |
||
48 | private $isLeaf; |
||
49 | |||
50 | /** |
||
51 | * Set the Parent of the current branch |
||
52 | * @param Branch $item |
||
53 | * @return Branch |
||
54 | */ |
||
55 | public function setParent(Branch $item) |
||
56 | { |
||
57 | $this->parent = $item; |
||
58 | return $this; |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * Verify if the current branch has a parent |
||
63 | * @return boolean |
||
64 | */ |
||
65 | public function hasParent() |
||
66 | { |
||
67 | if (!isset($this->parent)) { |
||
68 | return false; |
||
69 | } |
||
70 | return true; |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * Get the current branch's parent |
||
75 | * @return Branch |
||
76 | * @throws \Exception |
||
77 | */ |
||
78 | public function getParent() |
||
79 | { |
||
80 | if ($this->hasParent() === false) { |
||
81 | throw new \Exception('The current branch has no parent set!'); |
||
82 | } |
||
83 | return $this->parent; |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * Get the root parent of the current branch |
||
88 | * @return Branch |
||
89 | */ |
||
90 | public function getRootParent() |
||
91 | { |
||
92 | if ($this->hasParent() === false) { |
||
93 | return $this; |
||
94 | } |
||
95 | $parent = $this->getParent(); |
||
96 | while ($parent->hasParent() === true) { |
||
97 | $parent = $parent->getParent(); |
||
98 | } |
||
99 | return $parent; |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * Adds a new branch child |
||
104 | * @param Branch $item |
||
105 | */ |
||
106 | public function addChild(Branch $item) |
||
107 | { |
||
108 | $this->children[] = $item; |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * Verify if the current branch has any children |
||
113 | * @return boolean |
||
114 | */ |
||
115 | public function hasChildren() |
||
116 | { |
||
117 | if (empty($this->children)) { |
||
118 | return false; |
||
119 | } |
||
120 | return true; |
||
121 | } |
||
122 | |||
123 | /** |
||
124 | * Return the current branch children |
||
125 | * @return array - array(Branch, Branch) |
||
126 | * @throws \Exception |
||
127 | */ |
||
128 | public function getChildren() |
||
129 | { |
||
130 | if ($this->hasChildren() === false) { |
||
131 | throw new \Exception('The current branch has no childs!'); |
||
132 | } |
||
133 | return $this->children; |
||
134 | } |
||
135 | |||
136 | /** |
||
137 | * Set the branch depth |
||
138 | * @param int $depth |
||
139 | * @return AbstractBranch |
||
140 | */ |
||
141 | public function setDepth($depth) |
||
142 | { |
||
143 | $this->depth = $depth; |
||
144 | return $this; |
||
145 | } |
||
146 | |||
147 | /** |
||
148 | * Get the branch depth |
||
149 | * @return int |
||
150 | */ |
||
151 | public function getDepth() |
||
152 | { |
||
153 | return $this->depth; |
||
154 | } |
||
155 | |||
156 | /** |
||
157 | * Set Tree Left value |
||
158 | * @param int $value |
||
159 | * @return AbstractBranch |
||
160 | */ |
||
161 | public function setLeft($value) |
||
162 | { |
||
163 | $this->left = $value; |
||
164 | return $this; |
||
165 | } |
||
166 | |||
167 | /** |
||
168 | * Get Tree Left value |
||
169 | * @return int |
||
170 | */ |
||
171 | public function getLeft() |
||
172 | { |
||
173 | return $this->left; |
||
174 | } |
||
175 | |||
176 | |||
177 | /** |
||
178 | * Set Tree Right value |
||
179 | * @param int $value |
||
180 | * @return AbstractBranch |
||
181 | */ |
||
182 | public function setRight($value) |
||
183 | { |
||
184 | $this->right = $value; |
||
185 | return $this; |
||
186 | } |
||
187 | |||
188 | /** |
||
189 | * Get Tree Right value |
||
190 | * @return int |
||
191 | */ |
||
192 | public function getRight() |
||
193 | { |
||
194 | return $this->right; |
||
195 | } |
||
196 | |||
197 | /** |
||
198 | * Set the Leaf state |
||
199 | * @param boolean $isLeaf |
||
200 | * @return AbstractBranch |
||
201 | */ |
||
202 | public function setIsLeaf($isLeaf) |
||
203 | { |
||
204 | $this->isLeaf = $isLeaf; |
||
205 | return $this; |
||
206 | } |
||
207 | |||
208 | /** |
||
209 | * Return the leaf state of the item |
||
210 | * @return boolean |
||
211 | */ |
||
212 | public function isLeaf() |
||
213 | { |
||
214 | return $this->isLeaf; |
||
215 | } |
||
216 | |||
217 | /** |
||
218 | * Get the entire Item as array |
||
219 | * @return array |
||
220 | */ |
||
221 | public function getAsArray() |
||
222 | { |
||
223 | $returnedArray = array(); |
||
224 | $returnedArray['id'] = $this->getId(); |
||
225 | $returnedArray['parent_id'] = $this->hasParent() ? $this->getParentId() : 0; |
||
0 ignored issues
–
show
|
|||
226 | $returnedArray['data'] = $this->getData(); |
||
227 | $returnedArray['depth'] = $this->getDepth(); |
||
228 | $returnedArray['left'] = $this->getLeft(); |
||
229 | $returnedArray['right'] = $this->getRight(); |
||
230 | $returnedArray['is_leaf'] = $this->isLeaf(); |
||
231 | return $returnedArray; |
||
232 | } |
||
233 | } |
||
234 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.