1 | <?php |
||
21 | abstract class AbstractCollection implements \IteratorAggregate, \Countable, \ArrayAccess |
||
22 | { |
||
23 | |||
24 | /** |
||
25 | * @var array |
||
26 | */ |
||
27 | protected $data = []; |
||
28 | |||
29 | /** |
||
30 | * @param array $data |
||
31 | */ |
||
32 | 94 | public function __construct(array $data = []) |
|
36 | |||
37 | /** |
||
38 | * @return void |
||
39 | */ |
||
40 | public function clean() |
||
44 | |||
45 | /** |
||
46 | * This method can be used to pass a closure to created a filtered copy. |
||
47 | * The closure get an collection item passed and needs to return true when the item should |
||
48 | * be kept or false when it can be skipped. |
||
49 | * |
||
50 | * @param callable $filter |
||
51 | * @return AbstractCollection |
||
52 | */ |
||
53 | 26 | public function getFilteredCopy(\Closure $filter) |
|
66 | |||
67 | /** |
||
68 | * @return \ArrayIterator|\Traversable |
||
69 | */ |
||
70 | 25 | public function getIterator() |
|
74 | |||
75 | /** |
||
76 | * @return array |
||
77 | */ |
||
78 | 21 | public function getArrayCopy() |
|
82 | |||
83 | /** |
||
84 | * @param int $position |
||
85 | * @return Object |
||
86 | */ |
||
87 | 24 | public function getByPosition($position) |
|
92 | |||
93 | /** |
||
94 | * (PHP 5 >= 5.1.0)<br/> |
||
95 | * Count elements of an object |
||
96 | * @link http://php.net/manual/en/countable.count.php |
||
97 | * @return int The custom count as an integer. |
||
98 | * </p> |
||
99 | * <p> |
||
100 | * The return value is cast to an integer. |
||
101 | */ |
||
102 | 39 | public function count() |
|
106 | |||
107 | /** |
||
108 | * @return int |
||
109 | */ |
||
110 | 4 | public function getCount() |
|
114 | |||
115 | /** |
||
116 | * Whether a offset exists |
||
117 | * |
||
118 | * @param mixed $offset |
||
119 | * @return bool true on success or false on failure |
||
120 | */ |
||
121 | 23 | public function offsetExists($offset) |
|
125 | |||
126 | /** |
||
127 | * Offset to retrieve |
||
128 | * |
||
129 | * @param mixed $offset |
||
130 | * @return mixed |
||
131 | */ |
||
132 | 2 | public function offsetGet($offset) |
|
140 | |||
141 | /** |
||
142 | * Offset to set |
||
143 | * |
||
144 | * @param mixed $offset |
||
145 | * @param mixed $value |
||
146 | * @return void |
||
147 | */ |
||
148 | public function offsetSet($offset, $value) |
||
152 | |||
153 | /** |
||
154 | * Offset to unset |
||
155 | * |
||
156 | * @param mixed $offset |
||
157 | * @return void |
||
158 | */ |
||
159 | public function offsetUnset($offset) |
||
165 | } |
||
166 |