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

TypeResolver   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 19
ccs 6
cts 6
cp 1
rs 10
c 1
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A resolveFromDocBlock() 0 13 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;
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