@@ -67,7 +67,7 @@ discard block |
||
| 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 |
||
| 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 | { |
@@ -182,7 +182,7 @@ discard block |
||
| 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 |
||
| 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; |
@@ -57,7 +57,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | /** |