1 | <?php |
||
11 | class Collection implements CollectionContract, ArrayAccess, Countable, Iterator, JsonSerializable |
||
12 | { |
||
13 | /** |
||
14 | * Collection items. |
||
15 | * |
||
16 | * @var array |
||
17 | */ |
||
18 | protected $items = []; |
||
19 | |||
20 | /** |
||
21 | * Iterator position. |
||
22 | * |
||
23 | * @var int |
||
24 | */ |
||
25 | protected $position = 0; |
||
26 | |||
27 | /** |
||
28 | * Collection keys. |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $keys = []; |
||
33 | |||
34 | /** |
||
35 | * @param array $items = [] |
||
36 | */ |
||
37 | public function __construct(array $items = []) |
||
43 | |||
44 | /** |
||
45 | * Determines if given key exists in current collection. |
||
46 | * |
||
47 | * @param mixed $key |
||
48 | * |
||
49 | * @return bool |
||
50 | */ |
||
51 | public function has($key) |
||
55 | |||
56 | /** |
||
57 | * Retrieves item by given key from current collection. |
||
58 | * |
||
59 | * @param mixed $key |
||
60 | * |
||
61 | * @return mixed|null |
||
62 | */ |
||
63 | public function get($key) |
||
67 | |||
68 | /** |
||
69 | * Collection size. |
||
70 | * |
||
71 | * @return int |
||
72 | */ |
||
73 | public function count() |
||
77 | |||
78 | /** |
||
79 | * Determines if given offset exists in current collection. |
||
80 | * |
||
81 | * @param mixed $offset |
||
82 | * |
||
83 | * @return bool |
||
84 | */ |
||
85 | public function offsetExists($offset) |
||
89 | |||
90 | /** |
||
91 | * Puts value to given offset or appends it to current collection. |
||
92 | * |
||
93 | * @param mixed $offset |
||
94 | * @param mixed $value |
||
95 | */ |
||
96 | public function offsetSet($offset, $value) |
||
106 | |||
107 | /** |
||
108 | * Retrieves given offset from current collection. |
||
109 | * Returns NULL if no value found. |
||
110 | * |
||
111 | * @param mixed $offset |
||
112 | * |
||
113 | * @return mixed|null |
||
114 | */ |
||
115 | public function offsetGet($offset) |
||
119 | |||
120 | /** |
||
121 | * Drops given offset from current collection. |
||
122 | * |
||
123 | * @param mixed $offset |
||
124 | */ |
||
125 | public function offsetUnset($offset) |
||
131 | |||
132 | /** |
||
133 | * Rewinds iterator back to first position. |
||
134 | */ |
||
135 | public function rewind() |
||
139 | |||
140 | /** |
||
141 | * Current iterator item. |
||
142 | * |
||
143 | * @return mixed|null |
||
144 | */ |
||
145 | public function current() |
||
151 | |||
152 | /** |
||
153 | * Current iterator position. |
||
154 | * |
||
155 | * @return mixed |
||
156 | */ |
||
157 | public function key() |
||
161 | |||
162 | /** |
||
163 | * Increments iterator position. |
||
164 | */ |
||
165 | public function next() |
||
169 | |||
170 | /** |
||
171 | * Determines if there is some value at current iterator position. |
||
172 | * |
||
173 | * @return bool |
||
174 | */ |
||
175 | public function valid() |
||
185 | |||
186 | /** |
||
187 | * JSON representation of collection. |
||
188 | * |
||
189 | * @return array |
||
190 | */ |
||
191 | public function jsonSerialize() |
||
195 | } |
||
196 |