Passed
Push — add-with-all-to-modules-list ( 82b81d...0edb38 )
by Chema
03:40
created

DocBlockServiceResolver   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 26
rs 10
c 0
b 0
f 0
ccs 9
cts 9
cp 1
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getResolvableType() 0 3 1
A resolve() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Framework\ClassResolver\DocBlockService;
6
7
use Gacela\Framework\ClassResolver\AbstractClassResolver;
8
9
final class DocBlockServiceResolver extends AbstractClassResolver
10
{
11 29
    public function __construct(
12
        private string $resolvableType,
13
    ) {
14 29
    }
15
16
    /**
17
     * @param object|class-string $caller
0 ignored issues
show
Documentation Bug introduced by
The doc comment object|class-string at position 2 could not be parsed: Unknown type name 'class-string' at position 2 in object|class-string.
Loading history...
18
     *
19
     * @throws DocBlockServiceNotFoundException
20
     */
21 29
    public function resolve(object|string $caller): object
22
    {
23 29
        $resolved = $this->doResolve($caller);
24
25 29
        if ($resolved === null) {
26 1
            throw new DocBlockServiceNotFoundException($caller, $this->resolvableType);
27
        }
28
29 28
        return $resolved;
30
    }
31
32 29
    protected function getResolvableType(): string
33
    {
34 29
        return $this->resolvableType;
35
    }
36
}
37