Passed
Pull Request — master (#30)
by
unknown
46:28 queued 21:27
created

TraitVisitor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 13
ccs 5
cts 5
cp 1
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A leaveNode() 0 6 2
1
<?php declare(strict_types=1);
2
/**
3
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
4
 */
5
6
namespace PhUml\Parser\Code\Visitors;
7
8
use PhpParser\Node;
0 ignored issues
show
Bug introduced by
The type PhpParser\Node was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use PhpParser\Node\Stmt\Trait_;
0 ignored issues
show
Bug introduced by
The type PhpParser\Node\Stmt\Trait_ was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use PhpParser\NodeVisitorAbstract;
0 ignored issues
show
Bug introduced by
The type PhpParser\NodeVisitorAbstract was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use PhUml\Code\Codebase;
12
use PhUml\Parser\Code\Builders\TraitDefinitionBuilder;
13
14
/**
15
 * It builds a `TraitDefinition` and adds it to the `Codebase`
16
 */
17
final class TraitVisitor extends NodeVisitorAbstract
18
{
19 37
    public function __construct(private readonly TraitDefinitionBuilder $builder, private readonly Codebase $codebase)
20
    {
21
    }
22
23 29
    /** @return null|int|Node|Node[]  */
24
    public function leaveNode(Node $node): null|int|Node|array
25 29
    {
26 8
        if ($node instanceof Trait_) {
27
            $this->codebase->add($this->builder->build($node));
28 29
        }
29
        return null;
30
    }
31
}
32