Passed
Push — master ( bfac15...293213 )
by Chema
01:31 queued 16s
created

FactoryResolver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 24
ccs 6
cts 7
cp 0.8571
rs 10
c 3
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 10 2
A getResolvableType() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Framework\ClassResolver\Factory;
6
7
use Gacela\Framework\AbstractFactory;
8
use Gacela\Framework\ClassResolver\AbstractClassResolver;
9
10
final class FactoryResolver extends AbstractClassResolver
11
{
12
    public const TYPE = 'Factory';
13
14
    /**
15
     * @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...
16
     *
17
     * @throws FactoryNotFoundException
18
     */
19 34
    public function resolve($caller): AbstractFactory
20
    {
21
        /** @var ?AbstractFactory $resolved */
22 34
        $resolved = $this->doResolve($caller);
23
24 34
        if ($resolved === null) {
25
            throw new FactoryNotFoundException($caller);
26
        }
27
28 34
        return $resolved;
29
    }
30
31 34
    protected function getResolvableType(): string
32
    {
33 34
        return self::TYPE;
34
    }
35
}
36