Passed
Push — 1.5 ( c7c5a4...fe8795 )
by Luis
06:06
created

InterfaceVisitor::leaveNode()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * PHP version 7.1
4
 *
5
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
6
 */
7
8
namespace PhUml\Parser\Code\Visitors;
9
10
use PhpParser\Node;
11
use PhpParser\Node\Stmt\Interface_;
12
use PhpParser\NodeVisitorAbstract;
13
use PhUml\Code\Codebase;
14
use PhUml\Parser\Code\Builders\InterfaceDefinitionBuilder;
15
16
/**
17
 * It extracts an `InterfaceDefinition` and adds it to the `Codebase`
18
 */
19
class InterfaceVisitor extends NodeVisitorAbstract
20
{
21
    /** @var Codebase */
22
    private $codebase;
23
24
    /** @var InterfaceDefinitionBuilder */
25
    private $builder;
26
27 129
    public function __construct(InterfaceDefinitionBuilder $builder, Codebase $codebase)
28
    {
29 129
        $this->builder = $builder;
30 129
        $this->codebase = $codebase;
31 129
    }
32
33 108
    public function leaveNode(Node $node)
34
    {
35 108
        if ($node instanceof Interface_) {
36 48
            $this->codebase->add($this->builder->build($node));
37
        }
38 108
    }
39
}
40