Passed
Push — master ( 14321e...8cc3ab )
by Sinnarasa
02:52
created
src/Routing/Dispatcher/ControllerDispatcher.php 1 patch
Braces   +12 added lines, -7 removed lines patch added patch discarded remove patch
@@ -50,17 +50,21 @@  discard block
 block discarded – undo
50 50
         }
51 51
         if ($count == count($this->route->getParameters()) || $count == 0) {
52 52
             $dependencies = array_merge($dependencies, ($this->route->getParameters() == '') ? [] : $this->route->getParameters());
53
-            if ($this->response->getStatusCode() == 202)
54
-                $this->response->setStatusCode(200);
53
+            if ($this->response->getStatusCode() == 202) {
54
+                            $this->response->setStatusCode(200);
55
+            }
55 56
             if (is_array($content = $reflectionMethod->invokeArgs($this->getController(), $dependencies))) {
56 57
                 $this->route->addTarget('data', $content);
57 58
                 if (isset($this->route->getParams()['ajax']) && $this->route->getParams()['ajax'] === true) {
58 59
                     $this->response->setContent(json_encode($content));
59 60
                     $this->response->setHeaders(['Content-Type' => 'application/json']);
60 61
                 }
61
-            } elseif (!is_null($content)) $this->response->setContent($content);
62
-        } else
63
-            $this->response->setStatusCode(404);
62
+            } elseif (!is_null($content)) {
63
+                $this->response->setContent($content);
64
+            }
65
+        } else {
66
+                    $this->response->setStatusCode(404);
67
+        }
64 68
     }
65 69
 
66 70
 
@@ -71,8 +75,9 @@  discard block
 block discarded – undo
71 75
     private function getController()
72 76
     {
73 77
         $reflector = new ReflectionClass($this->route->getTarget('controller'));
74
-        if (!$reflector->isInstantiable())
75
-            throw new \Exception('Target [' . $this->route->getTarget('controller') . '] is not instantiable.');
78
+        if (!$reflector->isInstantiable()) {
79
+                    throw new \Exception('Target [' . $this->route->getTarget('controller') . '] is not instantiable.');
80
+        }
76 81
         $constructor = $reflector->getConstructor();
77 82
         if (is_null($constructor)) {
78 83
             $class = $this->route->getTarget('controller');
Please login to merge, or discard this patch.