1 | <?php |
||
8 | class Collection implements \ArrayAccess, \Countable, \IteratorAggregate |
||
9 | { |
||
10 | /** |
||
11 | * Array of data |
||
12 | * @var array |
||
13 | */ |
||
14 | protected $data; |
||
15 | |||
16 | public function __construct(array $data = []) |
||
20 | |||
21 | /** |
||
22 | * Returns data |
||
23 | * @return array |
||
24 | */ |
||
25 | public function toArray() |
||
29 | |||
30 | /** |
||
31 | * Sets a item with its key and value |
||
32 | * @param int|string $key |
||
33 | * @param mixed $value |
||
34 | * @return void |
||
35 | */ |
||
36 | public function set($key, $value) |
||
40 | |||
41 | /** |
||
42 | * Gets the value by the specified key |
||
43 | * @param int|string $key |
||
44 | * @param mixed $defaultValue |
||
45 | * @return mixed |
||
46 | */ |
||
47 | public function get($key, $defaultValue = null) |
||
51 | |||
52 | /** |
||
53 | * Merges a array to the collection |
||
54 | * @param array $data |
||
55 | */ |
||
56 | public function merge(array $data) |
||
60 | |||
61 | /** |
||
62 | * Checks whether the item exists |
||
63 | * @param int|string $key |
||
64 | * @return boolean |
||
65 | */ |
||
66 | public function exists($key) |
||
70 | |||
71 | /** |
||
72 | * Remove a item by its key |
||
73 | * @param mixed $key |
||
74 | */ |
||
75 | public function delete($key) |
||
79 | |||
80 | /** |
||
81 | * Clears the collection |
||
82 | */ |
||
83 | public function clear() |
||
87 | |||
88 | /** |
||
89 | * Clears the collection |
||
90 | * @deprecated |
||
91 | */ |
||
92 | public function flush() |
||
96 | |||
97 | /** |
||
98 | * {@inheritdoc} |
||
99 | */ |
||
100 | public function offsetGet($offset) |
||
104 | |||
105 | /** |
||
106 | * {@inheritdoc} |
||
107 | */ |
||
108 | public function offsetSet($offset, $value) |
||
112 | |||
113 | /** |
||
114 | * {@inheritdoc} |
||
115 | */ |
||
116 | public function offsetUnset($offset) |
||
120 | |||
121 | /** |
||
122 | * {@inheritdoc} |
||
123 | */ |
||
124 | public function offsetExists($offset) |
||
128 | |||
129 | |||
130 | /** |
||
131 | * {@inheritdoc} |
||
132 | */ |
||
133 | public function count() |
||
137 | |||
138 | /** |
||
139 | * {@inheritdoc} |
||
140 | */ |
||
141 | public function getIterator() |
||
145 | } |
||
146 |