AurynResolver::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Equip\Resolver;
4
5
use Auryn\Injector;
6
use Relay\ResolverInterface;
7
8
class AurynResolver implements ResolverInterface
9
{
10
    /**
11
     * @var Injector
12
     */
13
    private $injector;
14
15 27
    public function __construct(Injector $injector)
16
    {
17 27
        $this->injector = $injector;
18 27
    }
19
20
    /**
21
     * Resolve a class spec into an object, if it is not already instantiated.
22
     *
23
     * @param string|object $specOrObject
24
     *
25
     * @return object
26
     */
27 4
    public function __invoke($specOrObject)
28
    {
29 4
        if (is_object($specOrObject)) {
30 1
            return $specOrObject;
31
        }
32
33 4
        return $this->injector->make($specOrObject);
34
    }
35
}
36