1 | <?php |
||
17 | class ArrayCollection implements \Countable, \IteratorAggregate, \ArrayAccess, \JsonSerializable |
||
18 | { |
||
19 | /** |
||
20 | * @var array |
||
21 | */ |
||
22 | protected $elements; |
||
23 | |||
24 | /** |
||
25 | * @param array $elements |
||
26 | */ |
||
27 | 44 | public function __construct(array $elements = array()) |
|
31 | |||
32 | /** |
||
33 | * @return array |
||
34 | */ |
||
35 | 3 | public function toArray() |
|
36 | { |
||
37 | 3 | return $this->elements; |
|
38 | } |
||
39 | |||
40 | /** |
||
41 | * {@inheritDoc} |
||
42 | */ |
||
43 | 1 | public function jsonSerialize() |
|
44 | { |
||
45 | 1 | return $this->elements; |
|
46 | } |
||
47 | |||
48 | /** |
||
49 | * {@inheritDoc} |
||
50 | */ |
||
51 | 2 | public function offsetExists($offset) |
|
52 | { |
||
53 | 2 | return isset($this->elements[$offset]) || array_key_exists($offset, $this->elements); |
|
54 | } |
||
55 | |||
56 | /** |
||
57 | * {@inheritDoc} |
||
58 | */ |
||
59 | 3 | public function offsetGet($offset) |
|
60 | { |
||
61 | 3 | return $this->get($offset); |
|
62 | } |
||
63 | |||
64 | /** |
||
65 | * {@inheritDoc} |
||
66 | */ |
||
67 | 2 | public function offsetSet($offset, $value) |
|
68 | { |
||
69 | 2 | $this->set($offset, $value); |
|
70 | 2 | } |
|
71 | |||
72 | /** |
||
73 | * {@inheritDoc} |
||
74 | */ |
||
75 | 2 | public function offsetUnset($offset) |
|
76 | { |
||
77 | 2 | return $this->remove($offset); |
|
78 | } |
||
79 | |||
80 | /** |
||
81 | * {@inheritDoc} |
||
82 | */ |
||
83 | 23 | public function count() |
|
87 | |||
88 | /** |
||
89 | * {@inheritDoc} |
||
90 | */ |
||
91 | 39 | public function getIterator() |
|
95 | |||
96 | /** |
||
97 | * @param string $key |
||
98 | * @return null|mixed |
||
99 | */ |
||
100 | 12 | public function get($key) |
|
108 | |||
109 | /** |
||
110 | * @param string $key |
||
111 | * @param mixed $value |
||
112 | */ |
||
113 | 3 | public function set($key, $value) |
|
117 | |||
118 | /** |
||
119 | * @param mixed $value |
||
120 | * @return bool |
||
121 | */ |
||
122 | 2 | public function add($value) |
|
128 | |||
129 | /** |
||
130 | * @param string $key |
||
131 | * @return null|mixed |
||
132 | */ |
||
133 | 4 | public function remove($key) |
|
134 | { |
||
144 | |||
145 | /** |
||
146 | * @param ArrayCollection $collection |
||
147 | * @return ArrayCollection |
||
148 | */ |
||
149 | 3 | public function merge(ArrayCollection $collection) |
|
163 | } |
||
164 |