| @@ -16,10 +16,10 @@ discard block | ||
| 16 | 16 | public const RX_CLASS_NAME = '/([a-zA-Z]+)(Class|Model|Controller)$/'; | 
| 17 | 17 | |
| 18 | 18 | |
| 19 | - public static function box($settings=null) : ContainerInterface | |
| 19 | + public static function box($settings = null) : ContainerInterface | |
| 20 | 20 |      { | 
| 21 | -      if(is_null(self::$instance)){ | |
| 22 | - if(is_array($settings)) | |
| 21 | +      if (is_null(self::$instance)) { | |
| 22 | + if (is_array($settings)) | |
| 23 | 23 | return (self::$instance = new LeMarchand($settings)); | 
| 24 | 24 |          throw new LamentException('UNABLE_TO_OPEN_BOX'); | 
| 25 | 25 | } | 
| @@ -50,14 +50,14 @@ discard block | ||
| 50 | 50 | |
| 51 | 51 | public function has($configuration) | 
| 52 | 52 |      { | 
| 53 | -      try{ | |
| 53 | +      try { | |
| 54 | 54 | $this->get($configuration); | 
| 55 | 55 | return true; | 
| 56 | 56 | } | 
| 57 | -      catch(NotFoundExceptionInterface $e){ | |
| 57 | +      catch (NotFoundExceptionInterface $e) { | |
| 58 | 58 | return false; | 
| 59 | 59 | } | 
| 60 | -      catch(ContainerExceptionInterface $e){ | |
| 60 | +      catch (ContainerExceptionInterface $e) { | |
| 61 | 61 | return false; | 
| 62 | 62 | } | 
| 63 | 63 | } | 
| @@ -80,7 +80,7 @@ discard block | ||
| 80 | 80 | // 3. is it a class | 
| 81 | 81 |          if (preg_match(self::RX_CLASS_NAME, $configuration, $m) === 1) { | 
| 82 | 82 | $class_name = $this->cascadeNamespace($m[1], $m[2]); | 
| 83 | - if($m[2] === 'Class') | |
| 83 | + if ($m[2] === 'Class') | |
| 84 | 84 | return $class_name; | 
| 85 | 85 | |
| 86 | 86 | return $this->getInstance($class_name); | 
| @@ -88,7 +88,7 @@ discard block | ||
| 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])) | |
| 91 | + if (isset($wire[$configuration])) | |
| 92 | 92 | return $this->getInstance($wire[$configuration]); | 
| 93 | 93 | } | 
| 94 | 94 | |
| @@ -110,21 +110,21 @@ discard block | ||
| 110 | 110 | // throw new ConfigurationException($controller_name); | 
| 111 | 111 | // } | 
| 112 | 112 | |
| 113 | - private function cascadeNamespace($class_name, $mvc_type=null) | |
| 113 | + private function cascadeNamespace($class_name, $mvc_type = null) | |
| 114 | 114 |      { | 
| 115 | 115 | // does the name already exists ? | 
| 116 | - if(class_exists($class_name)) | |
| 116 | + if (class_exists($class_name)) | |
| 117 | 117 | return $class_name; | 
| 118 | 118 | |
| 119 | - if($mvc_type === 'Class') | |
| 119 | + if ($mvc_type === 'Class') | |
| 120 | 120 | $mvc_type = 'Model'; | 
| 121 | 121 | |
| 122 | - if($mvc_type === 'Controller') | |
| 122 | + if ($mvc_type === 'Controller') | |
| 123 | 123 | $class_name = $class_name.'Controller'; | 
| 124 | 124 | |
| 125 | 125 | // not fully namespaced, lets cascade | 
| 126 | 126 |          foreach ($this->getSettings('settings.namespaces') as $ns) { | 
| 127 | - if(class_exists($full_name = $ns . $mvc_type . 's\\' . $class_name)) | |
| 127 | + if (class_exists($full_name = $ns.$mvc_type.'s\\'.$class_name)) | |
| 128 | 128 | return $full_name; | 
| 129 | 129 | } | 
| 130 | 130 | |
| @@ -139,7 +139,7 @@ discard block | ||
| 139 | 139 | $construction_args = []; | 
| 140 | 140 |              if (!is_null($rc->getConstructor())) { | 
| 141 | 141 |                  foreach ($rc->getConstructor()->getParameters() as $param) { | 
| 142 | - $construction_args [] = $this->get($param->getType() . ''); | |
| 142 | + $construction_args [] = $this->get($param->getType().''); | |
| 143 | 143 | } | 
| 144 | 144 | $instance = $rc->newInstanceArgs($construction_args); | 
| 145 | 145 |              } else { | 
| @@ -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,19 +114,23 @@ discard block | ||
| 113 | 114 | private function cascadeNamespace($class_name, $mvc_type=null) | 
| 114 | 115 |      { | 
| 115 | 116 | // does the name already exists ? | 
| 116 | - if(class_exists($class_name)) | |
| 117 | - return $class_name; | |
| 117 | +        if(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 | - if($mvc_type === 'Controller') | |
| 123 | - $class_name = $class_name.'Controller'; | |
| 125 | +        if($mvc_type === 'Controller') { | |
| 126 | + $class_name = $class_name.'Controller'; | |
| 127 | + } | |
| 124 | 128 | |
| 125 | 129 | // not fully namespaced, lets cascade | 
| 126 | 130 |          foreach ($this->getSettings('settings.namespaces') as $ns) { | 
| 127 | - if(class_exists($full_name = $ns . $mvc_type . 's\\' . $class_name)) | |
| 128 | - return $full_name; | |
| 131 | +            if(class_exists($full_name = $ns . $mvc_type . 's\\' . $class_name)) { | |
| 132 | + return $full_name; | |
| 133 | + } | |
| 129 | 134 | } | 
| 130 | 135 | |
| 131 | 136 | throw new ConfigurationException($class_name); |