Total Complexity | 8 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
13 | final class Container implements ContainerInterface |
||
14 | { |
||
15 | private $definitions; |
||
16 | private $instances; |
||
17 | |||
18 | 6 | public function __construct(Definitions $definitions) |
|
19 | { |
||
20 | 6 | $this->definitions = $definitions; |
|
21 | 6 | $this->instances = new Map('string', 'object'); |
|
22 | 6 | } |
|
23 | |||
24 | /** |
||
25 | * {@inheritdoc} |
||
26 | */ |
||
27 | 4 | public function get($id): object |
|
28 | { |
||
29 | 4 | if (!$this->has($id)) { |
|
30 | 3 | throw new NotFound($id); |
|
31 | } |
||
32 | |||
33 | 1 | return $this->build(new Name($id)); |
|
34 | } |
||
35 | |||
36 | /** |
||
37 | * {@inheritdoc} |
||
38 | */ |
||
39 | 5 | public function has($id): bool |
|
56 | } |
||
57 | |||
58 | 1 | private function build(Name $name): object |
|
70 |