Total Complexity | 7 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | class Registry |
||
15 | { |
||
16 | /** @var MutableContainerInterface[] */ |
||
17 | private $registry = []; |
||
18 | |||
19 | /** |
||
20 | * @param MutableContainerInterface $container |
||
21 | * |
||
22 | * @throws ContainerAlreadyRegisteredException |
||
23 | */ |
||
24 | public function addContainer(MutableContainerInterface $container): void |
||
32 | } |
||
33 | |||
34 | public function register(RegistrableItemInterface $item): void |
||
35 | { |
||
36 | foreach ($item->getRegisteredContainerNames() as $containerName) { |
||
37 | if (false === array_key_exists($containerName, $this->registry)) { |
||
38 | continue; |
||
39 | } |
||
40 | |||
41 | $this->registry[$containerName]->add($item); |
||
42 | } |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @param string $containerName |
||
47 | * |
||
48 | * @return MutableContainerInterface |
||
49 | * |
||
50 | * @throws ContainerIsNotRegisteredException |
||
51 | */ |
||
52 | public function getContainer(string $containerName): MutableContainerInterface |
||
59 | } |
||
60 | } |
||
61 |