| Total Complexity | 10 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | class CompositeContainer implements ContainerInterface |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * Containers to look into starting from the beginning of the array. |
||
| 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 | // ignore |
||
| 32 | } |
||
| 33 | } |
||
| 34 | throw new NotFoundException("No definition for $id"); |
||
| 35 | } |
||
| 36 | |||
| 37 | public function has($id) |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Attaches a container to the composite container. |
||
| 49 | * @param ContainerInterface $container |
||
| 50 | */ |
||
| 51 | public function attach(ContainerInterface $container): void |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Removes a container from the list of containers. |
||
| 58 | * @param ContainerInterface $container |
||
| 59 | */ |
||
| 60 | public function detach(ContainerInterface $container): void |
||
| 69 |