Total Complexity | 5 |
Total Lines | 30 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class ArrayCache implements ContainerInterface |
||
10 | { |
||
11 | /** |
||
12 | * @var ContainerInterface |
||
13 | */ |
||
14 | private $container; |
||
15 | /** |
||
16 | * @var string[] |
||
17 | */ |
||
18 | private $values = []; |
||
19 | |||
20 | 6 | public function __construct(ContainerInterface $container) |
|
23 | 6 | } |
|
24 | |||
25 | /** |
||
26 | * @noinspection PhpMissingReturnTypeInspection |
||
27 | */ |
||
28 | 3 | public function get($id) |
|
29 | { |
||
30 | 3 | if (!array_key_exists($id, $this->values)) { |
|
31 | 3 | $this->values[$id] = $this->container->get($id); |
|
32 | } |
||
33 | 3 | return $this->values[$id]; |
|
34 | } |
||
35 | |||
36 | 3 | public function has($id): bool |
|
39 | } |
||
40 | } |
||
41 |