1 | <?php |
||
8 | class IndexNode implements \Countable |
||
9 | { |
||
10 | /** |
||
11 | * @var IndexObject |
||
12 | */ |
||
13 | protected $indexObject; |
||
14 | |||
15 | /** |
||
16 | * @var IndexNode[] |
||
17 | */ |
||
18 | protected $children = []; |
||
19 | |||
20 | /** |
||
21 | * @var IndexNode |
||
22 | */ |
||
23 | protected $parent; |
||
24 | |||
25 | /** |
||
26 | * For the construction of a root node both arguments have to be null. |
||
27 | * For the construction of regular or leaf nodes both arguments have to be given. |
||
28 | * |
||
29 | * @param IndexObject $indexObject |
||
30 | * @param IndexNode $parent |
||
31 | */ |
||
32 | public function __construct(IndexObject $indexObject = null, IndexNode $parent = null) |
||
39 | |||
40 | public function getIndexObject(): IndexObject |
||
44 | |||
45 | public function setIndexObject(IndexObject $indexObject): IndexNode |
||
53 | |||
54 | /** |
||
55 | * Returns map from index object basename to child node. |
||
56 | * |
||
57 | * @return array |
||
58 | */ |
||
59 | public function getChildren(): array |
||
63 | |||
64 | public function getParent(): ?IndexNode |
||
68 | |||
69 | public function getChild(string $name): ?IndexNode |
||
73 | |||
74 | public function hasChild(string $name): bool |
||
78 | |||
79 | public function addChild(IndexNode $indexNode): IndexNode |
||
91 | |||
92 | public function addChildren(array $children): IndexNode |
||
101 | |||
102 | public function getNodeByPath(string $path): ?IndexNode |
||
118 | |||
119 | /** |
||
120 | * Recursively counts all children and its children and returns total. |
||
121 | * |
||
122 | * @return int |
||
123 | */ |
||
124 | public function recursiveCount() |
||
132 | |||
133 | /** |
||
134 | * {@inheritdoc} |
||
135 | */ |
||
136 | public function count() |
||
140 | } |
||
141 |