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