Total Complexity | 8 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | final class NaiveContainer implements ContainerInterface |
||
11 | { |
||
12 | /** |
||
13 | * @var array<string, mixed> |
||
14 | */ |
||
15 | private $services = []; |
||
16 | |||
17 | public function get($id) |
||
18 | { |
||
19 | $id = (string)$id; |
||
20 | |||
21 | if (!$this->has($id)) { |
||
22 | throw new ServiceNotFoundException("Unable to instantiate '$id'"); |
||
23 | } |
||
24 | |||
25 | if (!isset($this->services[$id])) { |
||
26 | $this->services[$id] = new $id; |
||
27 | } |
||
28 | |||
29 | return $this->services[$id]; |
||
30 | } |
||
31 | |||
32 | public function has($id) |
||
53 | } |
||
54 | } |
||
55 |