Conditions | 6 |
Paths | 8 |
Total Lines | 38 |
Lines | 0 |
Ratio | 0 % |
Tests | 22 |
CRAP Score | 6.0622 |
Changes | 0 |
1 | <?php |
||
14 | 5 | public function visit(\DOMAttr $att, Compiler $context) |
|
15 | { |
||
16 | 5 | $node = $att->ownerElement; |
|
17 | |||
18 | 5 | $pi = $context->createControlNode("set __tmp_omit = " . html_entity_decode($att->value)); |
|
19 | 5 | $node->parentNode->insertBefore($pi, $node); |
|
20 | |||
21 | 5 | $pi = $context->createControlNode("if not __tmp_omit"); |
|
22 | 5 | $node->parentNode->insertBefore($pi, $node); |
|
23 | |||
24 | 5 | $pi = $context->createControlNode("endif"); |
|
25 | 5 | if ($node->firstChild) { |
|
26 | 5 | $node->insertBefore($pi, $node->firstChild); |
|
27 | 5 | } else { |
|
28 | $node->appendChild($pi); |
||
29 | } |
||
30 | |||
31 | 5 | $pi = $context->createControlNode("if not __tmp_omit"); |
|
32 | 5 | $node->appendChild($pi); |
|
33 | |||
34 | 5 | $pi = $context->createControlNode("endif"); |
|
35 | |||
36 | 5 | if ($node->parentNode->nextSibling) { |
|
37 | $node->parentNode->insertBefore($pi, $node->parentNode->nextSibling); |
||
38 | } else { |
||
39 | 5 | $node->parentNode->appendChild($pi); |
|
40 | } |
||
41 | |||
42 | 5 | $node->removeAttributeNode($att); |
|
43 | |||
44 | 5 | if ($att->value == "true" || $att->value == "1") { |
|
45 | 2 | foreach (iterator_to_array($node->attributes) as $att) { |
|
46 | 2 | $node->removeAttributeNode($att); |
|
47 | 2 | } |
|
48 | 2 | } |
|
49 | |||
50 | 5 | return Attribute::STOP_ATTRIBUTE; |
|
51 | } |
||
52 | } |
||
53 |