@@ -88,12 +88,12 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | private function compileGroupData() |
| 90 | 90 | { |
| 91 | - if(!is_a($this->group, RouteGroups::class)) return null; |
|
| 91 | + if (!is_a($this->group, RouteGroups::class)) return null; |
|
| 92 | 92 | |
| 93 | 93 | $this->defaultName = $this->name = $this->group->name; |
| 94 | 94 | $this->defaultNamespace = $this->group->namespace; |
| 95 | 95 | |
| 96 | - if(is_a($this->group->middlewares, MiddlewareCollection::class)) { |
|
| 96 | + if (is_a($this->group->middlewares, MiddlewareCollection::class)) { |
|
| 97 | 97 | $this->middleware = $this->group->middlewares; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | preg_match_all("~\{\s*([a-zA-Z_][a-zA-Z0-9_-]*)\??\}~x", $route, $params, PREG_SET_ORDER); |
| 162 | 162 | |
| 163 | 163 | if ($wordOnly) { |
| 164 | - $params = array_map(function ($param) { |
|
| 164 | + $params = array_map(function($param) { |
|
| 165 | 165 | return $param[1]; |
| 166 | 166 | }, $params); |
| 167 | 167 | } |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | private function resolveHandler(String $handler) |
| 228 | 228 | { |
| 229 | - if(!$this->defaultNamespace) { |
|
| 229 | + if (!$this->defaultNamespace) { |
|
| 230 | 230 | return $handler; |
| 231 | 231 | } |
| 232 | 232 | |
@@ -88,7 +88,9 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | private function compileGroupData() |
| 90 | 90 | { |
| 91 | - if(!is_a($this->group, RouteGroups::class)) return null; |
|
| 91 | + if(!is_a($this->group, RouteGroups::class)) { |
|
| 92 | + return null; |
|
| 93 | + } |
|
| 92 | 94 | |
| 93 | 95 | $this->defaultName = $this->name = $this->group->name; |
| 94 | 96 | $this->defaultNamespace = $this->group->namespace; |
@@ -144,7 +146,9 @@ discard block |
||
| 144 | 146 | */ |
| 145 | 147 | protected function getWhere(String $param): ?String |
| 146 | 148 | { |
| 147 | - if (!isset($this->where[$param])) return null; |
|
| 149 | + if (!isset($this->where[$param])) { |
|
| 150 | + return null; |
|
| 151 | + } |
|
| 148 | 152 | |
| 149 | 153 | return $this->where[$param]; |
| 150 | 154 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | $methods = array_map("strtoupper", $methods); |
| 102 | 102 | |
| 103 | - array_map(function ($method) use ($uri, $callback) { |
|
| 103 | + array_map(function($method) use ($uri, $callback) { |
|
| 104 | 104 | $this->routes[$method][$uri] = $this->addRouter($uri, $callback); |
| 105 | 105 | }, $methods); |
| 106 | 106 | } |
@@ -260,10 +260,10 @@ discard block |
||
| 260 | 260 | ); |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - if($this->instanceOf($route->getMiddleware(), MiddlewareCollection::class)) { |
|
| 263 | + if ($this->instanceOf($route->getMiddleware(), MiddlewareCollection::class)) { |
|
| 264 | 264 | $route->getMiddleware()->setRequest($route->request()); |
| 265 | 265 | |
| 266 | - if(!$route->getMiddleware()->execute()) { |
|
| 266 | + if (!$route->getMiddleware()->execute()) { |
|
| 267 | 267 | $this->setHttpCode($this->httpCodes["notFound"]); |
| 268 | 268 | |
| 269 | 269 | $this->throwException( |
@@ -152,7 +152,9 @@ discard block |
||
| 152 | 152 | $routes = $this->routes[$httpMethod]; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - if (!is_array($routes)) return null; |
|
| 155 | + if (!is_array($routes)) { |
|
| 156 | + return null; |
|
| 157 | + } |
|
| 156 | 158 | |
| 157 | 159 | $soughtRoute = null; |
| 158 | 160 | |
@@ -323,7 +325,9 @@ discard block |
||
| 323 | 325 | */ |
| 324 | 326 | protected function getHttpCode(String $slug) |
| 325 | 327 | { |
| 326 | - if (!isset($this->httpCodes[$slug])) return null; |
|
| 328 | + if (!isset($this->httpCodes[$slug])) { |
|
| 329 | + return null; |
|
| 330 | + } |
|
| 327 | 331 | |
| 328 | 332 | return $this->httpCodes[$slug]; |
| 329 | 333 | } |
@@ -353,7 +357,9 @@ discard block |
||
| 353 | 357 | { |
| 354 | 358 | $method = strtoupper($method); |
| 355 | 359 | |
| 356 | - if (!isset($this->routes[$method])) return null; |
|
| 360 | + if (!isset($this->routes[$method])) { |
|
| 361 | + return null; |
|
| 362 | + } |
|
| 357 | 363 | |
| 358 | 364 | return $this->routes[$method]; |
| 359 | 365 | } |
@@ -104,7 +104,7 @@ |
||
| 104 | 104 | protected function instanceMiddleware($middleware) |
| 105 | 105 | { |
| 106 | 106 | if (!preg_match("/\\\/", $middleware)) { |
| 107 | - if(!$middlewareClass = $this->getByAlias($middleware)) return; |
|
| 107 | + if (!$middlewareClass = $this->getByAlias($middleware)) return; |
|
| 108 | 108 | |
| 109 | 109 | return new $middlewareClass(); |
| 110 | 110 | } |
@@ -104,7 +104,9 @@ |
||
| 104 | 104 | protected function instanceMiddleware($middleware) |
| 105 | 105 | { |
| 106 | 106 | if (!preg_match("/\\\/", $middleware)) { |
| 107 | - if(!$middlewareClass = $this->getByAlias($middleware)) return; |
|
| 107 | + if(!$middlewareClass = $this->getByAlias($middleware)) { |
|
| 108 | + return; |
|
| 109 | + } |
|
| 108 | 110 | |
| 109 | 111 | return new $middlewareClass(); |
| 110 | 112 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | $this->httpMethod = $_SERVER['REQUEST_METHOD'] ?? ''; |
| 27 | 27 | $this->queryStrings = $_GET; |
| 28 | 28 | |
| 29 | - if(isset($this->queryStrings["route"])) { |
|
| 29 | + if (isset($this->queryStrings["route"])) { |
|
| 30 | 30 | unset($this->queryStrings["route"]); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -92,11 +92,11 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function __get(String $data) |
| 94 | 94 | { |
| 95 | - if(isset($this->data[$data])) { |
|
| 95 | + if (isset($this->data[$data])) { |
|
| 96 | 96 | return $this->data[$data]; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if(isset($this->queryStrings[$data])) { |
|
| 99 | + if (isset($this->queryStrings[$data])) { |
|
| 100 | 100 | return $this->queryStrings[$data]; |
| 101 | 101 | } |
| 102 | 102 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | $allWithExcession = $this->data; |
| 197 | 197 | $except = explode(',', $except); |
| 198 | 198 | |
| 199 | - $except = array_map(function ($excession) { |
|
| 199 | + $except = array_map(function($excession) { |
|
| 200 | 200 | return trim(rtrim($excession)); |
| 201 | 201 | }, $except); |
| 202 | 202 | |
@@ -121,7 +121,9 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | if (!empty($diff)) { |
| 123 | 123 | foreach ($routeParams as $index => $param) { |
| 124 | - if (!isset($diff[$index])) return; |
|
| 124 | + if (!isset($diff[$index])) { |
|
| 125 | + return; |
|
| 126 | + } |
|
| 125 | 127 | |
| 126 | 128 | if ($this->httpMethod != 'GET') { |
| 127 | 129 | $this->params[$param] = rawurldecode($diff[$index]); |
@@ -201,7 +203,9 @@ discard block |
||
| 201 | 203 | }, $except); |
| 202 | 204 | |
| 203 | 205 | foreach ($except as $excession) { |
| 204 | - if (!isset($this->data[$excession])) return; |
|
| 206 | + if (!isset($this->data[$excession])) { |
|
| 207 | + return; |
|
| 208 | + } |
|
| 205 | 209 | |
| 206 | 210 | unset($allWithExcession[$excession]); |
| 207 | 211 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | public function where(array $matches): RouteManager |
| 18 | 18 | { |
| 19 | - array_map(function ($key, $value) { |
|
| 19 | + array_map(function($key, $value) { |
|
| 20 | 20 | $this->where[$key] = $value; |
| 21 | 21 | }, array_keys($matches), $matches); |
| 22 | 22 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public function name(String $name, Bool $ignoreDefault = false): RouteManager |
| 103 | 103 | { |
| 104 | - if($ignoreDefault) { |
|
| 104 | + if ($ignoreDefault) { |
|
| 105 | 105 | $this->name = $name; |
| 106 | 106 | } else { |
| 107 | 107 | $this->name = $this->defaultName . $name; |