1 | <?php |
||
33 | class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable, Serializable |
||
34 | { |
||
35 | /** |
||
36 | * The collection data. |
||
37 | * |
||
38 | * @var array |
||
39 | */ |
||
40 | protected $items = []; |
||
41 | |||
42 | /** |
||
43 | * set data. |
||
44 | * |
||
45 | * @param mixed $items |
||
46 | */ |
||
47 | public function __construct(array $items = []) |
||
55 | |||
56 | /** |
||
57 | * Return all items. |
||
58 | * |
||
59 | * @return array |
||
60 | */ |
||
61 | public function all() |
||
65 | |||
66 | /** |
||
67 | * Return specific items. |
||
68 | * |
||
69 | * @param array $keys |
||
70 | * |
||
71 | * @return array |
||
72 | */ |
||
73 | public function only(array $keys) |
||
87 | |||
88 | /** |
||
89 | * Get all items except for those with the specified keys. |
||
90 | * |
||
91 | * @param mixed $keys |
||
92 | * |
||
93 | * @return static |
||
94 | */ |
||
95 | public function except($keys) |
||
101 | |||
102 | /** |
||
103 | * Merge data. |
||
104 | * |
||
105 | * @param array $items |
||
106 | * |
||
107 | * @return array |
||
108 | */ |
||
109 | public function merge($items) |
||
117 | |||
118 | /** |
||
119 | * To determine Whether the specified element exists. |
||
120 | * |
||
121 | * @param string $key |
||
122 | * |
||
123 | * @return bool |
||
124 | */ |
||
125 | public function has($key) |
||
129 | |||
130 | /** |
||
131 | * Retrieve the first item. |
||
132 | * |
||
133 | * @return mixed |
||
134 | */ |
||
135 | public function first() |
||
139 | |||
140 | /** |
||
141 | * Retrieve the last item. |
||
142 | * |
||
143 | * @return bool |
||
144 | */ |
||
145 | public function last() |
||
153 | |||
154 | /** |
||
155 | * add the item value. |
||
156 | * |
||
157 | * @param string $key |
||
158 | * @param mixed $value |
||
159 | */ |
||
160 | public function add($key, $value) |
||
164 | |||
165 | /** |
||
166 | * Set the item value. |
||
167 | * |
||
168 | * @param string $key |
||
169 | * @param mixed $value |
||
170 | */ |
||
171 | public function set($key, $value) |
||
175 | |||
176 | /** |
||
177 | * Retrieve item from Collection. |
||
178 | * |
||
179 | * @param string $key |
||
180 | * @param mixed $default |
||
181 | * |
||
182 | * @return mixed |
||
183 | */ |
||
184 | public function get($key, $default = null) |
||
188 | |||
189 | /** |
||
190 | * Remove item form Collection. |
||
191 | * |
||
192 | * @param string $key |
||
193 | */ |
||
194 | public function forget($key) |
||
198 | |||
199 | /** |
||
200 | * Build to array. |
||
201 | * |
||
202 | * @return array |
||
203 | */ |
||
204 | public function toArray() |
||
208 | |||
209 | /** |
||
210 | * Build to json. |
||
211 | * |
||
212 | * @param int $option |
||
213 | * |
||
214 | * @return string |
||
215 | */ |
||
216 | public function toJson($option = JSON_UNESCAPED_UNICODE) |
||
220 | |||
221 | /** |
||
222 | * To string. |
||
223 | * |
||
224 | * @return string |
||
225 | */ |
||
226 | public function __toString() |
||
230 | |||
231 | /** |
||
232 | * (PHP 5 >= 5.4.0)<br/> |
||
233 | * Specify data which should be serialized to JSON. |
||
234 | * |
||
235 | * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
||
236 | * |
||
237 | * @return mixed data which can be serialized by <b>json_encode</b>, |
||
238 | * which is a value of any type other than a resource. |
||
239 | */ |
||
240 | public function jsonSerialize() |
||
244 | |||
245 | /** |
||
246 | * (PHP 5 >= 5.1.0)<br/> |
||
247 | * String representation of object. |
||
248 | * |
||
249 | * @link http://php.net/manual/en/serializable.serialize.php |
||
250 | * |
||
251 | * @return string the string representation of the object or null |
||
252 | */ |
||
253 | public function serialize() |
||
257 | |||
258 | /** |
||
259 | * (PHP 5 >= 5.0.0)<br/> |
||
260 | * Retrieve an external iterator. |
||
261 | * |
||
262 | * @link http://php.net/manual/en/iteratoraggregate.getiterator.php |
||
263 | * |
||
264 | * @return Traversable An instance of an object implementing <b>Iterator</b> or |
||
265 | * <b>Traversable</b> |
||
266 | */ |
||
267 | public function getIterator() |
||
271 | |||
272 | /** |
||
273 | * (PHP 5 >= 5.1.0)<br/> |
||
274 | * Count elements of an object. |
||
275 | * |
||
276 | * @link http://php.net/manual/en/countable.count.php |
||
277 | * |
||
278 | * @return int The custom count as an integer. |
||
279 | * </p> |
||
280 | * <p> |
||
281 | * The return value is cast to an integer. |
||
282 | */ |
||
283 | public function count() |
||
287 | |||
288 | /** |
||
289 | * (PHP 5 >= 5.1.0)<br/> |
||
290 | * Constructs the object. |
||
291 | * |
||
292 | * @link http://php.net/manual/en/serializable.unserialize.php |
||
293 | * |
||
294 | * @param string $serialized <p> |
||
295 | * The string representation of the object. |
||
296 | * </p> |
||
297 | * |
||
298 | * @return mixed|void |
||
299 | */ |
||
300 | public function unserialize($serialized) |
||
304 | |||
305 | /** |
||
306 | * Get a data by key. |
||
307 | * |
||
308 | * @param string $key |
||
309 | * |
||
310 | * @return mixed |
||
311 | */ |
||
312 | public function __get($key) |
||
316 | |||
317 | /** |
||
318 | * Assigns a value to the specified data. |
||
319 | * |
||
320 | * @param string $key |
||
321 | * @param mixed $value |
||
322 | */ |
||
323 | public function __set($key, $value) |
||
327 | |||
328 | /** |
||
329 | * Whether or not an data exists by key. |
||
330 | * |
||
331 | * @param string $key |
||
332 | * |
||
333 | * @return bool |
||
334 | */ |
||
335 | public function __isset($key) |
||
339 | |||
340 | /** |
||
341 | * Unsets an data by key. |
||
342 | * |
||
343 | * @param string $key |
||
344 | */ |
||
345 | public function __unset($key) |
||
349 | |||
350 | /** |
||
351 | * var_export. |
||
352 | * |
||
353 | * @return array |
||
354 | */ |
||
355 | public function __set_state() |
||
359 | |||
360 | /** |
||
361 | * (PHP 5 >= 5.0.0)<br/> |
||
362 | * Whether a offset exists. |
||
363 | * |
||
364 | * @link http://php.net/manual/en/arrayaccess.offsetexists.php |
||
365 | * |
||
366 | * @param mixed $offset <p> |
||
367 | * An offset to check for. |
||
368 | * </p> |
||
369 | * |
||
370 | * @return bool true on success or false on failure. |
||
371 | * The return value will be casted to boolean if non-boolean was returned. |
||
372 | */ |
||
373 | public function offsetExists($offset) |
||
377 | |||
378 | /** |
||
379 | * (PHP 5 >= 5.0.0)<br/> |
||
380 | * Offset to unset. |
||
381 | * |
||
382 | * @link http://php.net/manual/en/arrayaccess.offsetunset.php |
||
383 | * |
||
384 | * @param mixed $offset <p> |
||
385 | * The offset to unset. |
||
386 | * </p> |
||
387 | */ |
||
388 | public function offsetUnset($offset) |
||
394 | |||
395 | /** |
||
396 | * (PHP 5 >= 5.0.0)<br/> |
||
397 | * Offset to retrieve. |
||
398 | * |
||
399 | * @link http://php.net/manual/en/arrayaccess.offsetget.php |
||
400 | * |
||
401 | * @param mixed $offset <p> |
||
402 | * The offset to retrieve. |
||
403 | * </p> |
||
404 | * |
||
405 | * @return mixed Can return all value types. |
||
406 | */ |
||
407 | public function offsetGet($offset) |
||
411 | |||
412 | /** |
||
413 | * (PHP 5 >= 5.0.0)<br/> |
||
414 | * Offset to set. |
||
415 | * |
||
416 | * @link http://php.net/manual/en/arrayaccess.offsetset.php |
||
417 | * |
||
418 | * @param mixed $offset <p> |
||
419 | * The offset to assign the value to. |
||
420 | * </p> |
||
421 | * @param mixed $value <p> |
||
422 | * The value to set. |
||
423 | * </p> |
||
424 | */ |
||
425 | public function offsetSet($offset, $value) |
||
429 | } |
||
430 |