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

InterfaceVisitor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A leaveNode() 0 4 2
A __construct() 0 4 1
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