1 | <?php |
||
13 | class Nodelist implements \Iterator, \Countable, \SeekableIterator, \ArrayAccess { |
||
14 | |||
15 | /** |
||
16 | * The driver for traversing this node and its children |
||
17 | * @var Driver |
||
18 | */ |
||
19 | protected $_driver; |
||
20 | |||
21 | /** |
||
22 | * The parent node, NULL if root |
||
23 | * @var Node |
||
24 | */ |
||
25 | protected $_parent; |
||
26 | |||
27 | /** |
||
28 | * Cache for the ids of this node list |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $_list_ids; |
||
32 | |||
33 | /** |
||
34 | * Single node object to be used during iteration |
||
35 | * @var Node |
||
36 | */ |
||
37 | protected $_node; |
||
38 | |||
39 | /** |
||
40 | * Implementing Iterator |
||
41 | * @var integer |
||
42 | */ |
||
43 | protected $_current = 0; |
||
44 | |||
45 | 18 | function __construct(Driver $driver, Locator $locator, Node $parent) |
|
52 | |||
53 | /** |
||
54 | * Returns a string representation of the collection. |
||
55 | * |
||
56 | * @return string |
||
57 | */ |
||
58 | 1 | public function __toString() |
|
67 | |||
68 | /** |
||
69 | * Implementation of the Iterator interface |
||
70 | * @return Nodelist |
||
71 | */ |
||
72 | 2 | public function rewind() |
|
77 | |||
78 | /** |
||
79 | * Implementation of the Iterator interface |
||
80 | * |
||
81 | * @return Node |
||
82 | */ |
||
83 | 2 | public function current() |
|
88 | |||
89 | /** |
||
90 | * Implementation of the Iterator interface |
||
91 | * @return int |
||
92 | */ |
||
93 | 1 | public function key() |
|
97 | |||
98 | /** |
||
99 | * Implementation of the Iterator interface |
||
100 | * @return Nodelist |
||
101 | */ |
||
102 | 2 | public function next() |
|
107 | |||
108 | /** |
||
109 | * Implementation of the Iterator interface |
||
110 | * |
||
111 | * @return boolean |
||
112 | */ |
||
113 | 2 | public function valid() |
|
117 | |||
118 | /** |
||
119 | * Implementation of the Countable interface |
||
120 | * |
||
121 | * @return int |
||
122 | */ |
||
123 | 3 | public function count() |
|
127 | |||
128 | /** |
||
129 | * Implementation of SeekableIterator |
||
130 | * |
||
131 | * @param mixed $offset |
||
132 | * @return boolean |
||
133 | */ |
||
134 | 1 | public function seek($offset) |
|
143 | |||
144 | /** |
||
145 | * ArrayAccess: offsetExists |
||
146 | * |
||
147 | * @param mixed $offset |
||
148 | * @return boolean |
||
149 | */ |
||
150 | 3 | public function offsetExists($offset) |
|
154 | |||
155 | /** |
||
156 | * ArrayAccess: offsetGet |
||
157 | * |
||
158 | * @param mixed $offset |
||
159 | * @return Node |
||
160 | */ |
||
161 | 1 | public function offsetGet($offset) |
|
168 | |||
169 | /** |
||
170 | * ArrayAccess: offsetSet |
||
171 | * |
||
172 | * @throws Kohana_Exception |
||
173 | * @param mixed $offset |
||
174 | * @param mixed $value |
||
175 | * @return void |
||
176 | */ |
||
177 | 1 | public function offsetSet($offset, $value) |
|
181 | |||
182 | /** |
||
183 | * ArrayAccess: offsetUnset |
||
184 | * |
||
185 | * @throws Kohana_Exception |
||
186 | * @param mixed $offset |
||
187 | * @return void |
||
188 | */ |
||
189 | 1 | public function offsetUnset($offset) |
|
193 | |||
194 | 14 | protected function _load($id) |
|
198 | |||
199 | 15 | protected function list_ids() |
|
219 | |||
220 | 2 | public function locator() |
|
224 | |||
225 | 1 | public function driver() |
|
229 | |||
230 | 12 | public function first() |
|
239 | |||
240 | 1 | public function last() |
|
249 | |||
250 | 1 | public function as_array() |
|
259 | |||
260 | } |
||
261 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.