| 1 | <?php |
||
| 8 | class Container implements ContainerInterface |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var array |
||
| 12 | */ |
||
| 13 | private $container = []; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Add an object to the container |
||
| 17 | * |
||
| 18 | * @param string $key The name of a service to set in the container |
||
| 19 | * @param mixed $value A closure of object representing a serive |
||
| 20 | * |
||
| 21 | * @return $this |
||
| 22 | */ |
||
| 23 | 39 | public function set($key, $value = null) |
|
| 24 | { |
||
| 25 | 39 | $this->container[$key] = $value; |
|
| 26 | 39 | } |
|
| 27 | |||
| 28 | 1 | public function remove($key) |
|
| 29 | { |
||
| 30 | 1 | if ($this->has($key)) { |
|
| 31 | 1 | unset($this->container[$key]); |
|
| 32 | } |
||
| 33 | 1 | } |
|
| 34 | |||
| 35 | /** |
||
| 36 | * {@inheritdoc} |
||
| 37 | */ |
||
| 38 | 40 | public function get($key) |
|
| 46 | |||
| 47 | /** |
||
| 48 | * {@inheritdoc} |
||
| 49 | */ |
||
| 50 | 40 | public function has($key) |
|
| 54 | } |
||
| 55 |