1 | <?php |
||
19 | class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable, Serializable |
||
20 | { |
||
21 | /** |
||
22 | * The collection data. |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $items = []; |
||
27 | |||
28 | public function __construct($items = []) |
||
32 | |||
33 | /** |
||
34 | * Return all items. |
||
35 | * |
||
36 | * @return array |
||
37 | */ |
||
38 | public function all() |
||
42 | |||
43 | /** |
||
44 | * Return specific items. |
||
45 | * |
||
46 | * @param array $keys |
||
47 | * |
||
48 | * @return array |
||
49 | */ |
||
50 | public function only($keys) |
||
65 | |||
66 | /** |
||
67 | * Replace the items |
||
68 | * |
||
69 | * @param $items |
||
70 | */ |
||
71 | public function setAll($items) |
||
75 | |||
76 | /** |
||
77 | * Set the item value. |
||
78 | * |
||
79 | * @param string $key |
||
80 | * @param mixed $value |
||
81 | */ |
||
82 | public function set($key, $value) |
||
90 | |||
91 | /** |
||
92 | * Retrieve item from Collection. |
||
93 | * |
||
94 | * @param string $key |
||
95 | * @param mixed $default |
||
96 | * |
||
97 | * @return mixed |
||
98 | */ |
||
99 | public function get($key, $default = null) |
||
103 | |||
104 | /** |
||
105 | * To determine Whether the specified element exists |
||
106 | * |
||
107 | * @param string $key |
||
108 | * @return bool |
||
109 | */ |
||
110 | public function has($key) |
||
114 | |||
115 | /** |
||
116 | * Remove item form Collection. |
||
117 | * |
||
118 | * @param array|string $keys |
||
119 | */ |
||
120 | public function forget($keys) |
||
124 | |||
125 | /** |
||
126 | * Merge data. |
||
127 | * |
||
128 | * @param Collection|array $items |
||
129 | * |
||
130 | * @return \TimSDK\Support\Collection |
||
131 | */ |
||
132 | public function merge($items) |
||
142 | |||
143 | /** |
||
144 | * Build to array. |
||
145 | * |
||
146 | * @return array |
||
147 | */ |
||
148 | public function toArray() |
||
152 | |||
153 | /** |
||
154 | * Build to json. |
||
155 | * |
||
156 | * @param int $option |
||
157 | * |
||
158 | * @return string |
||
159 | */ |
||
160 | public function toJson($option = JSON_UNESCAPED_UNICODE) |
||
164 | |||
165 | /** |
||
166 | * Count elements of an object |
||
167 | * @link http://php.net/manual/en/countable.count.php |
||
168 | * @return int The custom count as an integer. |
||
169 | * </p> |
||
170 | * <p> |
||
171 | * The return value is cast to an integer. |
||
172 | * @since 5.1.0 |
||
173 | */ |
||
174 | public function count() |
||
178 | |||
179 | /** |
||
180 | * Retrieve an external iterator |
||
181 | * @link http://php.net/manual/en/iteratoraggregate.getiterator.php |
||
182 | * @return ArrayIterator |
||
183 | * <b>Traversable</b> |
||
184 | * @since 5.0.0 |
||
185 | */ |
||
186 | public function getIterator() |
||
190 | |||
191 | /** |
||
192 | * Specify data which should be serialized to JSON |
||
193 | * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
||
194 | * @return mixed data which can be serialized by <b>json_encode</b>, |
||
195 | * which is a value of any type other than a resource. |
||
196 | * @since 5.4.0 |
||
197 | */ |
||
198 | public function jsonSerialize() |
||
202 | |||
203 | /** |
||
204 | * String representation of object |
||
205 | * @link http://php.net/manual/en/serializable.serialize.php |
||
206 | * @return string the string representation of the object or null |
||
207 | * @since 5.1.0 |
||
208 | */ |
||
209 | public function serialize() |
||
213 | |||
214 | /** |
||
215 | * Constructs the object |
||
216 | * @link http://php.net/manual/en/serializable.unserialize.php |
||
217 | * @param string $serialized <p> |
||
218 | * The string representation of the object. |
||
219 | * </p> |
||
220 | * @return array |
||
221 | * @since 5.1.0 |
||
222 | */ |
||
223 | public function unserialize($serialized) |
||
227 | |||
228 | /** |
||
229 | * To string. |
||
230 | * |
||
231 | * @return string |
||
232 | */ |
||
233 | public function __toString() |
||
237 | |||
238 | /** |
||
239 | * Assigns a value to the specified data. |
||
240 | * |
||
241 | * @param string $key |
||
242 | * @param mixed $value |
||
243 | */ |
||
244 | public function __set($key, $value) |
||
248 | |||
249 | /** |
||
250 | * Get a data by key. |
||
251 | * |
||
252 | * @param string $key |
||
253 | * |
||
254 | * @return mixed |
||
255 | */ |
||
256 | public function __get($key) |
||
260 | |||
261 | /** |
||
262 | * Whether or not an data exists by key. |
||
263 | * |
||
264 | * @param string $key |
||
265 | * |
||
266 | * @return bool |
||
267 | */ |
||
268 | public function __isset($key) |
||
272 | |||
273 | /** |
||
274 | * Unsets an data by key. |
||
275 | * |
||
276 | * @param string $key |
||
277 | */ |
||
278 | public function __unset($key) |
||
282 | |||
283 | /** |
||
284 | * var_export. |
||
285 | * |
||
286 | * @return array |
||
287 | */ |
||
288 | public function __set_state() |
||
292 | |||
293 | /** |
||
294 | * (PHP 5 >= 5.0.0)<br/> |
||
295 | * Whether a offset exists. |
||
296 | * |
||
297 | * @see http://php.net/manual/en/arrayaccess.offsetexists.php |
||
298 | * |
||
299 | * @param mixed $offset <p> |
||
300 | * An offset to check for. |
||
301 | * </p> |
||
302 | * |
||
303 | * @return bool true on success or false on failure. |
||
304 | * The return value will be casted to boolean if non-boolean was returned |
||
305 | */ |
||
306 | public function offsetExists($offset) |
||
310 | |||
311 | /** |
||
312 | * (PHP 5 >= 5.0.0)<br/> |
||
313 | * Offset to unset. |
||
314 | * |
||
315 | * @see http://php.net/manual/en/arrayaccess.offsetunset.php |
||
316 | * |
||
317 | * @param mixed $offset <p> |
||
318 | * The offset to unset. |
||
319 | * </p> |
||
320 | */ |
||
321 | public function offsetUnset($offset) |
||
327 | |||
328 | /** |
||
329 | * (PHP 5 >= 5.0.0)<br/> |
||
330 | * Offset to retrieve. |
||
331 | * |
||
332 | * @see http://php.net/manual/en/arrayaccess.offsetget.php |
||
333 | * |
||
334 | * @param mixed $offset <p> |
||
335 | * The offset to retrieve. |
||
336 | * </p> |
||
337 | * |
||
338 | * @return mixed Can return all value types |
||
339 | */ |
||
340 | public function offsetGet($offset) |
||
344 | |||
345 | /** |
||
346 | * (PHP 5 >= 5.0.0)<br/> |
||
347 | * Offset to set. |
||
348 | * |
||
349 | * @see http://php.net/manual/en/arrayaccess.offsetset.php |
||
350 | * |
||
351 | * @param mixed $offset <p> |
||
352 | * The offset to assign the value to. |
||
353 | * </p> |
||
354 | * @param mixed $value <p> |
||
355 | * The value to set. |
||
356 | * </p> |
||
357 | */ |
||
358 | public function offsetSet($offset, $value) |
||
362 | |||
363 | /** |
||
364 | * Results array of items from Collection or Arrayable. |
||
365 | * |
||
366 | * @param mixed $items |
||
367 | * @return array |
||
368 | */ |
||
369 | protected function getArrayableItems($items) |
||
384 | } |
||
385 |