@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | { |
| 258 | 258 | $routerTrimmed = trim($router, '/'); |
| 259 | 259 | |
| 260 | - if (! isset($this->middleware[$routerTrimmed])) { |
|
| 260 | + if (!isset($this->middleware[$routerTrimmed])) { |
|
| 261 | 261 | $this->middleware[$routerTrimmed] = []; |
| 262 | 262 | } |
| 263 | 263 | |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | $this->parameters |
| 289 | 289 | ]; |
| 290 | 290 | |
| 291 | - if (! count($middleWares)) { |
|
| 291 | + if (!count($middleWares)) { |
|
| 292 | 292 | return $result; |
| 293 | 293 | } |
| 294 | 294 | |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | * Route |
| 349 | 349 | * @return array|callable|bool route handler |
| 350 | 350 | */ |
| 351 | - protected function getStaticRouteProcessor(string $route , $universal) |
|
| 351 | + protected function getStaticRouteProcessor(string $route, $universal) |
|
| 352 | 352 | { |
| 353 | 353 | $processors = $this->staticRoutes[$_SERVER['REQUEST_METHOD']]; |
| 354 | 354 | |
@@ -374,9 +374,9 @@ discard block |
||
| 374 | 374 | * Route |
| 375 | 375 | * @return mixed Result of the router processor |
| 376 | 376 | */ |
| 377 | - public function findStaticRouteProcessor(string $route , $universal = false) |
|
| 377 | + public function findStaticRouteProcessor(string $route, $universal = false) |
|
| 378 | 378 | { |
| 379 | - $processor = $this->getStaticRouteProcessor($route , $universal); |
|
| 379 | + $processor = $this->getStaticRouteProcessor($route, $universal); |
|
| 380 | 380 | |
| 381 | 381 | if ($processor === false) { |
| 382 | 382 | return false; |
@@ -358,8 +358,7 @@ |
||
| 358 | 358 | } else { |
| 359 | 359 | return false; |
| 360 | 360 | } |
| 361 | - } |
|
| 362 | - else { |
|
| 361 | + } else { |
|
| 363 | 362 | $processor = $processors['*']; |
| 364 | 363 | } |
| 365 | 364 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function callRoute($route) |
| 107 | 107 | { |
| 108 | - if (! $this->regExpsWereCompiled) { |
|
| 108 | + if (!$this->regExpsWereCompiled) { |
|
| 109 | 109 | $this->compileRegexpForBunches(); |
| 110 | 110 | } |
| 111 | 111 | |
@@ -113,13 +113,13 @@ discard block |
||
| 113 | 113 | $requestMethod = $this->getRequestMethod(); |
| 114 | 114 | $this->validateRequestMethod($requestMethod); |
| 115 | 115 | |
| 116 | - if (($result = $this->findStaticRouteProcessor($route,false)) !== false) { |
|
| 116 | + if (($result = $this->findStaticRouteProcessor($route, false)) !== false) { |
|
| 117 | 117 | return $result; |
| 118 | 118 | } |
| 119 | 119 | if (($result = $this->findDynamicRouteProcessor($route)) !== false) { |
| 120 | 120 | return $result; |
| 121 | 121 | } |
| 122 | - if (($result = $this->findStaticRouteProcessor($route,true)) !== false) { |
|
| 122 | + if (($result = $this->findStaticRouteProcessor($route, true)) !== false) { |
|
| 123 | 123 | return $result; |
| 124 | 124 | } |
| 125 | 125 | call_user_func($this->invalidRouteErrorHandler, $route); |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | $route = Utils::prepareRoute($route); |
| 140 | 140 | |
| 141 | - if (($result = $this->getStaticRouteProcessor($route,false)) !== false) { |
|
| 141 | + if (($result = $this->getStaticRouteProcessor($route, false)) !== false) { |
|
| 142 | 142 | return $result; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | return $result; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - if (($result = $this->getStaticRouteProcessor($route,true)) !== false) { |
|
| 149 | + if (($result = $this->getStaticRouteProcessor($route, true)) !== false) { |
|
| 150 | 150 | return $result; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | { |
| 51 | 51 | $return = ''; |
| 52 | 52 | |
| 53 | - for ($n = 0; $n <= $i; $n ++) { |
|
| 53 | + for ($n = 0; $n <= $i; $n++) { |
|
| 54 | 54 | $return .= '()'; |
| 55 | 55 | } |
| 56 | 56 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | protected function compileRegexpForBunch(array &$bunch): void |
| 66 | 66 | { |
| 67 | - if (! empty($bunch['bunch'])) { |
|
| 67 | + if (!empty($bunch['bunch'])) { |
|
| 68 | 68 | $bunch['regexp'] = ''; |
| 69 | 69 | $hashTable = []; |
| 70 | 70 | $items = []; |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | protected function compileRegexpForBunches(): void |
| 102 | 102 | { |
| 103 | - if (! $this->regExpsWereCompiled) { |
|
| 103 | + if (!$this->regExpsWereCompiled) { |
|
| 104 | 104 | foreach (self::getListOfSupportedRequestMethods() as $requestMethod) { |
| 105 | 105 | foreach ($this->paramRoutes[$requestMethod] as &$bunch) { |
| 106 | 106 | $this->compileRegexpForBunch($bunch); |
@@ -136,31 +136,31 @@ discard block |
||
| 136 | 136 | $this->paramRoutes[$requestMethod][] = [ |
| 137 | 137 | 'bunch' => [] |
| 138 | 138 | ]; |
| 139 | - $bunchCursor ++; |
|
| 139 | + $bunchCursor++; |
|
| 140 | 140 | $lastBunchSize = 0; |
| 141 | 141 | } |
| 142 | 142 | /** |
| 143 | 143 | * Matching dynamic routes |
| 144 | 144 | */ |
| 145 | 145 | preg_match_all('#\[(.*?)\]#', $route, $match); |
| 146 | - foreach ( $match[0] as $key =>$block ) { |
|
| 147 | - $role = explode ( ":",$match[1][$key]); |
|
| 148 | - switch($role[0]) { |
|
| 146 | + foreach ($match[0] as $key =>$block) { |
|
| 147 | + $role = explode(":", $match[1][$key]); |
|
| 148 | + switch ($role[0]) { |
|
| 149 | 149 | case "s": // any string |
| 150 | 150 | $regex = "[a-zA-Z0-9]+$"; |
| 151 | - $route = str_replace($match[0][$key],$regex,$route); |
|
| 151 | + $route = str_replace($match[0][$key], $regex, $route); |
|
| 152 | 152 | break; |
| 153 | 153 | case "i": // any integer number |
| 154 | 154 | $regex = "[0-9]+$"; |
| 155 | - $route = str_replace($match[0][$key],$regex,$route); |
|
| 155 | + $route = str_replace($match[0][$key], $regex, $route); |
|
| 156 | 156 | break; |
| 157 | 157 | case "a": // any string |
| 158 | 158 | $regex = "([^\s]+)"; |
| 159 | - $route = str_replace($match[0][$key],$regex,$route); |
|
| 159 | + $route = str_replace($match[0][$key], $regex, $route); |
|
| 160 | 160 | break; |
| 161 | 161 | case "il": // comma separated list of integer ids |
| 162 | 162 | $regex = "[0-9]+(,[0-9]+)*"; |
| 163 | - $route = str_replace($match[0][$key],$regex,$route); |
|
| 163 | + $route = str_replace($match[0][$key], $regex, $route); |
|
| 164 | 164 | break; |
| 165 | 165 | } |
| 166 | 166 | } |
@@ -293,11 +293,11 @@ discard block |
||
| 293 | 293 | |
| 294 | 294 | foreach (self::getListOfSupportedRequestMethods() as $requestMethod) { |
| 295 | 295 | $trace[] = $requestMethod . ' : '; |
| 296 | - if (! empty($this->staticRoutes[$requestMethod])) { |
|
| 296 | + if (!empty($this->staticRoutes[$requestMethod])) { |
|
| 297 | 297 | $trace[] = implode(', ', array_keys($this->staticRoutes[$requestMethod])); |
| 298 | 298 | $trace[] = ', '; |
| 299 | 299 | } |
| 300 | - if (! empty($this->paramRoutes[$requestMethod])) { |
|
| 300 | + if (!empty($this->paramRoutes[$requestMethod])) { |
|
| 301 | 301 | foreach ($this->paramRoutes[$requestMethod] as $bunch) { |
| 302 | 302 | $items = []; |
| 303 | 303 | foreach ($bunch['bunch'] as $item) { |