1 | <?php |
||
12 | abstract class base_collection implements \Iterator, \Countable, \ArrayAccess |
||
13 | { |
||
14 | protected $entities = array(); |
||
15 | |||
16 | protected $entity_class; |
||
17 | |||
18 | /** |
||
19 | * Get the entities stored in the collection |
||
20 | */ |
||
21 | 10 | public function get_entities() |
|
25 | |||
26 | /** |
||
27 | * Clear the collection |
||
28 | */ |
||
29 | 82 | public function clear() |
|
33 | |||
34 | /** |
||
35 | * Reset the collection (implementation required by Iterator Interface) |
||
36 | */ |
||
37 | 51 | public function rewind() |
|
41 | |||
42 | /** |
||
43 | * Get the current entity in the collection (implementation required by Iterator Interface) |
||
44 | * |
||
45 | * @return mixed |
||
46 | */ |
||
47 | 54 | public function current() |
|
51 | |||
52 | /** |
||
53 | * Get the next entity in the collection (implementation required by Iterator Interface) |
||
54 | * |
||
55 | * @return mixed |
||
56 | */ |
||
57 | 50 | public function next() |
|
61 | |||
62 | /** |
||
63 | * Get the key of the current entity in the collection (implementation required by Iterator Interface) |
||
64 | * |
||
65 | * @return mixed |
||
66 | */ |
||
67 | 4 | public function key() |
|
71 | |||
72 | /** |
||
73 | * Check if there’re more entities in the collection (implementation required by Iterator Interface) |
||
74 | * |
||
75 | * @return bool |
||
76 | */ |
||
77 | 52 | public function valid() |
|
81 | |||
82 | /** |
||
83 | * Count the number of entities in the collection (implementation required by Countable Interface) |
||
84 | * |
||
85 | * @return mixed |
||
86 | */ |
||
87 | 22 | public function count() |
|
91 | |||
92 | /** |
||
93 | * Add an entity to the collection (implementation required by ArrayAccess interface) |
||
94 | * |
||
95 | * @param mixed $key |
||
96 | * @param mixed $entity |
||
97 | * @return bool |
||
98 | * @throws \blitze\sitemaker\exception\invalid_argument |
||
99 | */ |
||
100 | 79 | public function offsetSet($key, $entity) |
|
117 | |||
118 | /** |
||
119 | * Remove an entity from the collection (implementation required by ArrayAccess interface) |
||
120 | * |
||
121 | * @param mixed $key |
||
122 | * @return bool |
||
123 | */ |
||
124 | 4 | public function offsetUnset($key) |
|
145 | |||
146 | /** |
||
147 | * Get the specified entity in the collection (implementation required by ArrayAccess interface) |
||
148 | * |
||
149 | * @param mixed $key |
||
150 | * @return null |
||
151 | */ |
||
152 | 5 | public function offsetGet($key) |
|
156 | |||
157 | /** |
||
158 | * Check if the specified entity exists in the collection (implementation required by ArrayAccess interface) |
||
159 | * |
||
160 | * @param mixed $key |
||
161 | * @return bool |
||
162 | */ |
||
163 | 6 | public function offsetExists($key) |
|
167 | } |
||
168 |