1 | <?php |
||
9 | class ArrayCollection implements \Countable, \IteratorAggregate, \ArrayAccess{ |
||
10 | /** |
||
11 | * @var array |
||
12 | */ |
||
13 | protected $list; |
||
14 | |||
15 | /** |
||
16 | * @param array $list |
||
17 | */ |
||
18 | public function __construct(array $list = []) { |
||
21 | |||
22 | /** |
||
23 | * @param mixed $element |
||
24 | * |
||
25 | * @return $this |
||
26 | */ |
||
27 | public function add($element) { |
||
31 | |||
32 | /** |
||
33 | * Set or replace the element at a specific index. |
||
34 | * |
||
35 | * @param mixed $index |
||
36 | * @param mixed $element |
||
37 | * |
||
38 | * @return $this |
||
39 | */ |
||
40 | public function set($index, $element) { |
||
44 | |||
45 | /** |
||
46 | * Remove and return the element at the zero based index. |
||
47 | * |
||
48 | * @param int $index |
||
49 | * |
||
50 | * @return null|mixed Null if the element didn't exist. |
||
51 | */ |
||
52 | public function remove($index) { |
||
60 | |||
61 | /** |
||
62 | * First sets the internal pointer to the first element and returns it. |
||
63 | * |
||
64 | * @link http://php.net/manual/en/function.reset.php |
||
65 | * |
||
66 | * @return mixed the value of the first array element, or false if the array is empty. |
||
67 | */ |
||
68 | public function first() { |
||
71 | |||
72 | /** |
||
73 | * Last sets the internal pointer to the last element and returns it. |
||
74 | * |
||
75 | * @link http://php.net/manual/en/function.end.php |
||
76 | * |
||
77 | * @return mixed the value of the last element or false for empty array. |
||
78 | */ |
||
79 | public function last() { |
||
82 | |||
83 | /** |
||
84 | * toArray returns a plain old array. |
||
85 | * |
||
86 | * @return array |
||
87 | */ |
||
88 | public function toArray() { |
||
91 | |||
92 | /** |
||
93 | * Apply a callable to every element. |
||
94 | * |
||
95 | * @param callable $callable |
||
96 | * |
||
97 | * @return $this |
||
98 | */ |
||
99 | public function apply(callable $callable) { |
||
103 | |||
104 | /** |
||
105 | * Count elements of an object. |
||
106 | * |
||
107 | * @link http://php.net/manual/en/countable.count.php |
||
108 | * |
||
109 | * @return int The custom count as an integer. |
||
110 | */ |
||
111 | public function count() { |
||
114 | |||
115 | /** |
||
116 | * getIterator returns an external iterator. |
||
117 | * |
||
118 | * @link http://php.net/manual/en/iteratoraggregate.getiterator.php |
||
119 | * |
||
120 | * @return Traversable An instance of an object implementing <b>Iterator</b> or <b>Traversable</b> |
||
121 | */ |
||
122 | public function getIterator() { |
||
125 | |||
126 | /** |
||
127 | * offsetExists allows using `isset`. |
||
128 | * |
||
129 | * @link http://php.net/manual/en/arrayaccess.offsetexists.php |
||
130 | * |
||
131 | * @param mixed $offset An offset to check for. |
||
132 | * |
||
133 | * @return bool true on success or false on failure. |
||
134 | */ |
||
135 | public function offsetExists($offset) { |
||
138 | |||
139 | /** |
||
140 | * offsetGet allows array access, e.g. `$list[2]`. |
||
141 | * |
||
142 | * @link http://php.net/manual/en/arrayaccess.offsetget.php |
||
143 | * |
||
144 | * @param mixed $offset The offset to retrieve. |
||
145 | * |
||
146 | * @return mixed Can return all value types. |
||
147 | */ |
||
148 | public function offsetGet($offset) { |
||
151 | |||
152 | /** |
||
153 | * offsetSet allows writing to arrays `$list[2] = 'foo'`. |
||
154 | * |
||
155 | * @link http://php.net/manual/en/arrayaccess.offsetset.php |
||
156 | * |
||
157 | * @param mixed $offset The offset to assign the value to. |
||
158 | * @param mixed $value The value to set. |
||
159 | * |
||
160 | * @return void |
||
161 | */ |
||
162 | public function offsetSet($offset, $value) { |
||
169 | |||
170 | /** |
||
171 | * offsetUnset allows using `unset`. |
||
172 | * |
||
173 | * @link http://php.net/manual/en/arrayaccess.offsetunset.php |
||
174 | * |
||
175 | * @param mixed $offset The offset to unset. |
||
176 | * |
||
177 | * @return void |
||
178 | */ |
||
179 | public function offsetUnset($offset) { |
||
182 | } |
||
183 |