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

ClassDefinitionBuilder::build()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 10
nc 1
nop 1
dl 0
loc 13
ccs 11
cts 11
cp 1
crap 2
rs 9.9332
c 0
b 0
f 0
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\Builders;
7
8
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...
9
use PhUml\Code\ClassDefinition;
10
use PhUml\Code\Name;
11
use PhUml\Parser\Code\Builders\Names\InterfaceNamesBuilder;
12
use PhUml\Parser\Code\Builders\Names\TraitNamesBuilder;
13
14
/**
15
 * It builds a `ClassDefinition`
16
 *
17
 * @see MembersBuilder
18
 * @see InterfaceNamesBuilder
19
 * @see TraitNamesBuilder
20
 */
21
final class ClassDefinitionBuilder
22
{
23
    use InterfaceNamesBuilder;
24
    use TraitNamesBuilder;
0 ignored issues
show
Bug introduced by
The trait PhUml\Parser\Code\Builders\Names\TraitNamesBuilder requires the property $traits which is not provided by PhUml\Parser\Code\Builders\ClassDefinitionBuilder.
Loading history...
25
26 42
    public function __construct(
27
        private readonly MembersBuilder $membersBuilder,
28
        private readonly UseStatementsBuilder $useStatementsBuilder,
29
        private readonly AttributeAnalyzer $analyzer
30
    ) {
31
    }
32
33 31
    public function build(Class_ $class): ClassDefinition
34
    {
35 31
        $useStatements = $this->useStatementsBuilder->build($class);
36
37 31
        return new ClassDefinition(
38 31
            new Name((string) $class->namespacedName),
39 31
            $this->membersBuilder->methods($class->getMethods(), $useStatements),
40 31
            $this->membersBuilder->constants($class->stmts),
41 31
            $class->extends !== null ? new Name((string) $class->extends) : null,
42 31
            $this->membersBuilder->properties($class->stmts, $class->getMethod('__construct'), $useStatements),
43 31
            $this->buildInterfaces($class->implements),
44 31
            $this->buildTraits($class->stmts),
45 31
            $this->analyzer->isAttribute($class)
46
        );
47
    }
48
}
49