Passed
Push — main ( e6a09b...cb46db )
by Sammy
01:35
created
LeMarchand.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,24 +110,24 @@  discard block
 block discarded – undo
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
         // is the controller name already instantiable ?
116
-        if(is_null($mvc_type) && class_exists($class_name))
116
+        if (is_null($mvc_type) && 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 !== 'Model' && $mvc_type !== 'Controller'){
122
+        if ($mvc_type !== 'Model' && $mvc_type !== 'Controller') {
123 123
             throw new LamentException('MVC_TYPE ('.$mvc_type.') UNKOWN');
124 124
         }
125
-        if($mvc_type === 'Controller')
125
+        if ($mvc_type === 'Controller')
126 126
           $class_name = $class_name.'Controller';
127 127
 
128 128
         // not fully namespaced, lets cascade
129 129
         foreach ($this->getSettings('settings.namespaces') as $ns) {
130
-            if(class_exists($full_name = $ns . $mvc_type . 's\\' . $class_name))
130
+            if (class_exists($full_name = $ns.$mvc_type.'s\\'.$class_name))
131 131
               return $full_name;
132 132
         }
133 133
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
             $construction_args = [];
143 143
             if (!is_null($rc->getConstructor())) {
144 144
                 foreach ($rc->getConstructor()->getParameters() as $param) {
145
-                    $construction_args [] = $this->get($param->getType() . '');
145
+                    $construction_args [] = $this->get($param->getType().'');
146 146
                 }
147 147
                 $instance = $rc->newInstanceArgs($construction_args);
148 148
             } else {
Please login to merge, or discard this patch.