@@ -21,12 +21,12 @@ |
||
| 21 | 21 | { |
| 22 | 22 | $obj = $container->get(__CLASS__); |
| 23 | 23 | |
| 24 | - if ($obj && $obj instanceof static) |
|
| 25 | - return $obj; |
|
| 24 | + if ($obj && $obj instanceof static) { |
|
| 25 | + return $obj; |
|
| 26 | + } |
|
| 26 | 27 | |
| 27 | 28 | return null; |
| 28 | - } |
|
| 29 | - catch (NotFoundException $e) |
|
| 29 | + } catch (NotFoundException $e) |
|
| 30 | 30 | { |
| 31 | 31 | return null; |
| 32 | 32 | } |
@@ -24,8 +24,9 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | public function add(object $object) |
| 26 | 26 | { |
| 27 | - if (!($object instanceof ComponentInterface)) |
|
| 28 | - throw new ContainerException('Object must implement Yoshi2889\Container\ComponentInterface'); |
|
| 27 | + if (!($object instanceof ComponentInterface)) { |
|
| 28 | + throw new ContainerException('Object must implement Yoshi2889\Container\ComponentInterface'); |
|
| 29 | + } |
|
| 29 | 30 | |
| 30 | 31 | $this->storedComponents[get_class($object)] = $object; |
| 31 | 32 | } |
@@ -35,11 +36,13 @@ discard block |
||
| 35 | 36 | */ |
| 36 | 37 | public function get($id) |
| 37 | 38 | { |
| 38 | - if (!is_string($id)) |
|
| 39 | - throw new ContainerException('Given ID must be a string'); |
|
| 39 | + if (!is_string($id)) { |
|
| 40 | + throw new ContainerException('Given ID must be a string'); |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | - if (!$this->has($id)) |
|
| 42 | - throw new NotFoundException(); |
|
| 43 | + if (!$this->has($id)) { |
|
| 44 | + throw new NotFoundException(); |
|
| 45 | + } |
|
| 43 | 46 | |
| 44 | 47 | return $this->storedComponents[$id]; |
| 45 | 48 | } |
@@ -49,8 +52,9 @@ discard block |
||
| 49 | 52 | */ |
| 50 | 53 | public function has($id) |
| 51 | 54 | { |
| 52 | - if (!is_string($id)) |
|
| 53 | - throw new ContainerException('Given ID must be a string'); |
|
| 55 | + if (!is_string($id)) { |
|
| 56 | + throw new ContainerException('Given ID must be a string'); |
|
| 57 | + } |
|
| 54 | 58 | |
| 55 | 59 | return array_key_exists($id, $this->storedComponents); |
| 56 | 60 | } |