UseNode   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 2

Test Coverage

Coverage 91.67%

Importance

Changes 0
Metric Value
dl 0
loc 20
c 0
b 0
f 0
wmc 3
cbo 2
ccs 11
cts 12
cp 0.9167
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A visit() 0 17 3
1
<?php
2
namespace Goetas\Twital\Node;
3
4
use Goetas\Twital\Compiler;
5
use Goetas\Twital\Exception;
6
use Goetas\Twital\Node;
7
8
/**
9
 *
10
 * @author Asmir Mustafic <[email protected]>
11
 *
12
 */
13
class UseNode implements Node
14
{
15 9
    public function visit(\DOMElement $node, Compiler $context)
16
    {
17 9
        $code = "use ";
18
19 9
        if ($node->hasAttribute("from")) {
20 9
            $code .= '"' . $node->getAttribute("from") . '"';
21 9
        } else {
22
            throw new Exception("The 'from' attribute is required");
23
        }
24
25 9
        if ($node->hasAttribute("with")) {
26 3
            $code .= " with " . $node->getAttribute("with");
27 3
        }
28
29 9
        $pi = $context->createControlNode($code);
30 9
        $node->parentNode->replaceChild($pi, $node);
31 9
    }
32
}
33