@@ -19,8 +19,9 @@ discard block |
||
19 | 19 | public static function box($settings=null) : ContainerInterface |
20 | 20 | { |
21 | 21 | if(is_null(self::$instance)){ |
22 | - if(is_array($settings)) |
|
23 | - return (self::$instance = new LeMarchand($settings)); |
|
22 | + if(is_array($settings)) { |
|
23 | + return (self::$instance = new LeMarchand($settings)); |
|
24 | + } |
|
24 | 25 | throw new LamentException('UNABLE_TO_OPEN_BOX'); |
25 | 26 | } |
26 | 27 | |
@@ -53,11 +54,9 @@ discard block |
||
53 | 54 | try{ |
54 | 55 | $this->get($configuration); |
55 | 56 | return true; |
56 | - } |
|
57 | - catch(NotFoundExceptionInterface $e){ |
|
57 | + } catch(NotFoundExceptionInterface $e){ |
|
58 | 58 | return false; |
59 | - } |
|
60 | - catch(ContainerExceptionInterface $e){ |
|
59 | + } catch(ContainerExceptionInterface $e){ |
|
61 | 60 | return false; |
62 | 61 | } |
63 | 62 | } |
@@ -80,16 +79,18 @@ discard block |
||
80 | 79 | // 3. is it a class |
81 | 80 | if (preg_match(self::RX_CLASS_NAME, $configuration, $m) === 1) { |
82 | 81 | $class_name = $this->cascadeNamespace($m[1], $m[2]); |
83 | - if($m[2] === 'Class') |
|
84 | - return $class_name; |
|
82 | + if($m[2] === 'Class') { |
|
83 | + return $class_name; |
|
84 | + } |
|
85 | 85 | |
86 | 86 | return $this->getInstance($class_name); |
87 | 87 | } |
88 | 88 | |
89 | 89 | if (preg_match(self::RX_INTERFACE_NAME, $configuration, $m) === 1) { |
90 | 90 | $wire = $this->get('settings.interface_implementations'); |
91 | - if(isset($wire[$configuration])) |
|
92 | - return $this->getInstance($wire[$configuration]); |
|
91 | + if(isset($wire[$configuration])) { |
|
92 | + return $this->getInstance($wire[$configuration]); |
|
93 | + } |
|
93 | 94 | } |
94 | 95 | |
95 | 96 | throw new ConfigurationException($configuration); |
@@ -113,22 +114,26 @@ discard block |
||
113 | 114 | private function cascadeNamespace($class_name, $mvc_type=null) |
114 | 115 | { |
115 | 116 | // is the controller name already instantiable ? |
116 | - if(is_null($mvc_type) && class_exists($class_name)) |
|
117 | - return $class_name; |
|
117 | + if(is_null($mvc_type) && class_exists($class_name)) { |
|
118 | + return $class_name; |
|
119 | + } |
|
118 | 120 | |
119 | - if($mvc_type === 'Class') |
|
120 | - $mvc_type = 'Model'; |
|
121 | + if($mvc_type === 'Class') { |
|
122 | + $mvc_type = 'Model'; |
|
123 | + } |
|
121 | 124 | |
122 | 125 | if($mvc_type !== 'Model' && $mvc_type !== 'Controller'){ |
123 | 126 | throw new LamentException('MVC_TYPE ('.$mvc_type.') UNKOWN'); |
124 | 127 | } |
125 | - if($mvc_type === 'Controller') |
|
126 | - $class_name = $class_name.'Controller'; |
|
128 | + if($mvc_type === 'Controller') { |
|
129 | + $class_name = $class_name.'Controller'; |
|
130 | + } |
|
127 | 131 | |
128 | 132 | // not fully namespaced, lets cascade |
129 | 133 | foreach ($this->getSettings('settings.namespaces') as $ns) { |
130 | - if(class_exists($full_name = $ns . $mvc_type . 's\\' . $class_name)) |
|
131 | - return $full_name; |
|
134 | + if(class_exists($full_name = $ns . $mvc_type . 's\\' . $class_name)) { |
|
135 | + return $full_name; |
|
136 | + } |
|
132 | 137 | } |
133 | 138 | |
134 | 139 | throw new ConfigurationException($class_name); |