1 | <?php |
||
9 | abstract class BaseCollection implements ArrayAccess, Iterator, Countable |
||
10 | { |
||
11 | /** |
||
12 | * The list of internal items stored by this collection. |
||
13 | * |
||
14 | * @var array |
||
15 | */ |
||
16 | protected $items; |
||
17 | |||
18 | /** |
||
19 | * The current iterator position. |
||
20 | * |
||
21 | * @var int |
||
22 | */ |
||
23 | protected $position; |
||
24 | |||
25 | /** |
||
26 | * Instantiate a new collection with the optional provided array. |
||
27 | * |
||
28 | * @param array $items |
||
29 | */ |
||
30 | public function __construct(array $items = []) |
||
35 | |||
36 | /* |
||
37 | | -------------------------------------------------------------------------- |
||
38 | | Implementation of `ArrayAccess` interface. |
||
39 | | -------------------------------------------------------------------------- |
||
40 | */ |
||
41 | |||
42 | public function offsetExists($offset) |
||
46 | |||
47 | public function offsetGet($offset) |
||
53 | |||
54 | public function offsetSet($offset, $value) |
||
62 | |||
63 | public function offsetUnset($offset) |
||
67 | |||
68 | /* |
||
69 | | -------------------------------------------------------------------------- |
||
70 | | Implementation of `Iterator` interface. |
||
71 | | -------------------------------------------------------------------------- |
||
72 | */ |
||
73 | |||
74 | public function current() |
||
78 | |||
79 | public function key() |
||
83 | |||
84 | public function next() |
||
88 | |||
89 | public function rewind() |
||
93 | |||
94 | public function valid() |
||
98 | |||
99 | /* |
||
100 | | -------------------------------------------------------------------------- |
||
101 | | Implementation of `Countable` interface. |
||
102 | | -------------------------------------------------------------------------- |
||
103 | */ |
||
104 | |||
105 | public function count() |
||
109 | } |
||
110 |