1 | <?php |
||
11 | class Attributes extends AbstractBaseHtmlTagObject implements AttributesInterface |
||
12 | { |
||
13 | /** |
||
14 | * Stores the attribute data. |
||
15 | * |
||
16 | * @var \drupol\htmltag\Attribute\AttributeInterface[] |
||
17 | */ |
||
18 | private $storage = []; |
||
19 | |||
20 | /** |
||
21 | * The attribute factory. |
||
22 | * |
||
23 | * @var \drupol\htmltag\Attribute\AttributeFactoryInterface |
||
24 | */ |
||
25 | private $attributeFactory; |
||
26 | |||
27 | /** |
||
28 | * Attributes constructor. |
||
29 | * |
||
30 | * @param \drupol\htmltag\Attribute\AttributeFactoryInterface $attributeFactory |
||
31 | * The attribute factory. |
||
32 | * @param mixed[] $data |
||
33 | * The input attributes. |
||
34 | */ |
||
35 | 35 | public function __construct(AttributeFactoryInterface $attributeFactory, array $data = []) |
|
40 | |||
41 | /** |
||
42 | * {@inheritdoc} |
||
43 | */ |
||
44 | 35 | public function import(array $data) |
|
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | */ |
||
56 | 2 | public function set($key, ...$value) |
|
62 | |||
63 | /** |
||
64 | * {@inheritdoc} |
||
65 | */ |
||
66 | 3 | public function offsetGet($key) |
|
67 | { |
||
68 | $this->storage += [ |
||
69 | 3 | $key => $this->attributeFactory->getInstance($key) |
|
70 | ]; |
||
71 | |||
72 | 3 | return $this->storage[$key]; |
|
73 | } |
||
74 | |||
75 | /** |
||
76 | * {@inheritdoc} |
||
77 | */ |
||
78 | 1 | public function offsetSet($key, $value = null) |
|
82 | |||
83 | /** |
||
84 | * {@inheritdoc} |
||
85 | */ |
||
86 | 1 | public function offsetUnset($key) |
|
90 | |||
91 | /** |
||
92 | * {@inheritdoc} |
||
93 | */ |
||
94 | 2 | public function offsetExists($key) |
|
98 | |||
99 | /** |
||
100 | * {@inheritdoc} |
||
101 | */ |
||
102 | 16 | public function append($key, ...$values) |
|
112 | |||
113 | /** |
||
114 | * {@inheritdoc} |
||
115 | */ |
||
116 | 2 | public function remove($key, ...$values) |
|
124 | |||
125 | /** |
||
126 | * {@inheritdoc} |
||
127 | */ |
||
128 | 2 | public function delete(...$keys) |
|
136 | |||
137 | /** |
||
138 | * {@inheritdoc} |
||
139 | */ |
||
140 | 1 | public function without(...$keys) |
|
146 | |||
147 | /** |
||
148 | * {@inheritdoc} |
||
149 | */ |
||
150 | 1 | public function replace($key, $value, ...$replacements) |
|
160 | |||
161 | /** |
||
162 | * {@inheritdoc} |
||
163 | */ |
||
164 | 1 | public function merge(array ...$dataset) |
|
174 | |||
175 | /** |
||
176 | * {@inheritdoc} |
||
177 | */ |
||
178 | 3 | public function exists($key, ...$values) |
|
188 | |||
189 | /** |
||
190 | * {@inheritdoc} |
||
191 | */ |
||
192 | 3 | public function contains($key, ...$values) |
|
196 | |||
197 | /** |
||
198 | * {@inheritdoc} |
||
199 | */ |
||
200 | 1 | public function __toString() |
|
204 | |||
205 | /** |
||
206 | * {@inheritdoc} |
||
207 | */ |
||
208 | 22 | public function render() |
|
218 | |||
219 | /** |
||
220 | * {@inheritdoc} |
||
221 | */ |
||
222 | 1 | public function getStorage() |
|
226 | |||
227 | /** |
||
228 | * {@inheritdoc} |
||
229 | */ |
||
230 | 1 | public function getIterator() |
|
234 | |||
235 | /** |
||
236 | * {@inheritdoc} |
||
237 | */ |
||
238 | 1 | public function count() |
|
242 | |||
243 | /** |
||
244 | * {@inheritdoc} |
||
245 | */ |
||
246 | 27 | public function toArray() |
|
250 | |||
251 | /** |
||
252 | * {@inheritdoc} |
||
253 | */ |
||
254 | 3 | public function getValuesAsArray() |
|
264 | |||
265 | /** |
||
266 | * {@inheritdoc} |
||
267 | */ |
||
268 | 1 | public function serialize() |
|
274 | |||
275 | /** |
||
276 | * {@inheritdoc} |
||
277 | */ |
||
278 | 1 | public function unserialize($serialized) |
|
291 | |||
292 | /** |
||
293 | * {@inheritdoc} |
||
294 | */ |
||
295 | protected function escape($value) |
||
299 | } |
||
300 |