Passed
Push — master ( 1ba30a...8ac47c )
by Luis
01:05 queued 12s
created

ClassVisitor   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 19
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A leaveNode() 0 12 3
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\Class_;
0 ignored issues
show
Bug introduced by
The type PhpParser\Node\Stmt\Class_ 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\ClassDefinitionBuilder;
13
14
/**
15
 * It builds a `ClassDefinition` and adds it to the `Codebase`
16
 */
17
final class ClassVisitor extends NodeVisitorAbstract
18
{
19 39
    public function __construct(private readonly ClassDefinitionBuilder $builder, private readonly Codebase $codebase)
20
    {
21
    }
22
23
    /** @return null|int|Node|Node[]  */
24 31
    public function leaveNode(Node $node): null|int|Node|array
25
    {
26 31
        if (! $node instanceof Class_) {
27 30
            return null;
28
        }
29 29
        if ($node->isAnonymous()) {
30 1
            return null;
31
        }
32
33 28
        $this->codebase->add($this->builder->build($node));
34
35 28
        return null;
36
    }
37
}
38