@@ -96,8 +96,9 @@ discard block  | 
                                                    ||
| 96 | 96 |          { | 
                                                        
| 97 | 97 | foreach ($currentRoute->middleware as $middleware)  | 
                                                        
| 98 | 98 |              { | 
                                                        
| 99 | - if (!in_array($middleware, $_run))  | 
                                                        |
| 100 | - $_run[] = $middleware;  | 
                                                        |
| 99 | +                if (!in_array($middleware, $_run)) { | 
                                                        |
| 100 | + $_run[] = $middleware;  | 
                                                        |
| 101 | + }  | 
                                                        |
| 101 | 102 | }  | 
                                                        
| 102 | 103 | }  | 
                                                        
| 103 | 104 | |
@@ -125,31 +126,36 @@ discard block  | 
                                                    ||
| 125 | 126 | |
| 126 | 127 | $middlewareName = ucfirst($middlewareName).'_middleware';  | 
                                                        
| 127 | 128 | |
| 128 | - if (!file_exists($middlewareDir))  | 
                                                        |
| 129 | -            show_error('Unable to find (or read) the middleware folder: "'.$middlewareDir.'"'); | 
                                                        |
| 129 | +        if (!file_exists($middlewareDir)) { | 
                                                        |
| 130 | +                    show_error('Unable to find (or read) the middleware folder: "'.$middlewareDir.'"'); | 
                                                        |
| 131 | + }  | 
                                                        |
| 130 | 132 | |
| 131 | 133 | $runMiddleware = $middlewareDir.$middlewareName.'.php';  | 
                                                        
| 132 | 134 | |
| 133 | - if (!file_exists($runMiddleware))  | 
                                                        |
| 134 | -            show_error('Unable to find (or read) the middleware "'.$runMiddleware.'"'); | 
                                                        |
| 135 | +        if (!file_exists($runMiddleware)) { | 
                                                        |
| 136 | +                    show_error('Unable to find (or read) the middleware "'.$runMiddleware.'"'); | 
                                                        |
| 137 | + }  | 
                                                        |
| 135 | 138 | |
| 136 | 139 | require $runMiddleware;  | 
                                                        
| 137 | 140 | |
| 138 | - if (!class_exists($middlewareName))  | 
                                                        |
| 139 | -            show_error('Class "'.$middlewareName.'" not found'); | 
                                                        |
| 141 | +        if (!class_exists($middlewareName)) { | 
                                                        |
| 142 | +                    show_error('Class "'.$middlewareName.'" not found'); | 
                                                        |
| 143 | + }  | 
                                                        |
| 140 | 144 | |
| 141 | 145 | $middleware = new $middlewareName();  | 
                                                        
| 142 | 146 | |
| 143 | 147 | // Call the current controller __beforeMiddleware() method, if exists:  | 
                                                        
| 144 | - if (method_exists(self::$instance, '_beforeMiddleware'))  | 
                                                        |
| 145 | - self::$instance->_beforeMiddleware();  | 
                                                        |
| 148 | +        if (method_exists(self::$instance, '_beforeMiddleware')) { | 
                                                        |
| 149 | + self::$instance->_beforeMiddleware();  | 
                                                        |
| 150 | + }  | 
                                                        |
| 146 | 151 | |
| 147 | 152 | // Run the middleware  | 
                                                        
| 148 | 153 | $middleware->run();  | 
                                                        
| 149 | 154 | |
| 150 | 155 | // Call the current controller _afterMiddleware() method, if exists:  | 
                                                        
| 151 | - if (method_exists(self::$instance, '_afterMiddleware'))  | 
                                                        |
| 152 | - self::$instance->_afterMiddleware();  | 
                                                        |
| 156 | +        if (method_exists(self::$instance, '_afterMiddleware')) { | 
                                                        |
| 157 | + self::$instance->_afterMiddleware();  | 
                                                        |
| 158 | + }  | 
                                                        |
| 153 | 159 | |
| 154 | 160 | }  | 
                                                        
| 155 | 161 | }  | 
                                                        
@@ -117,16 +117,16 @@  | 
                                                    ||
| 117 | 117 | |
| 118 | 118 | // Redirect to 404 if not enough parameters provided  | 
                                                        
| 119 | 119 | |
| 120 | - if(count($path_args) < count($route_args['required']))  | 
                                                        |
| 120 | + if (count($path_args) < count($route_args['required']))  | 
                                                        |
| 121 | 121 | redirect(Route::get404()->path);  | 
                                                        
| 122 | 122 | |
| 123 | - if(count($path_args) == 0)  | 
                                                        |
| 123 | + if (count($path_args) == 0)  | 
                                                        |
| 124 | 124 |                  { | 
                                                        
| 125 | 125 |                      $this->CI->{$this->route->method}(); | 
                                                        
| 126 | 126 | }  | 
                                                        
| 127 | 127 | else  | 
                                                        
| 128 | 128 |                  { | 
                                                        
| 129 | - call_user_func_array( [$this->CI, $this->route->method], array_values($path_args) );  | 
                                                        |
| 129 | + call_user_func_array([$this->CI, $this->route->method], array_values($path_args));  | 
                                                        |
| 130 | 130 | }  | 
                                                        
| 131 | 131 | |
| 132 | 132 | |
@@ -64,20 +64,22 @@ discard block  | 
                                                    ||
| 64 | 64 | |
| 65 | 65 | // FIXME: Solve ambiguity here! POST with _method="GET" makes no sense  | 
                                                        
| 66 | 66 | |
| 67 | - if (isset($_POST['_method']) && in_array(strtoupper($_POST['_method']), $validMethods, TRUE))  | 
                                                        |
| 68 | - $formMethod = strtoupper($_POST['_method']);  | 
                                                        |
| 67 | +        if (isset($_POST['_method']) && in_array(strtoupper($_POST['_method']), $validMethods, TRUE)) { | 
                                                        |
| 68 | + $formMethod = strtoupper($_POST['_method']);  | 
                                                        |
| 69 | + }  | 
                                                        |
| 69 | 70 | |
| 70 | 71 | if (is_null($formMethod))  | 
                                                        
| 71 | 72 |          { | 
                                                        
| 72 | 73 | $this->requestMethod = $requestMethod;  | 
                                                        
| 73 | - }  | 
                                                        |
| 74 | - else  | 
                                                        |
| 74 | + } else  | 
                                                        |
| 75 | 75 |          { | 
                                                        
| 76 | - if ($requestMethod == 'POST')  | 
                                                        |
| 77 | - $this->requestMethod = $formMethod;  | 
                                                        |
| 76 | +            if ($requestMethod == 'POST') { | 
                                                        |
| 77 | + $this->requestMethod = $formMethod;  | 
                                                        |
| 78 | + }  | 
                                                        |
| 78 | 79 | |
| 79 | - if (!$this->CI->input->is_ajax_request() && $this->requestMethod == 'HEAD')  | 
                                                        |
| 80 | - $this->requestMethod = 'POST';  | 
                                                        |
| 80 | +            if (!$this->CI->input->is_ajax_request() && $this->requestMethod == 'HEAD') { | 
                                                        |
| 81 | + $this->requestMethod = 'POST';  | 
                                                        |
| 82 | + }  | 
                                                        |
| 81 | 83 | }  | 
                                                        
| 82 | 84 | }  | 
                                                        
| 83 | 85 | |
@@ -117,14 +119,14 @@ discard block  | 
                                                    ||
| 117 | 119 | |
| 118 | 120 | // Redirect to 404 if not enough parameters provided  | 
                                                        
| 119 | 121 | |
| 120 | - if(count($path_args) < count($route_args['required']))  | 
                                                        |
| 121 | - redirect(Route::get404()->path);  | 
                                                        |
| 122 | +                if(count($path_args) < count($route_args['required'])) { | 
                                                        |
| 123 | + redirect(Route::get404()->path);  | 
                                                        |
| 124 | + }  | 
                                                        |
| 122 | 125 | |
| 123 | 126 | if(count($path_args) == 0)  | 
                                                        
| 124 | 127 |                  { | 
                                                        
| 125 | 128 |                      $this->CI->{$this->route->method}(); | 
                                                        
| 126 | - }  | 
                                                        |
| 127 | - else  | 
                                                        |
| 129 | + } else  | 
                                                        |
| 128 | 130 |                  { | 
                                                        
| 129 | 131 | call_user_func_array( [$this->CI, $this->route->method], array_values($path_args) );  | 
                                                        
| 130 | 132 | }  | 
                                                        
@@ -134,14 +136,12 @@ discard block  | 
                                                    ||
| 134 | 136 | |
| 135 | 137 | $this->CI->output->_display();  | 
                                                        
| 136 | 138 | exit(0);  | 
                                                        
| 137 | - }  | 
                                                        |
| 138 | - else  | 
                                                        |
| 139 | + } else  | 
                                                        |
| 139 | 140 |              { | 
                                                        
| 140 | 141 | if (ENVIRONMENT != 'production')  | 
                                                        
| 141 | 142 |                  { | 
                                                        
| 142 | 143 |                      show_error('The method '.$this->route->controller.'::'.$this->route->method.'() does not exists', 500, 'Method not found'); | 
                                                        
| 143 | - }  | 
                                                        |
| 144 | - else  | 
                                                        |
| 144 | + } else  | 
                                                        |
| 145 | 145 |                  { | 
                                                        
| 146 | 146 | //redirect(Route::get404()->path);  | 
                                                        
| 147 | 147 | Route::trigger404();  | 
                                                        
@@ -570,12 +570,12 @@ discard block  | 
                                                    ||
| 570 | 570 | |
| 571 | 571 | foreach ($replaces as $regex => $replace)  | 
                                                        
| 572 | 572 |              { | 
                                                        
| 573 | - if($customRegex)  | 
                                                        |
| 573 | + if ($customRegex)  | 
                                                        |
| 574 | 574 | continue;  | 
                                                        
| 575 | 575 | |
| 576 | 576 | $matches = [];  | 
                                                        
| 577 | 577 | |
| 578 | -                if(preg_match('/^\{(.*)\}$/', $segment)) | 
                                                        |
| 578 | +                if (preg_match('/^\{(.*)\}$/', $segment)) | 
                                                        |
| 579 | 579 |                  { | 
                                                        
| 580 | 580 | $foundedArgs[$key] = $segment;  | 
                                                        
| 581 | 581 | }  | 
                                                        
@@ -583,7 +583,7 @@ discard block  | 
                                                    ||
| 583 | 583 | $c = 0;  | 
                                                        
| 584 | 584 |                  $segment = preg_replace('/'.$regex.'/', $replace, $segment, 1, $c); | 
                                                        
| 585 | 585 | |
| 586 | - if( $regex == array_keys($replaces)[0] && $c > 0)  | 
                                                        |
| 586 | + if ($regex == array_keys($replaces)[0] && $c > 0)  | 
                                                        |
| 587 | 587 | $customRegex = TRUE;  | 
                                                        
| 588 | 588 | }  | 
                                                        
| 589 | 589 | }  | 
                                                        
@@ -1018,7 +1018,7 @@ discard block  | 
                                                    ||
| 1018 | 1018 |                              { | 
                                                        
| 1019 | 1019 | for ($i = 0; $i < count($e_findPath); $i++)  | 
                                                        
| 1020 | 1020 |                                  { | 
                                                        
| 1021 | - if(in_array($i, $skip_seg))  | 
                                                        |
| 1021 | + if (in_array($i, $skip_seg))  | 
                                                        |
| 1022 | 1022 | continue;  | 
                                                        
| 1023 | 1023 | |
| 1024 | 1024 | if ($valid)  | 
                                                        
@@ -146,11 +146,13 @@ discard block  | 
                                                    ||
| 146 | 146 | $controller = $parsedController[1];  | 
                                                        
| 147 | 147 | $method = $parsedController[2];  | 
                                                        
| 148 | 148 | |
| 149 | - if (!is_string($path))  | 
                                                        |
| 150 | -            show_error('Route path must be a string ', 500, 'Route error: bad route path'); | 
                                                        |
| 149 | +        if (!is_string($path)) { | 
                                                        |
| 150 | +                    show_error('Route path must be a string ', 500, 'Route error: bad route path'); | 
                                                        |
| 151 | + }  | 
                                                        |
| 151 | 152 | |
| 152 | - if (!is_string($verb))  | 
                                                        |
| 153 | -            show_error('Route HTTP Verb must be a string', 500, 'Route error: bad verb type'); | 
                                                        |
| 153 | +        if (!is_string($verb)) { | 
                                                        |
| 154 | +                    show_error('Route HTTP Verb must be a string', 500, 'Route error: bad verb type'); | 
                                                        |
| 155 | + }  | 
                                                        |
| 154 | 156 | |
| 155 | 157 | $verb = strtoupper($verb);  | 
                                                        
| 156 | 158 | |
@@ -186,30 +188,36 @@ discard block  | 
                                                    ||
| 186 | 188 | $route['prefix'] = NULL;  | 
                                                        
| 187 | 189 |          $group_prefix = implode('/', self::$prefix); | 
                                                        
| 188 | 190 | |
| 189 | - if ($group_prefix)  | 
                                                        |
| 190 | - $route['prefix'] = $group_prefix.'/';  | 
                                                        |
| 191 | +        if ($group_prefix) { | 
                                                        |
| 192 | + $route['prefix'] = $group_prefix.'/';  | 
                                                        |
| 193 | + }  | 
                                                        |
| 191 | 194 | |
| 192 | - if (isset($attr['prefix']))  | 
                                                        |
| 193 | - $route['prefix'] .= $attr['prefix'];  | 
                                                        |
| 195 | +        if (isset($attr['prefix'])) { | 
                                                        |
| 196 | + $route['prefix'] .= $attr['prefix'];  | 
                                                        |
| 197 | + }  | 
                                                        |
| 194 | 198 | |
| 195 | 199 | // Setting up the namespace  | 
                                                        
| 196 | 200 | |
| 197 | 201 | $route['namespace'] = NULL;  | 
                                                        
| 198 | 202 |          $group_namespace = implode('/', self::$namespace); | 
                                                        
| 199 | 203 | |
| 200 | - if (!is_null($group_namespace))  | 
                                                        |
| 201 | - $route['namespace'] = $group_namespace.'/';  | 
                                                        |
| 202 | - if (isset($attr['namespace']))  | 
                                                        |
| 203 | - $route['namespace'] .= $attr['namespace'];  | 
                                                        |
| 204 | +        if (!is_null($group_namespace)) { | 
                                                        |
| 205 | + $route['namespace'] = $group_namespace.'/';  | 
                                                        |
| 206 | + }  | 
                                                        |
| 207 | +        if (isset($attr['namespace'])) { | 
                                                        |
| 208 | + $route['namespace'] .= $attr['namespace'];  | 
                                                        |
| 209 | + }  | 
                                                        |
| 204 | 210 | |
| 205 | 211 | $route['prefix'] = trim($route['prefix'], '/');  | 
                                                        
| 206 | 212 | $route['namespace'] = trim($route['namespace'], '/');  | 
                                                        
| 207 | 213 | |
| 208 | - if (empty($route['prefix']))  | 
                                                        |
| 209 | - $route['prefix'] = NULL;  | 
                                                        |
| 214 | +        if (empty($route['prefix'])) { | 
                                                        |
| 215 | + $route['prefix'] = NULL;  | 
                                                        |
| 216 | + }  | 
                                                        |
| 210 | 217 | |
| 211 | - if (empty($route['namespace']))  | 
                                                        |
| 212 | - $route['namespace'] = NULL;  | 
                                                        |
| 218 | +        if (empty($route['namespace'])) { | 
                                                        |
| 219 | + $route['namespace'] = NULL;  | 
                                                        |
| 220 | + }  | 
                                                        |
| 213 | 221 | |
| 214 | 222 | // Route middleware  | 
                                                        
| 215 | 223 | $route['middleware'] = [];  | 
                                                        
@@ -219,14 +227,14 @@ discard block  | 
                                                    ||
| 219 | 227 |          { | 
                                                        
| 220 | 228 | if (is_array($attr['middleware']))  | 
                                                        
| 221 | 229 |              { | 
                                                        
| 222 | - foreach ($attr['middleware'] as $middleware)  | 
                                                        |
| 223 | - $route['middleware'][] = $middleware; # Group  | 
                                                        |
| 224 | - }  | 
                                                        |
| 225 | - elseif (is_string($attr['middleware']))  | 
                                                        |
| 230 | +                foreach ($attr['middleware'] as $middleware) { | 
                                                        |
| 231 | + $route['middleware'][] = $middleware;  | 
                                                        |
| 232 | + }  | 
                                                        |
| 233 | + # Group  | 
                                                        |
| 234 | + } elseif (is_string($attr['middleware']))  | 
                                                        |
| 226 | 235 |              { | 
                                                        
| 227 | 236 | $route['middleware'][] = $attr['middleware']; # Group  | 
                                                        
| 228 | - }  | 
                                                        |
| 229 | - else  | 
                                                        |
| 237 | + } else  | 
                                                        |
| 230 | 238 |              { | 
                                                        
| 231 | 239 |                  show_error('Route middleware must be a string or an array', 500, 'Route error: bad middleware format'); | 
                                                        
| 232 | 240 | }  | 
                                                        
@@ -398,8 +406,9 @@ discard block  | 
                                                    ||
| 398 | 406 | */  | 
                                                        
| 399 | 407 | public static function matches($verbs, $url, $attr, $hideOriginal = FALSE)  | 
                                                        
| 400 | 408 |      { | 
                                                        
| 401 | - if (!is_array($verbs))  | 
                                                        |
| 402 | -            show_error('Route::matches() first argument must be an array of valid HTTP Verbs', 500, 'Route error: bad Route::matches() verb list'); | 
                                                        |
| 409 | +        if (!is_array($verbs)) { | 
                                                        |
| 410 | +                    show_error('Route::matches() first argument must be an array of valid HTTP Verbs', 500, 'Route error: bad Route::matches() verb list'); | 
                                                        |
| 411 | + }  | 
                                                        |
| 403 | 412 | |
| 404 | 413 | foreach ($verbs as $verb)  | 
                                                        
| 405 | 414 |          { | 
                                                        
@@ -427,19 +436,23 @@ discard block  | 
                                                    ||
| 427 | 436 | |
| 428 | 437 | $hideOriginal = FALSE;  | 
                                                        
| 429 | 438 | |
| 430 | - if (isset($attr['namespace']))  | 
                                                        |
| 431 | - $base_attr['namespace'] = $attr['namespace'];  | 
                                                        |
| 439 | +        if (isset($attr['namespace'])) { | 
                                                        |
| 440 | + $base_attr['namespace'] = $attr['namespace'];  | 
                                                        |
| 441 | + }  | 
                                                        |
| 432 | 442 | |
| 433 | - if (isset($attr['middleware']))  | 
                                                        |
| 434 | - $base_attr['middleware'] = $attr['middleware'];  | 
                                                        |
| 443 | +        if (isset($attr['middleware'])) { | 
                                                        |
| 444 | + $base_attr['middleware'] = $attr['middleware'];  | 
                                                        |
| 445 | + }  | 
                                                        |
| 435 | 446 | |
| 436 | - if (isset($attr['hideOriginal']))  | 
                                                        |
| 437 | - $hideOriginal = (bool) $attr['hideOriginal'];  | 
                                                        |
| 447 | +        if (isset($attr['hideOriginal'])) { | 
                                                        |
| 448 | + $hideOriginal = (bool) $attr['hideOriginal'];  | 
                                                        |
| 449 | + }  | 
                                                        |
| 438 | 450 | |
| 439 | 451 | $base_attr['prefix'] = strtolower($name);  | 
                                                        
| 440 | 452 | |
| 441 | - if (isset($attr['prefix']))  | 
                                                        |
| 442 | - $base_attr['prefix'] = $attr['prefix'];  | 
                                                        |
| 453 | +        if (isset($attr['prefix'])) { | 
                                                        |
| 454 | + $base_attr['prefix'] = $attr['prefix'];  | 
                                                        |
| 455 | + }  | 
                                                        |
| 443 | 456 | |
| 444 | 457 | $only = [];  | 
                                                        
| 445 | 458 | |
@@ -450,8 +463,7 @@ discard block  | 
                                                    ||
| 450 | 463 | if (is_array($attr['only']))  | 
                                                        
| 451 | 464 |              { | 
                                                        
| 452 | 465 | $only = $attr['only'];  | 
                                                        
| 453 | - }  | 
                                                        |
| 454 | - else  | 
                                                        |
| 466 | + } else  | 
                                                        |
| 455 | 467 |              { | 
                                                        
| 456 | 468 | $only[] = $attr['only'];  | 
                                                        
| 457 | 469 | }  | 
                                                        
@@ -528,13 +540,15 @@ discard block  | 
                                                    ||
| 528 | 540 | |
| 529 | 541 | $path = $route->path;  | 
                                                        
| 530 | 542 | |
| 531 | - if (!is_null($prefix))  | 
                                                        |
| 532 | - $path = $prefix.'/'.$path;  | 
                                                        |
| 543 | +        if (!is_null($prefix)) { | 
                                                        |
| 544 | + $path = $prefix.'/'.$path;  | 
                                                        |
| 545 | + }  | 
                                                        |
| 533 | 546 | |
| 534 | 547 | $controller = $route->controller.'/'.$route->method;  | 
                                                        
| 535 | 548 | |
| 536 | - if (!is_null($namespace))  | 
                                                        |
| 537 | - $controller = $namespace.'/'.$controller;  | 
                                                        |
| 549 | +        if (!is_null($namespace)) { | 
                                                        |
| 550 | + $controller = $namespace.'/'.$controller;  | 
                                                        |
| 551 | + }  | 
                                                        |
| 538 | 552 | |
| 539 | 553 | $path = trim($path, '/');  | 
                                                        
| 540 | 554 | $controller = trim($controller, '/');  | 
                                                        
@@ -570,8 +584,9 @@ discard block  | 
                                                    ||
| 570 | 584 | |
| 571 | 585 | foreach ($replaces as $regex => $replace)  | 
                                                        
| 572 | 586 |              { | 
                                                        
| 573 | - if($customRegex)  | 
                                                        |
| 574 | - continue;  | 
                                                        |
| 587 | +                if($customRegex) { | 
                                                        |
| 588 | + continue;  | 
                                                        |
| 589 | + }  | 
                                                        |
| 575 | 590 | |
| 576 | 591 | $matches = [];  | 
                                                        
| 577 | 592 | |
@@ -583,8 +598,9 @@ discard block  | 
                                                    ||
| 583 | 598 | $c = 0;  | 
                                                        
| 584 | 599 |                  $segment = preg_replace('/'.$regex.'/', $replace, $segment, 1, $c); | 
                                                        
| 585 | 600 | |
| 586 | - if( $regex == array_keys($replaces)[0] && $c > 0)  | 
                                                        |
| 587 | - $customRegex = TRUE;  | 
                                                        |
| 601 | +                if( $regex == array_keys($replaces)[0] && $c > 0) { | 
                                                        |
| 602 | + $customRegex = TRUE;  | 
                                                        |
| 603 | + }  | 
                                                        |
| 588 | 604 | }  | 
                                                        
| 589 | 605 | }  | 
                                                        
| 590 | 606 | |
@@ -602,11 +618,11 @@ discard block  | 
                                                    ||
| 602 | 618 |              { | 
                                                        
| 603 | 619 | $args['optional'][] = $arg;  | 
                                                        
| 604 | 620 | $argConstraint = TRUE;  | 
                                                        
| 605 | - }  | 
                                                        |
| 606 | - else  | 
                                                        |
| 621 | + } else  | 
                                                        |
| 607 | 622 |              { | 
                                                        
| 608 | - if ($argConstraint)  | 
                                                        |
| 609 | -                    show_error('Optional route path argument not valid at this position', 500, 'Route error'); | 
                                                        |
| 623 | +                if ($argConstraint) { | 
                                                        |
| 624 | +                                    show_error('Optional route path argument not valid at this position', 500, 'Route error'); | 
                                                        |
| 625 | + }  | 
                                                        |
| 610 | 626 | $args['required'][] = $arg;  | 
                                                        
| 611 | 627 | }  | 
                                                        
| 612 | 628 | }  | 
                                                        
@@ -718,12 +734,14 @@ discard block  | 
                                                    ||
| 718 | 734 | $path = key($route);  | 
                                                        
| 719 | 735 | $_404 = $route[$path];  | 
                                                        
| 720 | 736 | |
| 721 | - if (!isset($routes[$path]))  | 
                                                        |
| 722 | - $routes[$path] = $_404;  | 
                                                        |
| 737 | +            if (!isset($routes[$path])) { | 
                                                        |
| 738 | + $routes[$path] = $_404;  | 
                                                        |
| 739 | + }  | 
                                                        |
| 723 | 740 | }  | 
                                                        
| 724 | 741 | |
| 725 | - if (is_null(self::$defaultController))  | 
                                                        |
| 726 | -            show_error('You must specify a home route: Route::home() as default controller!', 500, 'Route error: missing default controller'); | 
                                                        |
| 742 | +        if (is_null(self::$defaultController)) { | 
                                                        |
| 743 | +                    show_error('You must specify a home route: Route::home() as default controller!', 500, 'Route error: missing default controller'); | 
                                                        |
| 744 | + }  | 
                                                        |
| 727 | 745 | |
| 728 | 746 | $defaultController = self::$defaultController->compiled;  | 
                                                        
| 729 | 747 | $defaultController = $defaultController[key($defaultController)];  | 
                                                        
@@ -757,11 +775,13 @@ discard block  | 
                                                    ||
| 757 | 775 | */  | 
                                                        
| 758 | 776 | public static function group($attr, $routes)  | 
                                                        
| 759 | 777 |      { | 
                                                        
| 760 | - if (!is_array($attr))  | 
                                                        |
| 761 | -            show_error('Group attribute must be a valid array'); | 
                                                        |
| 778 | +        if (!is_array($attr)) { | 
                                                        |
| 779 | +                    show_error('Group attribute must be a valid array'); | 
                                                        |
| 780 | + }  | 
                                                        |
| 762 | 781 | |
| 763 | - if (!isset($attr['prefix']))  | 
                                                        |
| 764 | -            show_error('You must specify an prefix!'); | 
                                                        |
| 782 | +        if (!isset($attr['prefix'])) { | 
                                                        |
| 783 | +                    show_error('You must specify an prefix!'); | 
                                                        |
| 784 | + }  | 
                                                        |
| 765 | 785 | |
| 766 | 786 | self::$prefix[] = $attr['prefix'];  | 
                                                        
| 767 | 787 | |
@@ -784,15 +804,14 @@ discard block  | 
                                                    ||
| 784 | 804 |              { | 
                                                        
| 785 | 805 | if (is_array($attr['middleware']) && !empty($attr['middleware']))  | 
                                                        
| 786 | 806 |                  { | 
                                                        
| 787 | - foreach ($attr['middleware'] as $middleware)  | 
                                                        |
| 788 | - self::$middleware[] = $middleware;  | 
                                                        |
| 789 | - }  | 
                                                        |
| 790 | - else  | 
                                                        |
| 807 | +                    foreach ($attr['middleware'] as $middleware) { | 
                                                        |
| 808 | + self::$middleware[] = $middleware;  | 
                                                        |
| 809 | + }  | 
                                                        |
| 810 | + } else  | 
                                                        |
| 791 | 811 |                  { | 
                                                        
| 792 | 812 | self::$middleware[] = $attr['middleware'];  | 
                                                        
| 793 | 813 | }  | 
                                                        
| 794 | - }  | 
                                                        |
| 795 | - else  | 
                                                        |
| 814 | + } else  | 
                                                        |
| 796 | 815 |              { | 
                                                        
| 797 | 816 |                  show_error('Group middleware must be an array o a string', 500, 'Route error'); | 
                                                        
| 798 | 817 | }  | 
                                                        
@@ -824,14 +843,17 @@ discard block  | 
                                                    ||
| 824 | 843 | 'as' => $as  | 
                                                        
| 825 | 844 | ];  | 
                                                        
| 826 | 845 | |
| 827 | - if (!is_null($attr) && !is_array($attr))  | 
                                                        |
| 828 | -            show_error('Default controller attributes must be an array', 500, 'Route error: bad attribute type'); | 
                                                        |
| 846 | +        if (!is_null($attr) && !is_array($attr)) { | 
                                                        |
| 847 | +                    show_error('Default controller attributes must be an array', 500, 'Route error: bad attribute type'); | 
                                                        |
| 848 | + }  | 
                                                        |
| 829 | 849 | |
| 830 | - if (!is_null($attr))  | 
                                                        |
| 831 | - $routeAttr = array_merge($routeAttr, $attr);  | 
                                                        |
| 850 | +        if (!is_null($attr)) { | 
                                                        |
| 851 | + $routeAttr = array_merge($routeAttr, $attr);  | 
                                                        |
| 852 | + }  | 
                                                        |
| 832 | 853 | |
| 833 | - if (isset($attr['prefix']))  | 
                                                        |
| 834 | -            show_error('Default controller may not have a prefix!', 500, 'Route error: prefix not allowed'); | 
                                                        |
| 854 | +        if (isset($attr['prefix'])) { | 
                                                        |
| 855 | +                    show_error('Default controller may not have a prefix!', 500, 'Route error: prefix not allowed'); | 
                                                        |
| 856 | + }  | 
                                                        |
| 835 | 857 | |
| 836 | 858 |          self::$defaultController = self::$routes[] = self::add('GET', '/', ['uses' => $controller, 'as' => $as], TRUE, TRUE); | 
                                                        
| 837 | 859 | }  | 
                                                        
@@ -850,14 +872,14 @@ discard block  | 
                                                    ||
| 850 | 872 | if (is_null($verb))  | 
                                                        
| 851 | 873 |          { | 
                                                        
| 852 | 874 | return self::$routes;  | 
                                                        
| 853 | - }  | 
                                                        |
| 854 | - else  | 
                                                        |
| 875 | + } else  | 
                                                        |
| 855 | 876 |          { | 
                                                        
| 856 | 877 | $routes = [];  | 
                                                        
| 857 | 878 | foreach (self::$routes as $route)  | 
                                                        
| 858 | 879 |              { | 
                                                        
| 859 | - if ($route->verb == $verb)  | 
                                                        |
| 860 | - $routes[] = $route;  | 
                                                        |
| 880 | +                if ($route->verb == $verb) { | 
                                                        |
| 881 | + $routes[] = $route;  | 
                                                        |
| 882 | + }  | 
                                                        |
| 861 | 883 | }  | 
                                                        
| 862 | 884 | return $routes;  | 
                                                        
| 863 | 885 | }  | 
                                                        
@@ -954,18 +976,21 @@ discard block  | 
                                                    ||
| 954 | 976 | */  | 
                                                        
| 955 | 977 | public static function getRouteByPath($path, $requestMethod = NULL)  | 
                                                        
| 956 | 978 |      { | 
                                                        
| 957 | - if (is_null($requestMethod))  | 
                                                        |
| 958 | - $requestMethod = $_SERVER['REQUEST_METHOD'];  | 
                                                        |
| 979 | +        if (is_null($requestMethod)) { | 
                                                        |
| 980 | + $requestMethod = $_SERVER['REQUEST_METHOD'];  | 
                                                        |
| 981 | + }  | 
                                                        |
| 959 | 982 | |
| 960 | 983 | $routes = self::getRoutes($requestMethod);  | 
                                                        
| 961 | 984 | |
| 962 | - if (empty($routes))  | 
                                                        |
| 963 | - return FALSE;  | 
                                                        |
| 985 | +        if (empty($routes)) { | 
                                                        |
| 986 | + return FALSE;  | 
                                                        |
| 987 | + }  | 
                                                        |
| 964 | 988 | |
| 965 | 989 | $path = trim($path);  | 
                                                        
| 966 | 990 | |
| 967 | - if ($path == '')  | 
                                                        |
| 968 | - return self::$defaultController;  | 
                                                        |
| 991 | +        if ($path == '') { | 
                                                        |
| 992 | + return self::$defaultController;  | 
                                                        |
| 993 | + }  | 
                                                        |
| 969 | 994 | |
| 970 | 995 | $wildcards =  | 
                                                        
| 971 | 996 | [  | 
                                                        
@@ -991,10 +1016,10 @@ discard block  | 
                                                    ||
| 991 | 1016 | |
| 992 | 1017 | if ($mode == 'exact')  | 
                                                        
| 993 | 1018 |                      { | 
                                                        
| 994 | - if ($findPath == $compiledPath)  | 
                                                        |
| 995 | - return $route;  | 
                                                        |
| 996 | - }  | 
                                                        |
| 997 | - else  | 
                                                        |
| 1019 | +                        if ($findPath == $compiledPath) { | 
                                                        |
| 1020 | + return $route;  | 
                                                        |
| 1021 | + }  | 
                                                        |
| 1022 | + } else  | 
                                                        |
| 998 | 1023 |                      { | 
                                                        
| 999 | 1024 |                          $e_findPath     = explode('/', $findPath); | 
                                                        
| 1000 | 1025 |                          $e_compiledPath = explode('/', $compiledPath); | 
                                                        
@@ -1010,24 +1035,28 @@ discard block  | 
                                                    ||
| 1010 | 1035 | $reg = preg_replace($wildcards, $replaces, $e_compiledPath[$i], -1, $count);  | 
                                                        
| 1011 | 1036 |                                  $valid = (bool) preg_match('#^'.$reg.'$#', $e_findPath[$i]); | 
                                                        
| 1012 | 1037 | |
| 1013 | - if ($valid && $count > 0)  | 
                                                        |
| 1014 | - $skip_seg[] = $i;  | 
                                                        |
| 1038 | +                                if ($valid && $count > 0) { | 
                                                        |
| 1039 | + $skip_seg[] = $i;  | 
                                                        |
| 1040 | + }  | 
                                                        |
| 1015 | 1041 | }  | 
                                                        
| 1016 | 1042 | |
| 1017 | 1043 | if ($valid)  | 
                                                        
| 1018 | 1044 |                              { | 
                                                        
| 1019 | 1045 | for ($i = 0; $i < count($e_findPath); $i++)  | 
                                                        
| 1020 | 1046 |                                  { | 
                                                        
| 1021 | - if(in_array($i, $skip_seg))  | 
                                                        |
| 1022 | - continue;  | 
                                                        |
| 1047 | +                                    if(in_array($i, $skip_seg)) { | 
                                                        |
| 1048 | + continue;  | 
                                                        |
| 1049 | + }  | 
                                                        |
| 1023 | 1050 | |
| 1024 | - if ($valid)  | 
                                                        |
| 1025 | - $valid = $e_findPath[$i] == $e_compiledPath[$i];  | 
                                                        |
| 1051 | +                                    if ($valid) { | 
                                                        |
| 1052 | + $valid = $e_findPath[$i] == $e_compiledPath[$i];  | 
                                                        |
| 1053 | + }  | 
                                                        |
| 1026 | 1054 | }  | 
                                                        
| 1027 | 1055 | }  | 
                                                        
| 1028 | 1056 | |
| 1029 | - if ($valid)  | 
                                                        |
| 1030 | - return $route;  | 
                                                        |
| 1057 | +                            if ($valid) { | 
                                                        |
| 1058 | + return $route;  | 
                                                        |
| 1059 | + }  | 
                                                        |
| 1031 | 1060 | }  | 
                                                        
| 1032 | 1061 | }  | 
                                                        
| 1033 | 1062 | }  | 
                                                        
@@ -1061,8 +1090,9 @@ discard block  | 
                                                    ||
| 1061 | 1090 | |
| 1062 | 1091 | for ($s = 0; $s < count($r_seg); $s++)  | 
                                                        
| 1063 | 1092 |          { | 
                                                        
| 1064 | - if (!isset($p_seg[$s]))  | 
                                                        |
| 1065 | - continue;  | 
                                                        |
| 1093 | +            if (!isset($p_seg[$s])) { | 
                                                        |
| 1094 | + continue;  | 
                                                        |
| 1095 | + }  | 
                                                        |
| 1066 | 1096 | |
| 1067 | 1097 | if ($r_seg[$s] != $p_seg[$s])  | 
                                                        
| 1068 | 1098 |              { |