ParametersBuilder::build()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 13
nc 1
nop 3
dl 0
loc 22
ccs 9
cts 9
cp 1
crap 1
rs 9.8333
c 1
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\Members;
7
8
use PhpParser\Comment\Doc;
0 ignored issues
show
Bug introduced by
The type PhpParser\Comment\Doc 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\Param;
0 ignored issues
show
Bug introduced by
The type PhpParser\Node\Param 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 PhUml\Code\Parameters\Parameter;
11
use PhUml\Code\UseStatements;
12
use PhUml\Code\Variables\Variable;
13
use PhUml\Parser\Code\Builders\ParameterTagFilterFactory;
14
use PhUml\Parser\Code\Builders\TagName;
0 ignored issues
show
Bug introduced by
The type PhUml\Parser\Code\Builders\TagName 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...
15
16
final class ParametersBuilder
17
{
18 47
    public function __construct(
19
        private readonly TypeBuilder $typeBuilder,
0 ignored issues
show
Bug introduced by
The type PhUml\Parser\Code\Builders\Members\TypeBuilder 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...
20
        private readonly ParameterTagFilterFactory $filterFactory
21
    ) {
22
    }
23
24
    /**
25
     * @param Param[] $parameters
26
     * @return Parameter[]
27
     */
28 24
    public function build(array $parameters, ?Doc $methodDocBlock, UseStatements $useStatements): array
29
    {
30 24
        return array_map(function (Param $parameter) use ($methodDocBlock, $useStatements): Parameter {
31
            /** @var \PhpParser\Node\Expr\Variable $parsedParameter Since the parser throws error by default */
32 21
            $parsedParameter = $parameter->var;
33
34
            /** @var string $parameterName Since it's a parameter not a variable */
35 21
            $parameterName = $parsedParameter->name;
36
37 21
            $name = "\${$parameterName}";
38 21
            $type = $parameter->type;
39
40 21
            $typeDeclaration = $this->typeBuilder->fromType(
41
                $type,
42
                $methodDocBlock,
43
                TagName::PARAM,
44
                $useStatements,
45 21
                $this->filterFactory->filter($name)
46
            );
47
48 21
            return new Parameter(new Variable($name, $typeDeclaration), $parameter->variadic, $parameter->byRef);
49
        }, $parameters);
50
    }
51
}
52