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

AliasResolver   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 60%

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 3
cts 5
cp 0.6
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 10 2
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