Completed
Push — master ( 3661d0...5a2a79 )
by Miloš
01:12
created

AliasResolver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 57.14%

Importance

Changes 0
Metric Value
dl 0
loc 20
ccs 4
cts 7
cp 0.5714
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 14 3
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
        if (!is_string($definition->getValue())) {
27
            throw new InvalidArgumentException('Value of $definition->getValue() must be string');
28
        }
29
30 1
        return $this->getContainer()->get($definition->getValue());
31
    }
32
}
33