Conditions | 4 |
Paths | 4 |
Total Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
17 | public function parse($value, array $types) |
||
18 | { |
||
19 | preg_match_all('/(?<=^|,)[A-Z0-9-]+=("?).+?\1(?=,|$)/', $value, $matches); |
||
20 | |||
21 | $result = new \ArrayObject(); |
||
22 | foreach ($matches[0] as $attr) { |
||
23 | list($name, $value) = explode('=', $attr); |
||
24 | $result[$name] = $value; |
||
25 | |||
26 | if (!isset($types[$name])) { |
||
27 | continue; |
||
28 | } |
||
29 | |||
30 | $type = $types[$name]; |
||
31 | $parse = $this->valueParsers->get($type); |
||
32 | if (is_callable($parse)) { |
||
33 | $result[$name] = $parse($value); |
||
34 | } |
||
35 | } |
||
36 | |||
37 | return $result; |
||
38 | } |
||
39 | } |
||
40 |