@@ -14,10 +14,10 @@ discard block |
||
| 14 | 14 | public const RX_SETTINGS = '/^settings\./'; |
| 15 | 15 | public const RX_MODEL_CLASS = '/([a-zA-Z]+)(Class|Model)$/'; |
| 16 | 16 | |
| 17 | - public static function box($settings=null) : ContainerInterface |
|
| 17 | + public static function box($settings = null) : ContainerInterface |
|
| 18 | 18 | { |
| 19 | - if(is_null(self::$instance)){ |
|
| 20 | - if(is_array($settings)) |
|
| 19 | + if (is_null(self::$instance)) { |
|
| 20 | + if (is_array($settings)) |
|
| 21 | 21 | return (self::$instance = new LeMarchand($settings)); |
| 22 | 22 | throw new LamentException('MVC_TYPE ('.$mvc_type.') UNKOWN'); |
| 23 | 23 | } |
@@ -48,14 +48,14 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | public function has($configuration) |
| 50 | 50 | { |
| 51 | - try{ |
|
| 51 | + try { |
|
| 52 | 52 | $this->get($configuration); |
| 53 | 53 | return true; |
| 54 | 54 | } |
| 55 | - catch(NotFoundExceptionInterface $e){ |
|
| 55 | + catch (NotFoundExceptionInterface $e) { |
|
| 56 | 56 | return false; |
| 57 | 57 | } |
| 58 | - catch(ContainerExceptionInterface $e){ |
|
| 58 | + catch (ContainerExceptionInterface $e) { |
|
| 59 | 59 | return false; |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | // 4. is it a class ? |
| 85 | 85 | if (preg_match(self::RX_MODEL_CLASS, $configuration, $m) === 1) { |
| 86 | 86 | $class_name = $this->cascadeNamespace($m[1], 'Models'); |
| 87 | - if($m[2] === 'Model') |
|
| 87 | + if ($m[2] === 'Model') |
|
| 88 | 88 | return $this->getInstance($class_name); |
| 89 | 89 | else |
| 90 | 90 | return $class_name; |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | if (preg_match(self::RX_INTERFACE_NAME, $configuration, $m) === 1) { |
| 94 | 94 | $wire = $this->get('settings.interface_implementations'); |
| 95 | - if(isset($wire[$configuration])) |
|
| 95 | + if (isset($wire[$configuration])) |
|
| 96 | 96 | return $this->getInstance($wire[$configuration]); |
| 97 | 97 | } |
| 98 | 98 | |
@@ -114,19 +114,19 @@ discard block |
||
| 114 | 114 | // throw new ConfigurationException($controller_name); |
| 115 | 115 | // } |
| 116 | 116 | |
| 117 | - private function cascadeNamespace($class_name, $mvc_type=null) |
|
| 117 | + private function cascadeNamespace($class_name, $mvc_type = null) |
|
| 118 | 118 | { |
| 119 | 119 | // is the controller name already instantiable ? |
| 120 | - if(is_null($mvc_type) && class_exists($class_name)) |
|
| 120 | + if (is_null($mvc_type) && class_exists($class_name)) |
|
| 121 | 121 | return $class_name; |
| 122 | 122 | |
| 123 | - if($mvc_type !== 'Models' && $mvc_type !== 'Controllers'){ |
|
| 123 | + if ($mvc_type !== 'Models' && $mvc_type !== 'Controllers') { |
|
| 124 | 124 | throw new LamentException('MVC_TYPE ('.$mvc_type.') UNKOWN'); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | // not fully namespaced, lets cascade |
| 128 | 128 | foreach ($this->getSettings('settings.namespaces') as $ns) { |
| 129 | - if(class_exists($full_name = $ns . $mvc_type . '\\' . $class_name)) |
|
| 129 | + if (class_exists($full_name = $ns.$mvc_type.'\\'.$class_name)) |
|
| 130 | 130 | return $full_name; |
| 131 | 131 | } |
| 132 | 132 | throw new ConfigurationException($class_name); |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $construction_args = []; |
| 141 | 141 | if (!is_null($rc->getConstructor())) { |
| 142 | 142 | foreach ($rc->getConstructor()->getParameters() as $param) { |
| 143 | - $construction_args [] = $this->get($param->getType() . ''); |
|
| 143 | + $construction_args [] = $this->get($param->getType().''); |
|
| 144 | 144 | } |
| 145 | 145 | $instance = $rc->newInstanceArgs($construction_args); |
| 146 | 146 | } else { |