Completed
Push — master ( f90141...1143dd )
by Sinnarasa
02:07
created
src/Routing/Response.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -166,8 +166,9 @@
 block discarded – undo
166 166
      */
167 167
     public function sendHeaders()
168 168
     {
169
-        foreach($this->headers as $key => $content)
170
-            header($key.' : '.$content);
169
+        foreach($this->headers as $key => $content) {
170
+                    header($key.' : '.$content);
171
+        }
171 172
         http_response_code($this->getStatusCode());
172 173
         return $this;
173 174
     }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * Class Response
8 8
  * @package JetFire\Routing
9 9
  */
10
-class Response implements ResponseInterface{
10
+class Response implements ResponseInterface {
11 11
 
12 12
     /**
13 13
      * @var array
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     public static $statusTexts = array(
54 54
         100 => 'Continue',
55 55
         101 => 'Switching Protocols',
56
-        102 => 'Processing',            // RFC2518
56
+        102 => 'Processing', // RFC2518
57 57
         200 => 'OK',
58 58
         201 => 'Created',
59 59
         202 => 'Accepted',
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
         204 => 'No Content',
62 62
         205 => 'Reset Content',
63 63
         206 => 'Partial Content',
64
-        207 => 'Multi-Status',          // RFC4918
65
-        208 => 'Already Reported',      // RFC5842
66
-        226 => 'IM Used',               // RFC3229
64
+        207 => 'Multi-Status', // RFC4918
65
+        208 => 'Already Reported', // RFC5842
66
+        226 => 'IM Used', // RFC3229
67 67
         300 => 'Multiple Choices',
68 68
         301 => 'Moved Permanently',
69 69
         302 => 'Found',
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         304 => 'Not Modified',
72 72
         305 => 'Use Proxy',
73 73
         307 => 'Temporary Redirect',
74
-        308 => 'Permanent Redirect',    // RFC7238
74
+        308 => 'Permanent Redirect', // RFC7238
75 75
         400 => 'Bad Request',
76 76
         401 => 'Unauthorized',
77 77
         402 => 'Payment Required',
@@ -90,26 +90,26 @@  discard block
 block discarded – undo
90 90
         415 => 'Unsupported Media Type',
91 91
         416 => 'Range Not Satisfiable',
92 92
         417 => 'Expectation Failed',
93
-        418 => 'I\'m a teapot',                                               // RFC2324
94
-        422 => 'Unprocessable Entity',                                        // RFC4918
95
-        423 => 'Locked',                                                      // RFC4918
96
-        424 => 'Failed Dependency',                                           // RFC4918
97
-        425 => 'Reserved for WebDAV advanced collections expired proposal',   // RFC2817
98
-        426 => 'Upgrade Required',                                            // RFC2817
99
-        428 => 'Precondition Required',                                       // RFC6585
100
-        429 => 'Too Many Requests',                                           // RFC6585
101
-        431 => 'Request Header Fields Too Large',                             // RFC6585
93
+        418 => 'I\'m a teapot', // RFC2324
94
+        422 => 'Unprocessable Entity', // RFC4918
95
+        423 => 'Locked', // RFC4918
96
+        424 => 'Failed Dependency', // RFC4918
97
+        425 => 'Reserved for WebDAV advanced collections expired proposal', // RFC2817
98
+        426 => 'Upgrade Required', // RFC2817
99
+        428 => 'Precondition Required', // RFC6585
100
+        429 => 'Too Many Requests', // RFC6585
101
+        431 => 'Request Header Fields Too Large', // RFC6585
102 102
         500 => 'Internal Server Error',
103 103
         501 => 'Not Implemented',
104 104
         502 => 'Bad Gateway',
105 105
         503 => 'Service Unavailable',
106 106
         504 => 'Gateway Timeout',
107 107
         505 => 'HTTP Version Not Supported',
108
-        506 => 'Variant Also Negotiates (Experimental)',                      // RFC2295
109
-        507 => 'Insufficient Storage',                                        // RFC4918
110
-        508 => 'Loop Detected',                                               // RFC5842
111
-        510 => 'Not Extended',                                                // RFC2774
112
-        511 => 'Network Authentication Required',                             // RFC6585
108
+        506 => 'Variant Also Negotiates (Experimental)', // RFC2295
109
+        507 => 'Insufficient Storage', // RFC4918
110
+        508 => 'Loop Detected', // RFC5842
111
+        510 => 'Not Extended', // RFC2774
112
+        511 => 'Network Authentication Required', // RFC6585
113 113
     );
114 114
 
115 115
     /**
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
      */
167 167
     public function sendHeaders()
168 168
     {
169
-        foreach($this->headers as $key => $content)
169
+        foreach ($this->headers as $key => $content)
170 170
             header($key.' : '.$content);
171 171
         http_response_code($this->getStatusCode());
172 172
         return $this;
Please login to merge, or discard this patch.
src/Routing/Route.php 1 patch
Braces   +18 added lines, -8 removed lines patch added patch discarded remove patch
@@ -52,10 +52,18 @@  discard block
 block discarded – undo
52 52
      */
53 53
     public function set($args = [])
54 54
     {
55
-        if (isset($args['name'])) $this->name = $args['name'];
56
-        if (isset($args['callback'])) $this->callback = $args['callback'];
57
-        if (isset($args['target'])) $this->target = $args['target'];
58
-        if (isset($args['detail'])) $this->detail = $args['detail'];
55
+        if (isset($args['name'])) {
56
+            $this->name = $args['name'];
57
+        }
58
+        if (isset($args['callback'])) {
59
+            $this->callback = $args['callback'];
60
+        }
61
+        if (isset($args['target'])) {
62
+            $this->target = $args['target'];
63
+        }
64
+        if (isset($args['detail'])) {
65
+            $this->detail = $args['detail'];
66
+        }
59 67
     }
60 68
 
61 69
     /**
@@ -145,8 +153,9 @@  discard block
 block discarded – undo
145 153
      */
146 154
     public function getTarget($key = null)
147 155
     {
148
-        if (!is_null($key))
149
-            return isset($this->target[$key]) ? $this->target[$key] : '';
156
+        if (!is_null($key)) {
157
+                    return isset($this->target[$key]) ? $this->target[$key] : '';
158
+        }
150 159
         return empty($this->target) ? '' : $this->target;
151 160
     }
152 161
 
@@ -165,8 +174,9 @@  discard block
 block discarded – undo
165 174
      */
166 175
     public function hasTarget($key = null)
167 176
     {
168
-        if (!is_null($key))
169
-            return isset($this->target[$key]) ? true : false;
177
+        if (!is_null($key)) {
178
+                    return isset($this->target[$key]) ? true : false;
179
+        }
170 180
         return empty($this->target) ? false : true;
171 181
     }
172 182
 
Please login to merge, or discard this patch.
src/Routing/Matcher/MatcherInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
      * @param $method
42 42
      * @param $class
43 43
      */
44
-    public function addDispatcher($method,$class);
44
+    public function addDispatcher($method, $class);
45 45
 
46 46
     /**
47 47
      * @return mixed
Please login to merge, or discard this patch.
src/Routing/Matcher/ArrayMatcher.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
     }
167 167
 
168 168
     /**
169
-     * @param $regex
169
+     * @param string $regex
170 170
      * @return bool
171 171
      */
172 172
     private function routeMatch($regex)
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
     }
217 217
 
218 218
     /**
219
-     * @param $key
219
+     * @param string $key
220 220
      */
221 221
     private function checkRequest($key)
222 222
     {
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -98,15 +98,15 @@  discard block
 block discarded – undo
98 98
     {
99 99
         $this->request = [];
100 100
         for ($i = 0; $i < $this->router->collection->countRoutes; ++$i) {
101
-            $this->request['prefix'] = ($this->router->collection->getRoutes('prefix_' . $i) != '') ? $this->router->collection->getRoutes('prefix_' . $i) : '';
102
-            $this->request['subdomain'] = ($this->router->collection->getRoutes('subdomain_' . $i) != '') ? $this->router->collection->getRoutes('subdomain_' . $i) : '';
103
-            foreach ($this->router->collection->getRoutes('routes_' . $i) as $route => $params) {
101
+            $this->request['prefix'] = ($this->router->collection->getRoutes('prefix_'.$i) != '') ? $this->router->collection->getRoutes('prefix_'.$i) : '';
102
+            $this->request['subdomain'] = ($this->router->collection->getRoutes('subdomain_'.$i) != '') ? $this->router->collection->getRoutes('subdomain_'.$i) : '';
103
+            foreach ($this->router->collection->getRoutes('routes_'.$i) as $route => $params) {
104 104
                 $this->request['params'] = $params;
105 105
                 $this->request['collection_index'] = $i;
106 106
                 if ($this->checkSubdomain($route)) {
107 107
                     $route = strstr($route, '/');
108
-                    $this->request['route'] = preg_replace_callback('#:([\w]+)#', [$this, 'paramMatch'], '/' . trim(trim($this->request['prefix'], '/') . '/' . trim($route, '/'), '/'));
109
-                    if ($this->routeMatch('#^' . $this->request['route'] . '$#')) {
108
+                    $this->request['route'] = preg_replace_callback('#:([\w]+)#', [$this, 'paramMatch'], '/'.trim(trim($this->request['prefix'], '/').'/'.trim($route, '/'), '/'));
109
+                    if ($this->routeMatch('#^'.$this->request['route'].'$#')) {
110 110
                         $this->setCallback();
111 111
                         return $this->generateTarget();
112 112
                     }
@@ -122,19 +122,19 @@  discard block
 block discarded – undo
122 122
      */
123 123
     private function checkSubdomain($route)
124 124
     {
125
-        $url = (isset($_SERVER['REQUEST_SCHEME']) ? $_SERVER['REQUEST_SCHEME'] : 'http') . '://' . ($host = (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST']));
125
+        $url = (isset($_SERVER['REQUEST_SCHEME']) ? $_SERVER['REQUEST_SCHEME'] : 'http').'://'.($host = (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST']));
126 126
         $host = explode(':', $host)[0];
127 127
         $domain = $this->router->collection->getDomain($url);
128
-        if (!empty($this->request['subdomain']) && $route[0] == '/') $route = trim($this->request['subdomain'], '.') . '.' . $domain . $route;
128
+        if (!empty($this->request['subdomain']) && $route[0] == '/') $route = trim($this->request['subdomain'], '.').'.'.$domain.$route;
129 129
         if ($route[0] == '/') {
130 130
             return ($host != $domain) ? false : true;
131 131
         } elseif ($route[0] != '/' && $host != $domain) {
132 132
             $route = substr($route, 0, strpos($route, "/"));
133 133
             $route = str_replace('{host}', $domain, $route);
134 134
             $route = preg_replace_callback('#{subdomain}#', [$this, 'subdomainMatch'], $route);
135
-            if (preg_match('#^' . $route . '$#', $host, $this->request['called_subdomain'])) {
135
+            if (preg_match('#^'.$route.'$#', $host, $this->request['called_subdomain'])) {
136 136
                 $this->request['called_subdomain'] = array_shift($this->request['called_subdomain']);
137
-                $this->request['subdomain'] = str_replace('.' . $domain, '', $host);
137
+                $this->request['subdomain'] = str_replace('.'.$domain, '', $host);
138 138
                 return true;
139 139
             }
140 140
         }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     private function subdomainMatch()
148 148
     {
149 149
         if (is_array($this->request['params']) && isset($this->request['params']['subdomain'])) {
150
-            return '(' . $this->request['params']['subdomain'] . ')';
150
+            return '('.$this->request['params']['subdomain'].')';
151 151
         }
152 152
         return '([^/]+)';
153 153
     }
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
     {
161 161
         if (is_array($this->request['params']) && isset($this->request['params']['arguments'][$match[1]])) {
162 162
             $this->request['params']['arguments'][$match[1]] = str_replace('(', '(?:', $this->request['params']['arguments'][$match[1]]);
163
-            return '(' . $this->request['params']['arguments'][$match[1]] . ')';
163
+            return '('.$this->request['params']['arguments'][$match[1]].')';
164 164
         }
165 165
         return '([^/]+)';
166 166
     }
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
         $this->checkRequest('prefix');
212 212
         $this->router->route->setDetail($this->request);
213 213
         $this->router->route->setTarget($target);
214
-        $this->router->route->addTarget('block', $this->router->collection->getRoutes('block_' . $index));
215
-        $this->router->route->addTarget('view_dir', $this->router->collection->getRoutes('view_dir_' . $index));
214
+        $this->router->route->addTarget('block', $this->router->collection->getRoutes('block_'.$index));
215
+        $this->router->route->addTarget('view_dir', $this->router->collection->getRoutes('view_dir_'.$index));
216 216
     }
217 217
 
218 218
     /**
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
     private function checkRequest($key)
222 222
     {
223 223
         if (strpos($this->request[$key], ':') !== false && isset($this->request['parameters'][0])) {
224
-            $this->request['@' . $key] = $this->request[$key];
224
+            $this->request['@'.$key] = $this->request[$key];
225 225
             $this->request[$key] = $this->request['parameters'][0];
226 226
             unset($this->request['parameters'][0]);
227 227
         }
@@ -237,9 +237,9 @@  discard block
 block discarded – undo
237 237
                 $this->router->route->setCallback($this->request['params']);
238 238
             } else {
239 239
                 if (is_array($this->request['params']) && isset($this->request['params']['use'])) {
240
-                    if(is_array($this->request['params']['use']) && isset($this->request['params']['use'][$this->router->route->getMethod()])){
240
+                    if (is_array($this->request['params']['use']) && isset($this->request['params']['use'][$this->router->route->getMethod()])) {
241 241
                         $this->router->route->setCallback($this->request['params']['use'][$this->router->route->getMethod()]);
242
-                    }elseif(!is_array($this->request['params']['use'])){
242
+                    }elseif (!is_array($this->request['params']['use'])) {
243 243
                         $this->router->route->setCallback($this->request['params']['use']);
244 244
                     }
245 245
                 } else {
@@ -342,9 +342,9 @@  discard block
 block discarded – undo
342 342
             $index = isset($this->request['collection_index']) ? $this->request['collection_index'] : 0;
343 343
             $class = (class_exists($routes[0]))
344 344
                 ? $routes[0]
345
-                : $this->router->collection->getRoutes()['ctrl_namespace_' . $index] . $routes[0];
345
+                : $this->router->collection->getRoutes()['ctrl_namespace_'.$index].$routes[0];
346 346
             if (!class_exists($class)) {
347
-                throw new \Exception('Class "' . $class . '." is not found');
347
+                throw new \Exception('Class "'.$class.'." is not found');
348 348
             }
349 349
             if (method_exists($class, $routes[1])) {
350 350
                 return [
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
                 ];
356 356
             }
357 357
             if (!strpos($callback, '{method}') !== false) {
358
-                throw new \Exception('The required method "' . $routes[1] . '" is not found in "' . $class . '"');
358
+                throw new \Exception('The required method "'.$routes[1].'" is not found in "'.$class.'"');
359 359
             }
360 360
         }
361 361
         return false;
@@ -372,13 +372,13 @@  discard block
 block discarded – undo
372 372
             $path = trim($callback, '/');
373 373
             $extension = substr(strrchr($path, "."), 1);
374 374
             $index = isset($this->request['collection_index']) ? $this->request['collection_index'] : 0;
375
-            $viewDir = $this->router->collection->getRoutes('view_dir_' . $index);
375
+            $viewDir = $this->router->collection->getRoutes('view_dir_'.$index);
376 376
             $target = null;
377
-            if (in_array('.' . $extension, $this->router->getConfig()['templateExtension']) && (is_file($fullPath = $viewDir . $path) || is_file($fullPath = $path))) {
377
+            if (in_array('.'.$extension, $this->router->getConfig()['templateExtension']) && (is_file($fullPath = $viewDir.$path) || is_file($fullPath = $path))) {
378 378
                 $target = $fullPath;
379 379
             } else {
380 380
                 foreach ($this->router->getConfig()['templateExtension'] as $ext) {
381
-                    if (is_file($fullPath = $viewDir . $path . $ext) || is_file($fullPath = $path . $ext)) {
381
+                    if (is_file($fullPath = $viewDir.$path.$ext) || is_file($fullPath = $path.$ext)) {
382 382
                         $target = $fullPath;
383 383
                         $extension = substr(strrchr($ext, "."), 1);
384 384
                         break;
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
                 }
387 387
             }
388 388
             if (is_null($target)) {
389
-                throw new \Exception('Template file "' . $path . '" is not found in "' . $viewDir . '"');
389
+                throw new \Exception('Template file "'.$path.'" is not found in "'.$viewDir.'"');
390 390
             }
391 391
             return [
392 392
                 'dispatcher' => $this->dispatcher['isTemplate'],
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -125,7 +125,9 @@  discard block
 block discarded – undo
125 125
         $url = (isset($_SERVER['REQUEST_SCHEME']) ? $_SERVER['REQUEST_SCHEME'] : 'http') . '://' . ($host = (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST']));
126 126
         $host = explode(':', $host)[0];
127 127
         $domain = $this->router->collection->getDomain($url);
128
-        if (!empty($this->request['subdomain']) && $route[0] == '/') $route = trim($this->request['subdomain'], '.') . '.' . $domain . $route;
128
+        if (!empty($this->request['subdomain']) && $route[0] == '/') {
129
+            $route = trim($this->request['subdomain'], '.') . '.' . $domain . $route;
130
+        }
129 131
         if ($route[0] == '/') {
130 132
             return ($host != $domain) ? false : true;
131 133
         } elseif ($route[0] != '/' && $host != $domain) {
@@ -239,7 +241,7 @@  discard block
 block discarded – undo
239 241
                 if (is_array($this->request['params']) && isset($this->request['params']['use'])) {
240 242
                     if(is_array($this->request['params']['use']) && isset($this->request['params']['use'][$this->router->route->getMethod()])){
241 243
                         $this->router->route->setCallback($this->request['params']['use'][$this->router->route->getMethod()]);
242
-                    }elseif(!is_array($this->request['params']['use'])){
244
+                    } elseif(!is_array($this->request['params']['use'])){
243 245
                         $this->router->route->setCallback($this->request['params']['use']);
244 246
                     }
245 247
                 } else {
@@ -331,12 +333,16 @@  discard block
 block discarded – undo
331 333
     {
332 334
         if (is_string($callback) && strpos($callback, '@') !== false) {
333 335
             $routes = explode('@', $callback);
334
-            if (!isset($routes[1])) $routes[1] = 'index';
336
+            if (!isset($routes[1])) {
337
+                $routes[1] = 'index';
338
+            }
335 339
             if ($routes[1] == '{method}') {
336 340
                 $this->request['parameters'] = explode('/', str_replace(str_replace('*', '', $this->request['route']), '', $this->router->route->getUrl()));
337 341
                 $routes[1] = $this->request['parameters'][0];
338 342
                 array_shift($this->request['parameters']);
339
-                if (preg_match('/[A-Z]/', $routes[1])) return false;
343
+                if (preg_match('/[A-Z]/', $routes[1])) {
344
+                    return false;
345
+                }
340 346
                 $routes[1] = lcfirst(str_replace(' ', '', ucwords(str_replace('-', ' ', $routes[1]))));
341 347
             }
342 348
             $index = isset($this->request['collection_index']) ? $this->request['collection_index'] : 0;
Please login to merge, or discard this patch.
src/Routing/Router.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@
 block discarded – undo
135 135
 
136 136
     /**
137 137
      * @description call the middleware before and after the target
138
-     * @param $action
138
+     * @param string $action
139 139
      */
140 140
     private function callMiddleware($action)
141 141
     {
Please login to merge, or discard this patch.
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -3,8 +3,6 @@
 block discarded – undo
3 3
 namespace JetFire\Routing;
4 4
 
5 5
 use JetFire\Routing\Matcher\ArrayMatcher;
6
-use ReflectionClass;
7
-use ReflectionMethod;
8 6
 
9 7
 /**
10 8
  * Class Router
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -120,14 +120,16 @@  discard block
 block discarded – undo
120 120
     public function run()
121 121
     {
122 122
         $this->setUrl();
123
-        if ($this->config['generateRoutesPath']) $this->collection->generateRoutesPath();
123
+        if ($this->config['generateRoutesPath']) {
124
+            $this->collection->generateRoutesPath();
125
+        }
124 126
         if ($this->match() === true) {
125 127
             $this->callMiddleware('before');
126 128
             if (!in_array(substr($this->response->getStatusCode(), 0, 1), [3,4,5])) {
127 129
                 $this->callTarget();
128 130
             }
129 131
             $this->callMiddleware('after');
130
-        }else{
132
+        } else{
131 133
             $this->response->setStatusCode(404);
132 134
         }
133 135
         return $this->callResponse();
@@ -158,8 +160,9 @@  discard block
 block discarded – undo
158 160
      */
159 161
     public function setUrl($url = null)
160 162
     {
161
-        if (is_null($url))
162
-            $url = (isset($_GET['url'])) ? $_GET['url'] : substr(str_replace(str_replace('/index.php', '', $_SERVER['SCRIPT_NAME']), '', $_SERVER['REQUEST_URI']), 1);
163
+        if (is_null($url)) {
164
+                    $url = (isset($_GET['url'])) ? $_GET['url'] : substr(str_replace(str_replace('/index.php', '', $_SERVER['SCRIPT_NAME']), '', $_SERVER['REQUEST_URI']), 1);
165
+        }
163 166
         $this->route->setUrl('/' . trim(explode('?', $url)[0], '/'));
164 167
     }
165 168
 
@@ -169,7 +172,9 @@  discard block
 block discarded – undo
169 172
     public function match()
170 173
     {
171 174
         foreach ($this->matcher as $key => $matcher) {
172
-            if (call_user_func([$this->matcher[$key], 'match'])) return true;
175
+            if (call_user_func([$this->matcher[$key], 'match'])) {
176
+                return true;
177
+            }
173 178
         }
174 179
         return false;
175 180
     }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         $this->collection = $collection;
58 58
         $this->response = is_null($response) ? new Response() : $response;
59 59
         $this->route = is_null($route) ? new Route() : $route;
60
-        $this->config['di'] = function ($class) {
60
+        $this->config['di'] = function($class) {
61 61
             return new $class;
62 62
         };
63 63
     }
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
         if ($this->config['generateRoutesPath']) $this->collection->generateRoutesPath();
124 124
         if ($this->match() === true) {
125 125
             $this->callMiddleware('before');
126
-            if (!in_array(substr($this->response->getStatusCode(), 0, 1), [3,4,5])) {
126
+            if (!in_array(substr($this->response->getStatusCode(), 0, 1), [3, 4, 5])) {
127 127
                 $this->callTarget();
128 128
             }
129 129
             $this->callMiddleware('after');
130
-        }else{
130
+        } else {
131 131
             $this->response->setStatusCode(404);
132 132
         }
133 133
         return $this->callResponse();
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     {
158 158
         if (is_null($url))
159 159
             $url = (isset($_GET['url'])) ? $_GET['url'] : substr(str_replace(str_replace('/index.php', '', $_SERVER['SCRIPT_NAME']), '', $_SERVER['REQUEST_URI']), 1);
160
-        $this->route->setUrl('/' . trim(explode('?', $url)[0], '/'));
160
+        $this->route->setUrl('/'.trim(explode('?', $url)[0], '/'));
161 161
     }
162 162
 
163 163
     /**
Please login to merge, or discard this patch.
src/Routing/Dispatcher/ControllerDispatcher.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@
 block discarded – undo
85 85
     {
86 86
         $reflector = new ReflectionClass($this->router->route->getTarget('controller'));
87 87
         if (!$reflector->isInstantiable()) {
88
-            throw new \Exception('Target [' . $this->router->route->getTarget('controller') . '] is not instantiable.');
88
+            throw new \Exception('Target ['.$this->router->route->getTarget('controller').'] is not instantiable.');
89 89
         }
90 90
         $constructor = $reflector->getConstructor();
91 91
         if (is_null($constructor)) {
Please login to merge, or discard this patch.
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,10 +49,11 @@
 block discarded – undo
49 49
 
50 50
         foreach ($reflectionMethod->getParameters() as $arg) {
51 51
             if (!is_null($arg->getClass())) {
52
-                if (isset($classInstance[$arg->getClass()->name]))
53
-                $dependencies[] = $classInstance[$arg->getClass()->name];
54
-            else
55
-                $dependencies[] = call_user_func_array($this->router->route->getTarget('di'), [$arg->getClass()->name]);
52
+                if (isset($classInstance[$arg->getClass()->name])) {
53
+                                $dependencies[] = $classInstance[$arg->getClass()->name];
54
+                } else {
55
+                            $dependencies[] = call_user_func_array($this->router->route->getTarget('di'), [$arg->getClass()->name]);
56
+            }
56 57
             } else {
57 58
                 $count++;
58 59
             }
Please login to merge, or discard this patch.
src/Routing/Dispatcher/TemplateDispatcher.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,8 +44,12 @@
 block discarded – undo
44 44
             $this->router->response->setContent(call_user_func_array($this->router->route->getTarget('callback')[$this->router->route->getTarget('extension')], [$this->router->route]));
45 45
         } else {
46 46
             ob_start();
47
-            if (isset($this->router->route->getTarget()['data'])) extract($this->router->route->getTarget('data'));
48
-            if (isset($this->router->route->getParams()['data'])) extract($this->router->route->getParams()['data']);
47
+            if (isset($this->router->route->getTarget()['data'])) {
48
+                extract($this->router->route->getTarget('data'));
49
+            }
50
+            if (isset($this->router->route->getParams()['data'])) {
51
+                extract($this->router->route->getParams()['data']);
52
+            }
49 53
             require($this->router->route->getTarget('template'));
50 54
             $this->router->response->setContent(ob_get_clean());
51 55
         }
Please login to merge, or discard this patch.
src/Routing/Matcher/UriMatcher.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
         $index = isset($this->request['collection_index']) ? $this->request['collection_index'] : 0;
109 109
         $this->router->route->setDetail($this->request);
110 110
         $this->router->route->setTarget($target);
111
-        $this->router->route->addTarget('block', $this->router->collection->getRoutes('block_' . $index));
112
-        $this->router->route->addTarget('view_dir', $this->router->collection->getRoutes('view_dir_' . $index));
111
+        $this->router->route->addTarget('block', $this->router->collection->getRoutes('block_'.$index));
112
+        $this->router->route->addTarget('view_dir', $this->router->collection->getRoutes('view_dir_'.$index));
113 113
     }
114 114
 
115 115
     /**
@@ -135,10 +135,10 @@  discard block
 block discarded – undo
135 135
     {
136 136
         foreach ($this->router->getConfig()['templateExtension'] as $extension) {
137 137
             for ($i = 0; $i < $this->router->collection->countRoutes; ++$i) {
138
-                $url = explode('/', str_replace($this->router->collection->getRoutes('prefix_' . $i), '', $this->router->route->getUrl()));
138
+                $url = explode('/', str_replace($this->router->collection->getRoutes('prefix_'.$i), '', $this->router->route->getUrl()));
139 139
                 $end = array_pop($url);
140
-                $url = implode('/', array_map('ucwords', $url)) . '/' . $end;
141
-                if (is_file(($template = rtrim($this->router->collection->getRoutes('view_dir_' . $i), '/') . $url . $extension))) {
140
+                $url = implode('/', array_map('ucwords', $url)).'/'.$end;
141
+                if (is_file(($template = rtrim($this->router->collection->getRoutes('view_dir_'.$i), '/').$url.$extension))) {
142 142
                     $this->request['collection_index'] = $i;
143 143
                     return [
144 144
                         'dispatcher' => $this->dispatcher['isTemplate'],
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
         $routes = array_slice(explode('/', $this->router->route->getUrl()), 1);
161 161
         $i = 0;
162 162
         do {
163
-            $route = ('/' . $routes[0] == $this->router->collection->getRoutes('prefix_' . $i)) ? array_slice($routes, 1) : $routes;
163
+            $route = ('/'.$routes[0] == $this->router->collection->getRoutes('prefix_'.$i)) ? array_slice($routes, 1) : $routes;
164 164
             if (isset($route[0])) {
165
-                $class = (class_exists($this->router->collection->getRoutes('ctrl_namespace_' . $i) . ucfirst($route[0]) . 'Controller'))
166
-                    ? $this->router->collection->getRoutes('ctrl_namespace_' . $i) . ucfirst($route[0]) . 'Controller'
167
-                    : ucfirst($route[0]) . 'Controller';
165
+                $class = (class_exists($this->router->collection->getRoutes('ctrl_namespace_'.$i).ucfirst($route[0]).'Controller'))
166
+                    ? $this->router->collection->getRoutes('ctrl_namespace_'.$i).ucfirst($route[0]).'Controller'
167
+                    : ucfirst($route[0]).'Controller';
168 168
                 $route[1] = isset($route[1]) ? $route[1] : 'index';
169 169
                 if (method_exists($class, $route[1])) {
170 170
                     $this->request['parameters'] = array_slice($route, 2);
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
                 }
179 179
             }
180 180
             ++$i;
181
-        } while ($i < $this->router->collection->countRoutes);
181
+        }while ($i < $this->router->collection->countRoutes);
182 182
         return false;
183 183
     }
184 184
 
Please login to merge, or discard this patch.
src/Routing/Middleware.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     }
68 68
 
69 69
     /**
70
-     * @param $action
70
+     * @param string $action
71 71
      * @param $middleware
72 72
      */
73 73
     private function setMiddleware($action, $middleware)
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     /**
96 96
      * @description global middleware
97 97
      * @param $action
98
-     * @return bool|mixed
98
+     * @return boolean
99 99
      */
100 100
     public function globalMiddleware($action)
101 101
     {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
     {
183 183
         $callback = explode('@', $callback);
184 184
         $method = isset($callback[1]) ? $callback[1] : 'handle';
185
-        if(class_exists($callback[0])) {
185
+        if (class_exists($callback[0])) {
186 186
             $instance = call_user_func($this->router->getConfig()['di'], $callback[0]);
187 187
             if (method_exists($instance, $method)) {
188 188
                 $reflectionMethod = new ReflectionMethod($instance, $method);
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
                 }
195 195
                 $dependencies = array_merge($dependencies, [$this->router->route]);
196 196
                 $response = $reflectionMethod->invokeArgs($instance, $dependencies);
197
-                if($response instanceof ResponseInterface) {
197
+                if ($response instanceof ResponseInterface) {
198 198
                     $this->router->response = $response;
199 199
                 }
200 200
                 return $response;
Please login to merge, or discard this patch.