Passed
Push — parser-refactoring ( e758c6...b54cbd )
by Luis
11:11
created

ClassVisitor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
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;
9
10
use PhpParser\Node;
11
use PhpParser\Node\Stmt\Class_;
12
use PhpParser\NodeVisitorAbstract;
13
use PhUml\Parser\Builders\ClassBuilder;
14
15
class ClassVisitor extends NodeVisitorAbstract
16
{
17
    /** @var Definitions */
18
    private $definitions;
19
20
    /** @var ClassBuilder */
21
    private $builder;
22
23
    public function __construct(Definitions $definitions, ClassBuilder $builder)
24
    {
25
        $this->definitions = $definitions;
26
        $this->builder = $builder;
27
    }
28
29
    public function leaveNode(Node $node)
30
    {
31
        if ($node instanceof Class_) {
32
            $this->definitions->add($this->builder->build($node));
33
        }
34
    }
35
}
36