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

FactoryResolver::resolve()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 10
ccs 4
cts 5
cp 0.8
crap 2.032
rs 10
c 1
b 0
f 0
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