1 | <?php |
||
19 | final class Node |
||
20 | { |
||
21 | private $content = null; |
||
22 | private $children = array(); |
||
23 | private $parent = null; |
||
24 | |||
25 | 7 | public function __construct($value) |
|
29 | |||
30 | 5 | public function addChild(Node $child) |
|
35 | |||
36 | 3 | public function hasChildren() |
|
37 | { |
||
38 | 3 | return (count($this->children) > 0); |
|
39 | } |
||
40 | |||
41 | 5 | public function setParent(Node $node) |
|
45 | |||
46 | 1 | public function getParent() |
|
47 | { |
||
48 | 1 | return $this->parent; |
|
49 | } |
||
50 | |||
51 | 2 | public function getChildren() |
|
52 | { |
||
53 | 2 | return $this->children; |
|
54 | } |
||
55 | |||
56 | 4 | public function getContent() |
|
60 | |||
61 | /** |
||
62 | * Displays all elements from a tree in hierarchic order |
||
63 | * |
||
64 | * @param int $level Current level of indentation |
||
65 | */ |
||
66 | 1 | public function display($level = 0) |
|
88 | |||
89 | /** |
||
90 | * |
||
91 | * @param Closure $expr |
||
92 | * @return array |
||
93 | */ |
||
94 | 1 | public function getNodesByFilter(Closure $expr) |
|
110 | } |
||
111 |