| Conditions | 5 |
| Paths | 3 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 5.0113 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | 4 | public function visit(\DOMAttr $att, Compiler $context) |
|
| 17 | { |
||
| 18 | 4 | $node = $att->ownerElement; |
|
| 19 | |||
| 20 | 4 | if (!$prev = IfAttribute::findPrevElement($node)) { |
|
| 21 | throw new Exception("The attribute 'elseif' must be the very next sibling of an 'if' of 'elseif' attribute"); |
||
| 22 | } |
||
| 23 | |||
| 24 | 4 | $pi = $context->createControlNode("elseif " . html_entity_decode($att->value)); |
|
| 25 | 4 | $node->parentNode->insertBefore($pi, $node); |
|
| 26 | |||
| 27 | 4 | if (!($nextElement = IfAttribute::findNextElement($node)) || (!$nextElement->hasAttributeNS(Twital::NS, 'elseif') && !$nextElement->hasAttributeNS(Twital::NS, 'else'))) { |
|
| 28 | 3 | $pi = $context->createControlNode("endif"); |
|
| 29 | 3 | $node->parentNode->insertBefore($pi, $node->nextSibling); // insert after |
|
| 30 | 3 | } else { |
|
| 31 | 2 | IfAttribute::removeWhitespace($node); |
|
| 32 | } |
||
| 33 | |||
| 34 | 4 | $node->removeAttributeNode($att); |
|
| 35 | 4 | } |
|
| 36 | } |
||
| 37 |