MacroNode   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 3

Test Coverage

Coverage 90%

Importance

Changes 0
Metric Value
dl 0
loc 20
c 0
b 0
f 0
wmc 2
cbo 3
ccs 9
cts 10
cp 0.9
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A visit() 0 17 2
1
<?php
2
namespace Goetas\Twital\Node;
3
4
use Goetas\Twital\Compiler;
5
use Goetas\Twital\Exception;
6
use Goetas\Twital\Helper\DOMHelper;
7
use Goetas\Twital\Node;
8
9
/**
10
 *
11
 * @author Asmir Mustafic <[email protected]>
12
 *
13
 */
14
class MacroNode implements Node
15
{
16 3
    public function visit(\DOMElement $node, Compiler $context)
17
    {
18 3
        if (!$node->hasAttribute("name")) {
19
            throw new Exception("Name attribute is required");
20
        }
21
22 3
        $context->compileChilds($node);
23
24 3
        $set = iterator_to_array($node->childNodes);
25
26 3
        $start = $context->createControlNode("macro " . $node->getAttribute("name") . "(" . $node->getAttribute("args") . ")");
27 3
        array_unshift($set, $start);
28
29 3
        $set[] = $context->createControlNode("endmacro");
30
31 3
        DOMHelper::replaceWithSet($node, $set);
32 3
    }
33
}
34