Passed
Push — 81 ( 07c7b3 )
by Luis
25:00
created

TraitVisitor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 12
ccs 6
cts 6
cp 1
rs 10
c 1
b 0
f 0
wmc 3
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\Trait_;
12
use PhpParser\NodeVisitorAbstract;
13
use PhUml\Code\Codebase;
14
use PhUml\Parser\Code\Builders\TraitDefinitionBuilder;
15
16
/**
17
 * It extracts an `TraitDefinition` and adds it to the `Codebase`
18
 */
19
final class TraitVisitor extends NodeVisitorAbstract
20
{
21
    public function __construct(private readonly TraitDefinitionBuilder $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
    public function leaveNode(Node $node)
26
    {
27
        if ($node instanceof Trait_) {
28
            $this->codebase->add($this->builder->build($node));
29
        }
30
        return null;
31
    }
32
}
33