1 | <?php |
||
24 | class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable, Serializable |
||
25 | { |
||
26 | /** |
||
27 | * The collection data. |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $items = []; |
||
32 | |||
33 | /** |
||
34 | * set data. |
||
35 | * |
||
36 | * @param mixed $items |
||
37 | */ |
||
38 | public function __construct(array $items = []) |
||
46 | |||
47 | /** |
||
48 | * Return all items. |
||
49 | * |
||
50 | * @return array |
||
51 | */ |
||
52 | public function all() |
||
56 | |||
57 | /** |
||
58 | * Return specific items. |
||
59 | * |
||
60 | * @param array $keys |
||
61 | * |
||
62 | * @return array |
||
63 | */ |
||
64 | public function only(array $keys) |
||
78 | |||
79 | /** |
||
80 | * Get all items except for those with the specified keys. |
||
81 | * |
||
82 | * @param mixed $keys |
||
83 | * |
||
84 | * @return static |
||
85 | */ |
||
86 | public function except($keys) |
||
92 | |||
93 | /** |
||
94 | * Merge data. |
||
95 | * |
||
96 | * @param array $items |
||
97 | * |
||
98 | * @return array |
||
99 | */ |
||
100 | public function merge($items) |
||
108 | |||
109 | /** |
||
110 | * To determine Whether the specified element exists. |
||
111 | * |
||
112 | * @param string $key |
||
113 | * |
||
114 | * @return bool |
||
115 | */ |
||
116 | public function has($key) |
||
120 | |||
121 | /** |
||
122 | * Retrieve the first item. |
||
123 | * |
||
124 | * @return mixed |
||
125 | */ |
||
126 | public function first() |
||
130 | |||
131 | /** |
||
132 | * Retrieve the last item. |
||
133 | * |
||
134 | * @return bool |
||
135 | */ |
||
136 | public function last() |
||
144 | |||
145 | /** |
||
146 | * add the item value. |
||
147 | * |
||
148 | * @param string $key |
||
149 | * @param mixed $value |
||
150 | */ |
||
151 | public function add($key, $value) |
||
155 | |||
156 | /** |
||
157 | * Set the item value. |
||
158 | * |
||
159 | * @param string $key |
||
160 | * @param mixed $value |
||
161 | */ |
||
162 | public function set($key, $value) |
||
166 | |||
167 | /** |
||
168 | * Retrieve item from Collection. |
||
169 | * |
||
170 | * @param string $key |
||
171 | * @param mixed $default |
||
172 | * |
||
173 | * @return mixed |
||
174 | */ |
||
175 | public function get($key, $default = null) |
||
179 | |||
180 | /** |
||
181 | * Remove item form Collection. |
||
182 | * |
||
183 | * @param string $key |
||
184 | */ |
||
185 | public function forget($key) |
||
189 | |||
190 | /** |
||
191 | * Build to array. |
||
192 | * |
||
193 | * @return array |
||
194 | */ |
||
195 | public function toArray() |
||
199 | |||
200 | /** |
||
201 | * Build to json. |
||
202 | * |
||
203 | * @param int $option |
||
204 | * |
||
205 | * @return string |
||
206 | */ |
||
207 | public function toJson($option = JSON_UNESCAPED_UNICODE) |
||
211 | |||
212 | /** |
||
213 | * To string. |
||
214 | * |
||
215 | * @return string |
||
216 | */ |
||
217 | public function __toString() |
||
221 | |||
222 | /** |
||
223 | * (PHP 5 >= 5.4.0)<br/> |
||
224 | * Specify data which should be serialized to JSON. |
||
225 | * |
||
226 | * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
||
227 | * |
||
228 | * @return mixed data which can be serialized by <b>json_encode</b>, |
||
229 | * which is a value of any type other than a resource. |
||
230 | */ |
||
231 | public function jsonSerialize() |
||
235 | |||
236 | /** |
||
237 | * (PHP 5 >= 5.1.0)<br/> |
||
238 | * String representation of object. |
||
239 | * |
||
240 | * @link http://php.net/manual/en/serializable.serialize.php |
||
241 | * |
||
242 | * @return string the string representation of the object or null |
||
243 | */ |
||
244 | public function serialize() |
||
248 | |||
249 | /** |
||
250 | * (PHP 5 >= 5.0.0)<br/> |
||
251 | * Retrieve an external iterator. |
||
252 | * |
||
253 | * @link http://php.net/manual/en/iteratoraggregate.getiterator.php |
||
254 | * |
||
255 | * @return Traversable An instance of an object implementing <b>Iterator</b> or |
||
256 | * <b>Traversable</b> |
||
257 | */ |
||
258 | public function getIterator() |
||
262 | |||
263 | /** |
||
264 | * (PHP 5 >= 5.1.0)<br/> |
||
265 | * Count elements of an object. |
||
266 | * |
||
267 | * @link http://php.net/manual/en/countable.count.php |
||
268 | * |
||
269 | * @return int The custom count as an integer. |
||
270 | * </p> |
||
271 | * <p> |
||
272 | * The return value is cast to an integer. |
||
273 | */ |
||
274 | public function count() |
||
278 | |||
279 | /** |
||
280 | * (PHP 5 >= 5.1.0)<br/> |
||
281 | * Constructs the object. |
||
282 | * |
||
283 | * @link http://php.net/manual/en/serializable.unserialize.php |
||
284 | * |
||
285 | * @param string $serialized <p> |
||
286 | * The string representation of the object. |
||
287 | * </p> |
||
288 | * |
||
289 | * @return mixed|void |
||
290 | */ |
||
291 | public function unserialize($serialized) |
||
295 | |||
296 | /** |
||
297 | * Get a data by key. |
||
298 | * |
||
299 | * @param string $key |
||
300 | * |
||
301 | * @return mixed |
||
302 | */ |
||
303 | public function __get($key) |
||
307 | |||
308 | /** |
||
309 | * Assigns a value to the specified data. |
||
310 | * |
||
311 | * @param string $key |
||
312 | * @param mixed $value |
||
313 | */ |
||
314 | public function __set($key, $value) |
||
318 | |||
319 | /** |
||
320 | * Whether or not an data exists by key. |
||
321 | * |
||
322 | * @param string $key |
||
323 | * |
||
324 | * @return bool |
||
325 | */ |
||
326 | public function __isset($key) |
||
330 | |||
331 | /** |
||
332 | * Unsets an data by key. |
||
333 | * |
||
334 | * @param string $key |
||
335 | */ |
||
336 | public function __unset($key) |
||
340 | |||
341 | /** |
||
342 | * var_export. |
||
343 | * |
||
344 | * @return array |
||
345 | */ |
||
346 | public function __set_state() |
||
350 | |||
351 | /** |
||
352 | * (PHP 5 >= 5.0.0)<br/> |
||
353 | * Whether a offset exists. |
||
354 | * |
||
355 | * @link http://php.net/manual/en/arrayaccess.offsetexists.php |
||
356 | * |
||
357 | * @param mixed $offset <p> |
||
358 | * An offset to check for. |
||
359 | * </p> |
||
360 | * |
||
361 | * @return bool true on success or false on failure. |
||
362 | * The return value will be casted to boolean if non-boolean was returned. |
||
363 | */ |
||
364 | public function offsetExists($offset) |
||
368 | |||
369 | /** |
||
370 | * (PHP 5 >= 5.0.0)<br/> |
||
371 | * Offset to unset. |
||
372 | * |
||
373 | * @link http://php.net/manual/en/arrayaccess.offsetunset.php |
||
374 | * |
||
375 | * @param mixed $offset <p> |
||
376 | * The offset to unset. |
||
377 | * </p> |
||
378 | */ |
||
379 | public function offsetUnset($offset) |
||
385 | |||
386 | /** |
||
387 | * (PHP 5 >= 5.0.0)<br/> |
||
388 | * Offset to retrieve. |
||
389 | * |
||
390 | * @link http://php.net/manual/en/arrayaccess.offsetget.php |
||
391 | * |
||
392 | * @param mixed $offset <p> |
||
393 | * The offset to retrieve. |
||
394 | * </p> |
||
395 | * |
||
396 | * @return mixed Can return all value types. |
||
397 | */ |
||
398 | public function offsetGet($offset) |
||
402 | |||
403 | /** |
||
404 | * (PHP 5 >= 5.0.0)<br/> |
||
405 | * Offset to set. |
||
406 | * |
||
407 | * @link http://php.net/manual/en/arrayaccess.offsetset.php |
||
408 | * |
||
409 | * @param mixed $offset <p> |
||
410 | * The offset to assign the value to. |
||
411 | * </p> |
||
412 | * @param mixed $value <p> |
||
413 | * The value to set. |
||
414 | * </p> |
||
415 | */ |
||
416 | public function offsetSet($offset, $value) |
||
420 | } |
||
421 |