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

TypeResolver::resolveFromDocBlock()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 3
nop 4
dl 0
loc 13
ccs 4
cts 4
cp 1
crap 3
rs 10
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;
7
8
use PhUml\Code\UseStatements;
9
use PhUml\Code\Variables\TypeDeclaration;
10
use PhUml\Parser\Code\Builders\TagName;
11
use PhUml\Parser\Code\Builders\TagType;
12
use PhUml\Parser\Code\Builders\TagTypeFactory;
0 ignored issues
show
Bug introduced by
The type PhUml\Parser\Code\Builders\TagTypeFactory 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...
13
14
final class TypeResolver
15 84
{
16
    public function __construct(private readonly TagTypeFactory $typeFactory)
17
    {
18
    }
19 29
20
    public function resolveFromDocBlock(
21
        ?string $docBlock,
22
        TagName $tagName,
23
        UseStatements $useStatements,
24 29
        callable $filter = null
25 14
    ): TypeDeclaration {
26
        if ($docBlock === null) {
27
            return TypeDeclaration::absent();
28 29
        }
29
30 29
        $returnType = $this->typeFactory->typeFromTag($docBlock, $tagName, $filter);
31
32
        return $returnType instanceof TagType ? $returnType->resolve($useStatements) : TypeDeclaration::absent();
33 32
    }
34
}
35