Completed
Push — master ( c18e2a...b8ddaa )
by Woody
05:03 queued 02:48
created

InjectorContainer::has()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Northwoods\Container;
4
5
use Auryn\Injector;
6
use Auryn\InjectorException;
7
use Psr\Container\ContainerInterface;
8
9
class InjectorContainer implements ContainerInterface
10
{
11
    /**
12
     * @var Injector
13
     */
14
    private $injector;
15
16 5
    public function __construct(Injector $injector)
17
    {
18 5
        $this->injector = $injector;
19 5
    }
20
21
    // ContainerInterface
22 3
    public function get($id)
23
    {
24 3
        if (false === $this->has($id)) {
25 1
            throw NotFoundException::classDoesNotExist($id);
26
        }
27
28
        try {
29 2
            return $this->injector->make($id);
30 1
        } catch (InjectorException $e) {
31 1
            throw ContainerException::couldNotMake($id, $e);
32
        }
33
    }
34
35
    // ContainerInterface
36 4
    public function has($id)
37
    {
38 4
        return class_exists($id);
39
    }
40
}
41