Passed
Branch master (636813)
by Sinnarasa
05:09
created
src/Routing/Dispatcher/MvcDispatcher.php 1 patch
Unused Use Statements   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@
 block discarded – undo
2 2
 
3 3
 namespace JetFire\Routing\Dispatcher;
4 4
 
5
-use JetFire\Routing\Router;
6
-use ReflectionClass;
5
+use JetFire\Routing\Router;
6
+use ReflectionClass;
7 7
 use ReflectionMethod;
8 8
 
9 9
 /**
Please login to merge, or discard this patch.
src/Routing/Match/RoutesMatch.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      */
87 87
     private function generateTarget()
88 88
     {
89
-        if(is_callable($this->request['path'])){
89
+        if (is_callable($this->request['path'])) {
90 90
             $this->router->route->setCallback($this->request['path']);
91 91
             $this->router->route->setDetail($this->request);
92 92
             $this->anonymous();
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
                     ? $this->router->route->setCallback($this->request['path']['use'])
100 100
                     : $this->router->route->setCallback($this->request['path']);
101 101
             $this->router->route->setDetail($this->request);
102
-            if($this->validMethod()) {
103
-                $this->anonymous();$this->mvc();$this->template();
102
+            if ($this->validMethod()) {
103
+                $this->anonymous(); $this->mvc(); $this->template();
104 104
                 $this->router->route->setResponse(['code' => 202, 'message' => 'Accepted']);
105
-            }else
105
+            } else
106 106
                 $this->router->route->setResponse(['code' => 405, 'message' => 'Method Not Allowed']);
107 107
         }
108 108
         return $this->router->route->hasTarget();
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
             $index = isset($this->request['index']) ? $this->request['index'] : 0;
145 145
             $class = (class_exists($routes[0]))
146 146
                 ? $routes[0]
147
-                : $this->router->collection->getRoutes()['namespace_'.$index].$routes[0];
147
+                : $this->router->collection->getRoutes()['namespace_' . $index] . $routes[0];
148 148
             if (!class_exists($class))
149 149
                 throw new \Exception('Class "' . $class . '." is not found');
150 150
             if (method_exists($class, $routes[1])) {
@@ -167,23 +167,23 @@  discard block
 block discarded – undo
167 167
             $extension = explode('.', $path);
168 168
             $extension = end($extension);
169 169
             $index = isset($this->request['index']) ? $this->request['index'] : 0;
170
-            $block = $this->router->collection->getRoutes('path_'.$index);
170
+            $block = $this->router->collection->getRoutes('path_' . $index);
171 171
             if (in_array('.' . $extension, $this->router->getConfig()['viewExtension'])) {
172 172
                 if (is_file($block . $path)) {
173 173
                     $target = $block . $path;
174
-                    $this->router->route->setTarget(['dispatcher' => 'JetFire\Routing\Dispatcher\TemplateDispatcher', 'template' => $target,'block' => $block, 'extension' => $extension]);
174
+                    $this->router->route->setTarget(['dispatcher' => 'JetFire\Routing\Dispatcher\TemplateDispatcher', 'template' => $target, 'block' => $block, 'extension' => $extension]);
175 175
                     return true;
176 176
                 }
177 177
                 throw new \Exception('Template file "' . $path . '" is not found in "' . $block . '"');
178 178
             } else {
179 179
                 foreach ($this->router->getConfig()['viewExtension'] as $ext) {
180
-                    if (is_file($block . $path . $ext)){
180
+                    if (is_file($block . $path . $ext)) {
181 181
                         $target = $block . $path . $ext;
182
-                        $this->router->route->setTarget(['dispatcher' => 'JetFire\Routing\Dispatcher\TemplateDispatcher', 'template' => $target,'block' => $block,  'extension' => str_replace('.', '', $ext)]);
182
+                        $this->router->route->setTarget(['dispatcher' => 'JetFire\Routing\Dispatcher\TemplateDispatcher', 'template' => $target, 'block' => $block, 'extension' => str_replace('.', '', $ext)]);
183 183
                         return true;
184 184
                     }
185 185
                 }
186
-                throw new \Exception('Template file "' . $path . '" is not found in "' .$block . '"');
186
+                throw new \Exception('Template file "' . $path . '" is not found in "' . $block . '"');
187 187
             }
188 188
         }
189 189
         return false;
Please login to merge, or discard this patch.
src/Routing/Match/SmartMatch.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
     {
44 44
         foreach ($this->router->getConfig()['viewExtension'] as $extension) {
45 45
             for ($i = 0; $i < $this->router->collection->countRoutes; ++$i) {
46
-                $url = explode('/', str_replace($this->router->collection->getRoutes('prefix_' . $i), '',$this->router->route->getUrl()));
46
+                $url = explode('/', str_replace($this->router->collection->getRoutes('prefix_' . $i), '', $this->router->route->getUrl()));
47 47
                 $end = array_pop($url);
48
-                $url = implode('/', array_map('ucwords', $url)).'/'.$end;
48
+                $url = implode('/', array_map('ucwords', $url)) . '/' . $end;
49 49
                 if (is_file(($template = rtrim($this->router->collection->getRoutes('path_' . $i), '/') . $url . $extension))) {
50 50
                     $this->router->route->setTarget(['dispatcher' => 'JetFire\Routing\Dispatcher\TemplateDispatcher', 'template' => $template, 'extension' => str_replace('.', '', $extension)]);
51 51
                     $this->router->route->addDetail('block', $this->router->collection->getRoutes('path_' . $i));
@@ -63,12 +63,12 @@  discard block
 block discarded – undo
63 63
     {
64 64
         $routes = array_slice(explode('/', $this->router->route->getUrl()), 1);
65 65
         $i = 0;
66
-        do{
67
-            $route =  ('/' . $routes[0] == $this->router->collection->getRoutes('prefix_' . $i))
66
+        do {
67
+            $route = ('/' . $routes[0] == $this->router->collection->getRoutes('prefix_' . $i))
68 68
                 ? array_slice($routes, 1) : $routes;
69 69
             if (isset($route[0])) {
70
-                $class =  (class_exists($this->router->collection->getRoutes('namespace_' . $i). ucfirst($route[0]) . 'Controller'))
71
-                    ? $this->router->collection->getRoutes('namespace_' . $i). ucfirst($route[0]) . 'Controller'
70
+                $class = (class_exists($this->router->collection->getRoutes('namespace_' . $i) . ucfirst($route[0]) . 'Controller'))
71
+                    ? $this->router->collection->getRoutes('namespace_' . $i) . ucfirst($route[0]) . 'Controller'
72 72
                     : ucfirst($route[0]) . 'Controller';
73 73
                 if (isset($route[1]) && method_exists($class, $route[1])) {
74 74
                     $this->router->route->setTarget(['dispatcher' => 'JetFire\Routing\Dispatcher\MvcDispatcher', 'controller' => $class, 'action' => $route[1]]);
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
                 }
78 78
             }
79 79
             ++$i;
80
-        }while($i < $this->router->collection->countRoutes);
80
+        }while ($i < $this->router->collection->countRoutes);
81 81
         return false;
82 82
     }
83 83
 
Please login to merge, or discard this patch.
src/Routing/Route.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -205,8 +205,8 @@
 block discarded – undo
205 205
     /**
206 206
      * @return array
207 207
      */
208
-    public function getData(){
209
-        return (isset($this->getDetail()['data']) && is_array($this->getDetail()['data']))?$this->getDetail()['data']:[];
208
+    public function getData() {
209
+        return (isset($this->getDetail()['data']) && is_array($this->getDetail()['data'])) ? $this->getDetail()['data'] : [];
210 210
     }
211 211
 
212 212
     /**
Please login to merge, or discard this patch.
src/Routing/RouteCollection.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function addRoutes($routes = null, $options = [])
44 44
     {
45
-        if(!is_null($routes) && !is_array($routes)) {
45
+        if (!is_null($routes) && !is_array($routes)) {
46 46
             if (strpos($routes, '.php') === false) $routes = trim($routes, '/') . '/';
47 47
             if (is_file($routes . '/routes.php') && is_array($routesFile = include $routes . '/routes.php')) $routes = $routesFile;
48 48
             elseif (is_file($routes) && is_array($routesFile = include $routes)) $routes = $routesFile;
49
-            else throw new \InvalidArgumentException('Argument for "' . get_called_class() . '" constructor is not recognized. Expected argument array or file containing array but "'.$routes.'" given');
49
+            else throw new \InvalidArgumentException('Argument for "' . get_called_class() . '" constructor is not recognized. Expected argument array or file containing array but "' . $routes . '" given');
50 50
         }
51 51
         $this->routes['routes_' . $this->countRoutes] = is_array($routes) ? $routes : [];
52 52
         $this->routes['path_' . $this->countRoutes] = (isset($options['path']) && !empty($options['path'])) ? rtrim($options['path'], '/') . '/' : '';
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function getRoutes($key = null)
63 63
     {
64
-        if(!is_null($key))
65
-            return isset($this->routes[$key])?$this->routes[$key]:'';
64
+        if (!is_null($key))
65
+            return isset($this->routes[$key]) ? $this->routes[$key] : '';
66 66
         return $this->routes;
67 67
     }
68 68
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
         } elseif (is_string($args))
79 79
             for ($i = 0; $i < $this->countRoutes; ++$i)
80 80
                 $this->routes['prefix_' . $i] = '/' . trim($args, '/');
81
-        if($this->countRoutes == 0)$this->countRoutes++;
81
+        if ($this->countRoutes == 0)$this->countRoutes++;
82 82
     }
83 83
 
84 84
     /**
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
     {
89 89
         $nbrArgs = count($args);
90 90
         for ($i = 0; $i < $nbrArgs; ++$i) {
91
-            if(is_array($args[$i])){
91
+            if (is_array($args[$i])) {
92 92
                 $this->routes['path_' . $i] = (isset($args[$i]['path']) && !empty($args[$i]['path'])) ? rtrim($args[$i]['path'], '/') . '/' : '';
93 93
                 $this->routes['namespace_' . $i] = (isset($args[$i]['namespace']) && !empty($args[$i]['namespace'])) ? trim($args[$i]['namespace'], '\\') . '\\' : '';
94
-                $this->routes['prefix_' . $i] = (isset($args[$i]['prefix']) && !empty($args[$i]['prefix'])) ? '/'.trim($args[$i]['prefix'], '/') : '';
95
-                if(!isset($this->routes['routes_' . $i]))$this->routes['routes_' . $i] = [];
94
+                $this->routes['prefix_' . $i] = (isset($args[$i]['prefix']) && !empty($args[$i]['prefix'])) ? '/' . trim($args[$i]['prefix'], '/') : '';
95
+                if (!isset($this->routes['routes_' . $i]))$this->routes['routes_' . $i] = [];
96 96
             }
97 97
         }
98
-        if($this->countRoutes == 0)$this->countRoutes++;
98
+        if ($this->countRoutes == 0)$this->countRoutes++;
99 99
     }
100 100
 
101 101
     /**
Please login to merge, or discard this patch.