1 | <?php |
||
7 | abstract class Node |
||
8 | { |
||
9 | /** |
||
10 | * @var int |
||
11 | */ |
||
12 | protected $depth = 0; |
||
13 | |||
14 | /** |
||
15 | * @var Node|null |
||
16 | */ |
||
17 | protected $parent; |
||
18 | |||
19 | /** |
||
20 | * @var Node|null |
||
21 | */ |
||
22 | protected $previous; |
||
23 | |||
24 | /** |
||
25 | * @var Node|null |
||
26 | */ |
||
27 | protected $next; |
||
28 | |||
29 | /** |
||
30 | * @var Node|null |
||
31 | */ |
||
32 | protected $firstChild; |
||
33 | |||
34 | /** |
||
35 | * @var Node|null |
||
36 | */ |
||
37 | protected $lastChild; |
||
38 | |||
39 | /** |
||
40 | * @return Node|null |
||
41 | */ |
||
42 | 15 | public function previous() |
|
43 | { |
||
44 | 15 | return $this->previous; |
|
45 | } |
||
46 | |||
47 | /** |
||
48 | * @return Node|null |
||
49 | */ |
||
50 | 1947 | public function next() |
|
54 | |||
55 | /** |
||
56 | * @return Node|null |
||
57 | */ |
||
58 | 1962 | public function parent() |
|
62 | |||
63 | /** |
||
64 | * @param Node|null $node |
||
65 | */ |
||
66 | 1986 | protected function setParent(Node $node = null) |
|
71 | |||
72 | /** |
||
73 | * Inserts the $sibling node after $this |
||
74 | * |
||
75 | * @param Node $sibling |
||
76 | */ |
||
77 | 1503 | public function insertAfter(Node $sibling) |
|
94 | |||
95 | /** |
||
96 | * Inserts the $sibling node before $this |
||
97 | * |
||
98 | * @param Node $sibling |
||
99 | */ |
||
100 | 9 | public function insertBefore(Node $sibling) |
|
117 | |||
118 | 384 | public function replaceWith(Node $replacement) |
|
124 | |||
125 | 1986 | public function detach() |
|
144 | |||
145 | /** |
||
146 | * @return bool |
||
147 | */ |
||
148 | abstract public function isContainer(); |
||
149 | |||
150 | /** |
||
151 | * @return Node|null |
||
152 | */ |
||
153 | 1953 | public function firstChild() |
|
157 | |||
158 | /** |
||
159 | * @return Node|null |
||
160 | */ |
||
161 | 1812 | public function lastChild() |
|
165 | |||
166 | /** |
||
167 | * @return Node[] |
||
168 | */ |
||
169 | 2040 | public function children() |
|
178 | |||
179 | /** |
||
180 | * @param Node $child |
||
181 | */ |
||
182 | 1980 | public function appendChild(Node $child) |
|
192 | |||
193 | /** |
||
194 | * Adds $child as the very first child of $this |
||
195 | * |
||
196 | * @param Node $child |
||
197 | */ |
||
198 | 6 | public function prependChild(Node $child) |
|
208 | |||
209 | /** |
||
210 | * Detaches all child nodes of given node |
||
211 | */ |
||
212 | 6 | public function detachChildren() |
|
219 | |||
220 | /** |
||
221 | * Replace all children of given node with collection of another |
||
222 | * |
||
223 | * @param array $children |
||
224 | * |
||
225 | * @return $this |
||
226 | */ |
||
227 | 3 | public function replaceChildren(array $children) |
|
240 | |||
241 | /** |
||
242 | * @return int |
||
243 | */ |
||
244 | 396 | public function getDepth() |
|
248 | |||
249 | /** |
||
250 | * @return NodeWalker |
||
251 | */ |
||
252 | 1941 | public function walker() |
|
256 | } |
||
257 |