Passed
Pull Request — master (#22)
by Luis
24:40 queued 21:48
created

ClassVisitor   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 16
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 4
1
<?php declare(strict_types=1);
2
/**
3
 * PHP version 8.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\Class_;
12
use PhpParser\NodeVisitorAbstract;
13
use PhUml\Code\Codebase;
14
use PhUml\Parser\Code\Builders\ClassDefinitionBuilder;
15
16
/**
17
 * It extracts a `ClassDefinition` and adds it to the `Codebase`
18
 */
19
final class ClassVisitor extends NodeVisitorAbstract
20
{
21 38
    public function __construct(private readonly ClassDefinitionBuilder $builder, private readonly Codebase $codebase)
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_STRING, expecting T_VARIABLE on line 21 at column 49
Loading history...
22
    {
23
    }
24
25 30
    public function leaveNode(Node $node)
26
    {
27 30
        if (! $node instanceof Class_) {
28 29
            return null;
29
        }
30 28
        if ($node->isAnonymous()) {
31 1
            return null;
32
        }
33 27
        $this->codebase->add($this->builder->build($node));
34 27
        return null;
35
    }
36
}
37