1 | <?php |
||
16 | class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable, Serializable, Arrayable |
||
17 | { |
||
18 | /** |
||
19 | * The collection data. |
||
20 | * |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $items = []; |
||
24 | |||
25 | /** |
||
26 | * set data. |
||
27 | * |
||
28 | * @param mixed $items |
||
29 | */ |
||
30 | public function __construct(array $items = []) |
||
36 | |||
37 | /** |
||
38 | * Return all items. |
||
39 | * |
||
40 | * @return array |
||
41 | */ |
||
42 | public function all() |
||
46 | |||
47 | /** |
||
48 | * Return specific items. |
||
49 | * |
||
50 | * @param array $keys |
||
51 | * |
||
52 | * @return \PiaoST\Kernel\Support\Collection |
||
53 | */ |
||
54 | public function only(array $keys) |
||
68 | |||
69 | /** |
||
70 | * Get all items except for those with the specified keys. |
||
71 | * |
||
72 | * @param mixed $keys |
||
73 | * |
||
74 | * @return static |
||
75 | */ |
||
76 | public function except($keys) |
||
82 | |||
83 | /** |
||
84 | * Merge data. |
||
85 | * |
||
86 | * @param Collection|array $items |
||
87 | * |
||
88 | * @return \PiaoST\Kernel\Support\Collection |
||
89 | */ |
||
90 | public function merge($items) |
||
100 | |||
101 | /** |
||
102 | * To determine Whether the specified element exists. |
||
103 | * |
||
104 | * @param string $key |
||
105 | * |
||
106 | * @return bool |
||
107 | */ |
||
108 | public function has($key) |
||
112 | |||
113 | /** |
||
114 | * Retrieve the first item. |
||
115 | * |
||
116 | * @return mixed |
||
117 | */ |
||
118 | public function first() |
||
122 | |||
123 | /** |
||
124 | * Retrieve the last item. |
||
125 | * |
||
126 | * @return bool |
||
127 | */ |
||
128 | public function last() |
||
136 | |||
137 | /** |
||
138 | * add the item value. |
||
139 | * |
||
140 | * @param string $key |
||
141 | * @param mixed $value |
||
142 | */ |
||
143 | public function add($key, $value) |
||
147 | |||
148 | /** |
||
149 | * Set the item value. |
||
150 | * |
||
151 | * @param string $key |
||
152 | * @param mixed $value |
||
153 | */ |
||
154 | public function set($key, $value) |
||
158 | |||
159 | /** |
||
160 | * Retrieve item from Collection. |
||
161 | * |
||
162 | * @param string $key |
||
163 | * @param mixed $default |
||
164 | * |
||
165 | * @return mixed |
||
166 | */ |
||
167 | public function get($key, $default = null) |
||
171 | |||
172 | /** |
||
173 | * Remove item form Collection. |
||
174 | * |
||
175 | * @param string $key |
||
176 | */ |
||
177 | public function forget($key) |
||
181 | |||
182 | /** |
||
183 | * Build to array. |
||
184 | * |
||
185 | * @return array |
||
186 | */ |
||
187 | public function toArray() |
||
191 | |||
192 | /** |
||
193 | * Build to json. |
||
194 | * |
||
195 | * @param int $option |
||
196 | * |
||
197 | * @return string |
||
198 | */ |
||
199 | public function toJson($option = JSON_UNESCAPED_UNICODE) |
||
203 | |||
204 | /** |
||
205 | * To string. |
||
206 | * |
||
207 | * @return string |
||
208 | */ |
||
209 | public function __toString() |
||
213 | |||
214 | /** |
||
215 | * (PHP 5 >= 5.4.0)<br/> |
||
216 | * Specify data which should be serialized to JSON. |
||
217 | * |
||
218 | * @see http://php.net/manual/en/jsonserializable.jsonserialize.php |
||
219 | * |
||
220 | * @return mixed data which can be serialized by <b>json_encode</b>, |
||
221 | * which is a value of any type other than a resource |
||
222 | */ |
||
223 | public function jsonSerialize() |
||
227 | |||
228 | /** |
||
229 | * (PHP 5 >= 5.1.0)<br/> |
||
230 | * String representation of object. |
||
231 | * |
||
232 | * @see http://php.net/manual/en/serializable.serialize.php |
||
233 | * |
||
234 | * @return string the string representation of the object or null |
||
235 | */ |
||
236 | public function serialize() |
||
240 | |||
241 | /** |
||
242 | * (PHP 5 >= 5.0.0)<br/> |
||
243 | * Retrieve an external iterator. |
||
244 | * |
||
245 | * @see http://php.net/manual/en/iteratoraggregate.getiterator.php |
||
246 | * |
||
247 | * @return \ArrayIterator An instance of an object implementing <b>Iterator</b> or |
||
248 | * <b>Traversable</b> |
||
249 | */ |
||
250 | public function getIterator() |
||
254 | |||
255 | /** |
||
256 | * (PHP 5 >= 5.1.0)<br/> |
||
257 | * Count elements of an object. |
||
258 | * |
||
259 | * @see http://php.net/manual/en/countable.count.php |
||
260 | * |
||
261 | * @return int the custom count as an integer. |
||
262 | * </p> |
||
263 | * <p> |
||
264 | * The return value is cast to an integer |
||
265 | */ |
||
266 | public function count() |
||
270 | |||
271 | /** |
||
272 | * (PHP 5 >= 5.1.0)<br/> |
||
273 | * Constructs the object. |
||
274 | * |
||
275 | * @see http://php.net/manual/en/serializable.unserialize.php |
||
276 | * |
||
277 | * @param string $serialized <p> |
||
278 | * The string representation of the object. |
||
279 | * </p> |
||
280 | * |
||
281 | * @return mixed|void |
||
282 | */ |
||
283 | public function unserialize($serialized) |
||
287 | |||
288 | /** |
||
289 | * Get a data by key. |
||
290 | * |
||
291 | * @param string $key |
||
292 | * |
||
293 | * @return mixed |
||
294 | */ |
||
295 | public function __get($key) |
||
299 | |||
300 | /** |
||
301 | * Assigns a value to the specified data. |
||
302 | * |
||
303 | * @param string $key |
||
304 | * @param mixed $value |
||
305 | */ |
||
306 | public function __set($key, $value) |
||
310 | |||
311 | /** |
||
312 | * Whether or not an data exists by key. |
||
313 | * |
||
314 | * @param string $key |
||
315 | * |
||
316 | * @return bool |
||
317 | */ |
||
318 | public function __isset($key) |
||
322 | |||
323 | /** |
||
324 | * Unset an data by key. |
||
325 | * |
||
326 | * @param string $key |
||
327 | */ |
||
328 | public function __unset($key) |
||
332 | |||
333 | /** |
||
334 | * var_export. |
||
335 | * |
||
336 | * @return array |
||
337 | */ |
||
338 | public function __set_state() |
||
342 | |||
343 | /** |
||
344 | * (PHP 5 >= 5.0.0)<br/> |
||
345 | * Whether a offset exists. |
||
346 | * |
||
347 | * @see http://php.net/manual/en/arrayaccess.offsetexists.php |
||
348 | * |
||
349 | * @param mixed $offset <p> |
||
350 | * An offset to check for. |
||
351 | * </p> |
||
352 | * |
||
353 | * @return bool true on success or false on failure. |
||
354 | * The return value will be casted to boolean if non-boolean was returned |
||
355 | */ |
||
356 | public function offsetExists($offset) |
||
360 | |||
361 | /** |
||
362 | * (PHP 5 >= 5.0.0)<br/> |
||
363 | * Offset to unset. |
||
364 | * |
||
365 | * @see http://php.net/manual/en/arrayaccess.offsetunset.php |
||
366 | * |
||
367 | * @param mixed $offset <p> |
||
368 | * The offset to unset. |
||
369 | * </p> |
||
370 | */ |
||
371 | public function offsetUnset($offset) |
||
377 | |||
378 | /** |
||
379 | * (PHP 5 >= 5.0.0)<br/> |
||
380 | * Offset to retrieve. |
||
381 | * |
||
382 | * @see http://php.net/manual/en/arrayaccess.offsetget.php |
||
383 | * |
||
384 | * @param mixed $offset <p> |
||
385 | * The offset to retrieve. |
||
386 | * </p> |
||
387 | * |
||
388 | * @return mixed Can return all value types |
||
389 | */ |
||
390 | public function offsetGet($offset) |
||
394 | |||
395 | /** |
||
396 | * (PHP 5 >= 5.0.0)<br/> |
||
397 | * Offset to set. |
||
398 | * |
||
399 | * @see http://php.net/manual/en/arrayaccess.offsetset.php |
||
400 | * |
||
401 | * @param mixed $offset <p> |
||
402 | * The offset to assign the value to. |
||
403 | * </p> |
||
404 | * @param mixed $value <p> |
||
405 | * The value to set. |
||
406 | * </p> |
||
407 | */ |
||
408 | public function offsetSet($offset, $value) |
||
412 | } |
||
413 |