Total Complexity | 2 |
Total Lines | 62 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class Container implements ContainerInterface |
||
11 | { |
||
12 | /** |
||
13 | * @var array |
||
14 | */ |
||
15 | private $container; |
||
16 | |||
17 | /** |
||
18 | * @param array $entries Array of string => mixed. |
||
19 | */ |
||
20 | 6 | public function __construct(array $entries = []) |
|
23 | 6 | } |
|
24 | |||
25 | /** |
||
26 | * {@inheritdoc} |
||
27 | */ |
||
28 | 5 | public function get($id) |
|
29 | { |
||
30 | 5 | if (!$this->resolved($id)) { |
|
31 | 1 | $this->container[$id] = \call_user_func($this->container[$id], $this); |
|
32 | } |
||
33 | |||
34 | 4 | return $this->container[$id]; |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * {@inheritdoc} |
||
39 | */ |
||
40 | 6 | public function has($id) |
|
41 | { |
||
42 | 6 | return \array_key_exists($id, $this->container); |
|
43 | } |
||
44 | |||
45 | /** |
||
46 | * @param string $id |
||
47 | * @param mixed $entry |
||
48 | */ |
||
49 | 3 | public function set(string $id, $entry): void |
|
52 | 3 | } |
|
53 | |||
54 | 1 | public function register(ServiceProvider $provider): void |
|
57 | 1 | } |
|
58 | |||
59 | /** |
||
60 | * Returns whether a given service has already been resolved |
||
61 | * into its final value, or is still a callable. |
||
62 | * |
||
63 | * @throws NotFoundExceptionInterface No entry was found for **this** identifier. |
||
64 | */ |
||
65 | 6 | public function resolved(string $id): bool |
|
72 | } |
||
73 | } |
||
74 |