Passed
Pull Request — master (#28)
by
unknown
49:49 queued 24:56
created

EnumDefinitionBuilder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 22
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A build() 0 11 1
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\Enum_;
0 ignored issues
show
Bug introduced by
The type PhpParser\Node\Stmt\Enum_ 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\EnumDefinition;
10
use PhUml\Code\Name;
11
use PhUml\Parser\Code\Builders\Names\InterfaceNamesBuilder;
12
use PhUml\Parser\Code\Builders\Names\TraitNamesBuilder;
13
14
final class EnumDefinitionBuilder
15
{
16
    use InterfaceNamesBuilder;
17
    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\EnumDefinitionBuilder.
Loading history...
18
19
    public function __construct(
20
        private readonly MembersBuilder $membersBuilder,
21
        private readonly UseStatementsBuilder $useStatementsBuilder,
22
    ) {
23
    }
24
25
    public function build(Enum_ $enum): EnumDefinition
26
    {
27
        $useStatements = $this->useStatementsBuilder->build($enum);
28
29
        return new EnumDefinition(
30
            new Name((string) $enum->namespacedName),
31
            $this->membersBuilder->enumCases($enum->stmts),
32
            $this->membersBuilder->methods($enum->getMethods(), $useStatements),
33
            $this->membersBuilder->constants($enum->stmts),
34
            $this->buildInterfaces($enum->implements),
35
            $this->buildTraits($enum->stmts),
36
        );
37
    }
38
}
39