Total Complexity | 10 |
Total Lines | 53 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
16 | class CompositeContainer implements ContainerInterface |
||
17 | { |
||
18 | /** |
||
19 | * We use a simple array since order matters |
||
20 | * @var ContainerInterface[] The list of containers |
||
21 | */ |
||
22 | private $containers = []; |
||
23 | |||
24 | /** @inheritdoc */ |
||
25 | public function get($id) |
||
26 | { |
||
27 | foreach ($this->containers as $container) { |
||
28 | try { |
||
29 | return $container->get($id); |
||
30 | } catch (NotFoundExceptionInterface $e) { |
||
31 | continue; |
||
32 | } |
||
33 | } |
||
34 | throw new NotFoundException(); |
||
35 | } |
||
36 | |||
37 | /** @inheritdoc */ |
||
38 | public function has($id) |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * Attaches a container to the composite container. |
||
50 | * @param ContainerInterface $container |
||
51 | */ |
||
52 | public function attach(ContainerInterface $container) |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * Removes a container from the list of containers. |
||
59 | * @param ContainerInterface $container |
||
60 | */ |
||
61 | public function detach(ContainerInterface $container) |
||
71 |