1 | <?php |
||
16 | class Dictionary extends AbstractCollectionArray implements MapInterface, \ArrayAccess |
||
17 | { |
||
18 | use StrictKeyedIterableTrait, |
||
19 | GuardTrait; |
||
20 | |||
21 | public function at($k) |
||
25 | |||
26 | 21 | public function set($key, $value) |
|
32 | |||
33 | /** |
||
34 | * {@inheritdoc} |
||
35 | */ |
||
36 | 8 | public function get($index) |
|
44 | |||
45 | /** |
||
46 | * {@inheritdoc} |
||
47 | */ |
||
48 | 11 | public function add($key, $value) |
|
57 | |||
58 | /** |
||
59 | * {@inheritdoc} |
||
60 | */ |
||
61 | 4 | public function addAll($items) |
|
62 | { |
||
63 | 4 | if (!is_array($items) && !$items instanceof Traversable) { |
|
64 | 1 | throw new \InvalidArgumentException('The items must be an array or Traversable'); |
|
65 | } |
||
66 | |||
67 | 3 | foreach ($items as $key => $value) { |
|
68 | 3 | if (is_array($value)) { |
|
69 | 1 | $value = Dictionary::fromArray($value); |
|
70 | 1 | } |
|
71 | 3 | $this->add($key, $value); |
|
72 | 3 | } |
|
73 | 3 | } |
|
74 | |||
75 | /** |
||
76 | * {@inheritdoc} |
||
77 | */ |
||
78 | 16 | public function containsKey($key) |
|
82 | |||
83 | /** |
||
84 | * {@inheritdoc} |
||
85 | */ |
||
86 | public function contains($element) |
||
90 | |||
91 | /** |
||
92 | * {@inheritdoc} |
||
93 | */ |
||
94 | 1 | public function remove($element) |
|
101 | |||
102 | /** |
||
103 | * {@inheritdoc} |
||
104 | */ |
||
105 | 2 | public function removeKey($key) |
|
112 | |||
113 | /** |
||
114 | * {@inheritdoc} |
||
115 | */ |
||
116 | 1 | public function offsetExists($offset) |
|
120 | |||
121 | /** |
||
122 | * {@inheritdoc} |
||
123 | */ |
||
124 | 5 | public function offsetGet($offset) |
|
128 | |||
129 | /** |
||
130 | * {@inheritdoc} |
||
131 | */ |
||
132 | 10 | public function offsetSet($offset, $value) |
|
140 | |||
141 | /** |
||
142 | * {@inheritdoc} |
||
143 | */ |
||
144 | 1 | public function offsetUnset($offset) |
|
148 | |||
149 | /** |
||
150 | * Gets the collection's iterator |
||
151 | * @return MapIterator |
||
152 | */ |
||
153 | 9 | public function getIterator() |
|
157 | |||
158 | } |
||
159 |