Completed
Push — master ( 8eb05e...3661d0 )
by Miloš
01:25
created

AliasResolver::resolve()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.2559

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 10
ccs 3
cts 5
cp 0.6
crap 2.2559
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
namespace Laganica\Di\Resolver;
4
5
use InvalidArgumentException;
6
use Laganica\Di\Definition\AliasDefinition;
7
8
/**
9
 * Class AliasResolver
10
 *
11
 * @package Laganica\Di\Resolver
12
 */
13
class AliasResolver extends ReflectionResolver
14
{
15
    /**
16
     * @inheritDoc
17
     */
18 1
    public function resolve($definition)
19
    {
20 1
        if (!$definition instanceof AliasDefinition) {
21
            $definitionClass = AliasDefinition::class;
22
23
            throw new InvalidArgumentException("Argument $definition must be $definitionClass");
24
        }
25
26 1
        return $this->getContainer()->get($definition->getValue());
0 ignored issues
show
Bug introduced by
It seems like $definition->getValue() targeting Laganica\Di\Definition\Definition::getValue() can also be of type object<Closure>; however, Psr\Container\ContainerInterface::get() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
27
    }
28
}
29