Conditions | 6 |
Paths | 6 |
Total Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
27 | public function parse(Lines $lines) |
||
28 | { |
||
29 | foreach ($lines as $line) { |
||
30 | if ($line->isType(Line::TYPE_URI)) { |
||
31 | $this->dataBuilder->addUri($line->getValue()); |
||
32 | |||
33 | continue; |
||
34 | } |
||
35 | |||
36 | $tag = $line->getTag(); |
||
37 | |||
38 | $definition = $this->tagDefinitions->findOneByTag($tag); |
||
39 | if (null === $definition) { |
||
40 | continue; |
||
41 | } |
||
42 | |||
43 | $valueType = $definition->getValueType(); |
||
44 | $value = $line->getValue(); |
||
45 | |||
46 | $parse = $this->valueParsers->get($valueType); |
||
47 | if (is_callable($parse)) { |
||
48 | $value = 'attribute-list' === $valueType ? $parse($value, $definition->getAttributeTypes()) : $parse($value); |
||
49 | } |
||
50 | $this->dataBuilder->addTag($definition, $value); |
||
51 | } |
||
52 | |||
53 | return $this->dataBuilder->getResult(); |
||
54 | } |
||
55 | } |
||
56 |