1 | <?php |
||
13 | class Directory extends AccessRights implements Iterator |
||
14 | { |
||
15 | /** |
||
16 | * Position of the iteration |
||
17 | * |
||
18 | * @var int |
||
19 | **/ |
||
20 | private $position = 0; |
||
21 | |||
22 | /** |
||
23 | * Child nodes |
||
24 | * |
||
25 | * @var Node[] |
||
26 | **/ |
||
27 | private $children = array(); |
||
28 | |||
29 | /** |
||
30 | * Scan the child nodes for a path |
||
31 | * |
||
32 | * When given a path like `foo/bar/baz`, it will see if directory `foo` |
||
33 | * exists, it has a child directory node `bar`, which should have a child |
||
34 | * node `baz` |
||
35 | * |
||
36 | * Will return either the found child node, or boolean false |
||
37 | * |
||
38 | * @param string $path |
||
39 | * @return Node|bool |
||
40 | **/ |
||
41 | public function scan($path) |
||
65 | |||
66 | /** |
||
67 | * Get the child nodes |
||
68 | * |
||
69 | * @return Node[] |
||
70 | */ |
||
71 | public function getChildren() |
||
75 | |||
76 | /** |
||
77 | * Set the child nodes |
||
78 | * |
||
79 | * @param Node[] $children |
||
80 | * @return Directory |
||
81 | */ |
||
82 | public function setChildren(array $children) |
||
88 | |||
89 | /** |
||
90 | * Add a child |
||
91 | * |
||
92 | * @param Node $child |
||
93 | * @return Directory |
||
94 | **/ |
||
95 | public function addChild(Node $child) |
||
103 | |||
104 | /** |
||
105 | * Does a child with name $name exist? |
||
106 | * |
||
107 | * @param string $name |
||
108 | * @return bool |
||
109 | **/ |
||
110 | public function hasChild($name) |
||
120 | |||
121 | /** |
||
122 | * Get a child with name $name |
||
123 | * |
||
124 | * @param string $name |
||
125 | * @return Node |
||
126 | **/ |
||
127 | public function getChild($name) |
||
140 | |||
141 | /** |
||
142 | * Rewind iterator |
||
143 | * |
||
144 | * @return void |
||
145 | **/ |
||
146 | public function rewind() |
||
150 | |||
151 | /** |
||
152 | * Get current node |
||
153 | * |
||
154 | * @return Node |
||
155 | **/ |
||
156 | public function current() |
||
160 | |||
161 | /** |
||
162 | * Get current key |
||
163 | * |
||
164 | * @return int |
||
165 | **/ |
||
166 | public function key() |
||
170 | |||
171 | /** |
||
172 | * Go to next position |
||
173 | * |
||
174 | * @return void |
||
175 | **/ |
||
176 | public function next() |
||
180 | |||
181 | /** |
||
182 | * Is the iterator in a valid position? |
||
183 | * |
||
184 | * @return bool |
||
185 | **/ |
||
186 | public function valid() |
||
190 | } |
||
191 |