Total Complexity | 10 |
Total Lines | 48 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
12 | class CompositeContainer implements ContainerInterface |
||
13 | { |
||
14 | /** |
||
15 | * Containers to look into starting from the beginning of the array. |
||
16 | * @var ContainerInterface[] The list of containers |
||
17 | */ |
||
18 | private $containers = []; |
||
19 | |||
20 | public function get($id) |
||
21 | { |
||
22 | foreach ($this->containers as $container) { |
||
23 | try { |
||
24 | return $container->get($id); |
||
25 | } catch (NotFoundExceptionInterface $e) { |
||
26 | // ignore |
||
27 | } |
||
28 | } |
||
29 | throw new NotFoundException("No definition for $id"); |
||
30 | } |
||
31 | |||
32 | public function has($id) |
||
33 | { |
||
34 | foreach ($this->containers as $container) { |
||
35 | if ($container->has($id)) { |
||
36 | return true; |
||
37 | } |
||
38 | } |
||
39 | return false; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Attaches a container to the composite container. |
||
44 | * @param ContainerInterface $container |
||
45 | */ |
||
46 | public function attach(ContainerInterface $container): void |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * Removes a container from the list of containers. |
||
53 | * @param ContainerInterface $container |
||
54 | */ |
||
55 | public function detach(ContainerInterface $container): void |
||
60 | } |
||
61 | } |
||
64 |