| Conditions | 4 |
| Paths | 5 |
| Total Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 4.0032 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | 24 | public function visit(\DOMElement $node, Compiler $context) |
|
| 17 | { |
||
| 18 | 24 | if ($node->hasAttribute("from-exp")) { |
|
| 19 | 3 | $filename = $node->getAttribute("from-exp"); |
|
| 20 | 24 | } elseif ($node->hasAttribute("from")) { |
|
| 21 | 21 | $filename = '"' . $node->getAttribute("from") . '"'; |
|
| 22 | 21 | } else { |
|
| 23 | throw new Exception("The 'from' or 'from-exp' attribute is required"); |
||
| 24 | } |
||
| 25 | |||
| 26 | 24 | $context->compileChilds($node); |
|
| 27 | |||
| 28 | 24 | $ext = $context->createControlNode("extends {$filename}"); |
|
| 29 | |||
| 30 | 24 | $set = iterator_to_array($node->childNodes); |
|
| 31 | 24 | if (count($set)) { |
|
| 32 | 18 | $n = $node->ownerDocument->createTextNode("\n"); |
|
| 33 | 18 | array_unshift($set, $n); |
|
| 34 | 18 | } |
|
| 35 | 24 | array_unshift($set, $ext); |
|
| 36 | |||
| 37 | 24 | DOMHelper::replaceWithSet($node, $set); |
|
| 38 | 24 | } |
|
| 39 | } |
||
| 40 |