1 | <?php |
||
10 | class Map_Iterator implements Iterator |
||
11 | { |
||
12 | |||
13 | /** |
||
14 | * @var Iterator |
||
15 | **/ |
||
16 | protected $items; |
||
17 | |||
18 | protected $keyField, $titleField; |
||
|
|||
19 | |||
20 | protected $firstItemIdx = 0; |
||
21 | |||
22 | protected $endItemIdx; |
||
23 | |||
24 | protected $firstItems = array(); |
||
25 | protected $lastItems = array(); |
||
26 | |||
27 | protected $excludedItems = array(); |
||
28 | |||
29 | /** |
||
30 | * @param Iterator $items The iterator to build this map from |
||
31 | * @param string $keyField The field to use for the keys |
||
32 | * @param string $titleField The field to use for the values |
||
33 | * @param array $firstItems An optional map of items to show first |
||
34 | * @param array $lastItems An optional map of items to show last |
||
35 | */ |
||
36 | public function __construct(Iterator $items, $keyField, $titleField, $firstItems = null, $lastItems = null) |
||
58 | |||
59 | /** |
||
60 | * Rewind the Iterator to the first element. |
||
61 | * |
||
62 | * @return mixed |
||
63 | */ |
||
64 | public function rewind() |
||
85 | |||
86 | /** |
||
87 | * Return the current element. |
||
88 | * |
||
89 | * @return mixed |
||
90 | */ |
||
91 | public function current() |
||
102 | |||
103 | /** |
||
104 | * Extracts a value from an item in the list, where the item is either an |
||
105 | * object or array. |
||
106 | * |
||
107 | * @param array|object $item |
||
108 | * @param string $key |
||
109 | * @return mixed |
||
110 | */ |
||
111 | protected function extractValue($item, $key) |
||
124 | |||
125 | /** |
||
126 | * Return the key of the current element. |
||
127 | * |
||
128 | * @return string |
||
129 | */ |
||
130 | public function key() |
||
142 | |||
143 | /** |
||
144 | * Move forward to next element. |
||
145 | * |
||
146 | * @return mixed |
||
147 | */ |
||
148 | public function next() |
||
182 | |||
183 | /** |
||
184 | * Checks if current position is valid. |
||
185 | * |
||
186 | * @return boolean |
||
187 | */ |
||
188 | public function valid() |
||
196 | } |
||
197 |
Only declaring a single property per statement allows you to later on add doc comments more easily.
It is also recommended by PSR2, so it is a common style that many people expect.