Conditions | 2 |
Paths | 2 |
Total Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 2.004 |
Changes | 0 |
1 | <?php |
||
15 | 2 | public function visit(\DOMAttr $att, Compiler $context) |
|
16 | { |
||
17 | 2 | $node = $att->ownerElement; |
|
18 | |||
19 | 2 | if (!$prev = IfAttribute::findPrevElement($node)) { |
|
20 | throw new Exception("The attribute 'elseif' must be the very next sibling of an 'if' of 'elseif' attribute"); |
||
21 | } |
||
22 | |||
23 | 2 | $pi = $context->createControlNode("else"); |
|
24 | 2 | $node->parentNode->insertBefore($pi, $node); |
|
25 | |||
26 | 2 | $pi = $context->createControlNode("endif"); |
|
27 | 2 | $node->parentNode->insertBefore($pi, $node->nextSibling); |
|
28 | |||
29 | 2 | $node->removeAttributeNode($att); |
|
30 | 2 | } |
|
31 | } |
||
32 |