| 1 | <?php |
||
| 13 | class ComponentContainer implements ContainerInterface |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @var object[] |
||
| 17 | */ |
||
| 18 | protected $storedComponents = []; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @param ComponentInterface $object $object |
||
| 22 | * |
||
| 23 | * @throws ContainerException |
||
| 24 | */ |
||
| 25 | 2 | public function add(ComponentInterface $object) |
|
| 29 | |||
| 30 | /** |
||
| 31 | * @inheritdoc |
||
| 32 | */ |
||
| 33 | 4 | public function get($id) |
|
| 34 | { |
||
| 35 | 4 | if (!is_string($id)) |
|
| 36 | 1 | throw new ContainerException('Given ID must be a string'); |
|
| 37 | |||
| 38 | 3 | if (!$this->has($id)) |
|
| 39 | 2 | throw new NotFoundException(); |
|
| 40 | |||
| 41 | 1 | return $this->storedComponents[$id]; |
|
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @inheritdoc |
||
| 46 | */ |
||
| 47 | 4 | public function has($id) |
|
| 54 | } |