@@ -89,12 +89,12 @@ discard block |
||
89 | 89 | */ |
90 | 90 | private function compileGroupData() |
91 | 91 | { |
92 | - if(!is_a($this->group, RouteGroups::class)) return null; |
|
92 | + if (!is_a($this->group, RouteGroups::class)) return null; |
|
93 | 93 | |
94 | 94 | $this->defaultName = $this->name = $this->group->name; |
95 | 95 | $this->defaultNamespace = $this->group->namespace; |
96 | 96 | |
97 | - if(is_a($this->group->middlewares, MiddlewareCollection::class)) { |
|
97 | + if (is_a($this->group->middlewares, MiddlewareCollection::class)) { |
|
98 | 98 | $this->middleware = $this->group->middlewares; |
99 | 99 | } |
100 | 100 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | preg_match_all("~\{\s*([a-zA-Z_][a-zA-Z0-9_-]*)\??\}~x", $route, $params, PREG_SET_ORDER); |
163 | 163 | |
164 | 164 | if ($wordOnly) { |
165 | - $params = array_map(function ($param) { |
|
165 | + $params = array_map(function($param) { |
|
166 | 166 | return $param[1]; |
167 | 167 | }, $params); |
168 | 168 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | */ |
228 | 228 | private function resolveHandler(String $handler) |
229 | 229 | { |
230 | - if(!$this->defaultNamespace) { |
|
230 | + if (!$this->defaultNamespace) { |
|
231 | 231 | return $handler; |
232 | 232 | } |
233 | 233 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | */ |
330 | 330 | public function middleware($middleware): RouteManager |
331 | 331 | { |
332 | - if(is_a($this->middleware, MiddlewareCollection::class)) { |
|
332 | + if (is_a($this->middleware, MiddlewareCollection::class)) { |
|
333 | 333 | $middleware = $this->middleware->storeMiddleware($middleware); |
334 | 334 | } |
335 | 335 |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | use MinasRouter\Helpers\Functions; |
4 | 4 | |
5 | -if (! function_exists('router')) { |
|
5 | +if (!function_exists('router')) { |
|
6 | 6 | /** |
7 | 7 | * Method responsible for returning a |
8 | 8 | * new instance of Functions. |
@@ -295,7 +295,7 @@ |
||
295 | 295 | $allWithExcession = $this->data; |
296 | 296 | $except = explode(',', $except); |
297 | 297 | |
298 | - $except = array_map(function ($excession) { |
|
298 | + $except = array_map(function($excession) { |
|
299 | 299 | return trim(rtrim($excession)); |
300 | 300 | }, $except); |
301 | 301 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | { |
34 | 34 | $params = (array) func_get_arg(1); |
35 | 35 | |
36 | - if(!$router = $this->get($routerName)) { |
|
36 | + if (!$router = $this->get($routerName)) { |
|
37 | 37 | return null; |
38 | 38 | } |
39 | 39 | |
@@ -41,15 +41,15 @@ discard block |
||
41 | 41 | |
42 | 42 | preg_match_all("/{\w+\??}/", $originalRoute, $matches); |
43 | 43 | |
44 | - if(empty($matches[0])) { |
|
44 | + if (empty($matches[0])) { |
|
45 | 45 | return $originalRoute; |
46 | 46 | } |
47 | 47 | |
48 | - if(count($matches[0]) != count($params)) { |
|
48 | + if (count($matches[0]) != count($params)) { |
|
49 | 49 | return null; |
50 | 50 | } |
51 | 51 | |
52 | - foreach($matches[0] as $index => $match) { |
|
52 | + foreach ($matches[0] as $index => $match) { |
|
53 | 53 | $paramForReplace = isset($params[$index]) ? $params[$index] : 'undefined'; |
54 | 54 | |
55 | 55 | $originalRoute = str_replace($match, $paramForReplace, $originalRoute); |
@@ -19,7 +19,7 @@ |
||
19 | 19 | |
20 | 20 | public static function userData(Int $id) |
21 | 21 | { |
22 | - if(!isset(self::$names[$id])) { |
|
22 | + if (!isset(self::$names[$id])) { |
|
23 | 23 | return [ |
24 | 24 | 'error' => 404, |
25 | 25 | 'message' => 'User not found' |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function where(array $matches) |
24 | 24 | { |
25 | - array_map(function ($key, $value) { |
|
25 | + array_map(function($key, $value) { |
|
26 | 26 | $this->setWhereData($key, $value); |
27 | 27 | }, array_keys($matches), $matches); |
28 | 28 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function name(String $name, Bool $ignoreDefault = false) |
103 | 103 | { |
104 | - if($ignoreDefault) { |
|
104 | + if ($ignoreDefault) { |
|
105 | 105 | $this->setName($name); |
106 | 106 | } else { |
107 | 107 | $this->setName($this->getDefaultName() . $name); |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function withoutMiddleware($middleware) |
131 | 131 | { |
132 | - if(!is_a($this->middleware, MiddlewareCollection::class)) { |
|
132 | + if (!is_a($this->middleware, MiddlewareCollection::class)) { |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $mid = trim(rtrim($mid)); |
113 | 113 | |
114 | 114 | if (is_string($currentMiddleware)) { |
115 | - $currentMiddleware = rtrim(trim(preg_replace("/\s?".$mid."\,?/", "", $currentMiddleware), ' '), ','); |
|
115 | + $currentMiddleware = rtrim(trim(preg_replace("/\s?" . $mid . "\,?/", "", $currentMiddleware), ' '), ','); |
|
116 | 116 | } else { |
117 | 117 | $currentMiddleware = array_values(array_filter($currentMiddleware, fn($middleware) => $middleware != $mid)); |
118 | 118 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | { |
165 | 165 | $middlewares = $this->middlewares; |
166 | 166 | |
167 | - if(is_string($middlewares)) { |
|
167 | + if (is_string($middlewares)) { |
|
168 | 168 | $middlewares = explode(',', $middlewares); |
169 | 169 | } |
170 | 170 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | */ |
184 | 184 | protected function resolveNestedMiddleware(Array $middlewares): void |
185 | 185 | { |
186 | - $this->queue = array_map(function ($middleware) { |
|
186 | + $this->queue = array_map(function($middleware) { |
|
187 | 187 | $middleware = trim(rtrim($middleware)); |
188 | 188 | |
189 | 189 | return $this->instanceMiddleware($middleware); |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | $methods = array_map("strtoupper", $methods); |
126 | 126 | |
127 | - array_map(function ($method) use ($uri, $callback) { |
|
127 | + array_map(function($method) use ($uri, $callback) { |
|
128 | 128 | $this->routes[$method][$uri] = $this->addRouter($uri, $callback); |
129 | 129 | }, $methods); |
130 | 130 | } |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | protected function dispatchRoute(): ?\Closure |
323 | 323 | { |
324 | 324 | if (!$route = $this->currentRoute) { |
325 | - if($fallbackRoute = $this->getByName('fallback')) { |
|
325 | + if ($fallbackRoute = $this->getByName('fallback')) { |
|
326 | 326 | return $this->executeRoute($fallbackRoute); |
327 | 327 | } |
328 | 328 | |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | ); |
338 | 338 | } |
339 | 339 | |
340 | - if(!$middlewareResponse = $this->executeMiddlewares($route)) { |
|
340 | + if (!$middlewareResponse = $this->executeMiddlewares($route)) { |
|
341 | 341 | return null; |
342 | 342 | } |
343 | 343 | |
344 | - if(is_callable($middlewareResponse)) { |
|
344 | + if (is_callable($middlewareResponse)) { |
|
345 | 345 | return call_user_func($middlewareResponse); |
346 | 346 | } |
347 | 347 | |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | |
420 | 420 | $callMiddleware = $route->getMiddleware()->execute(); |
421 | 421 | |
422 | - if($callMiddleware === true) { |
|
422 | + if ($callMiddleware === true) { |
|
423 | 423 | return true; |
424 | 424 | } |
425 | 425 | |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | ); |
434 | 434 | } |
435 | 435 | |
436 | - if(is_string($callMiddleware)) { |
|
436 | + if (is_string($callMiddleware)) { |
|
437 | 437 | die($callMiddleware); |
438 | 438 | } |
439 | 439 |