@@ -104,12 +104,12 @@ discard block |
||
| 104 | 104 | $found = false; |
| 105 | 105 | $counter = 0; |
| 106 | 106 | |
| 107 | - if(count($this->routes) === 0) { |
|
| 107 | + if (count($this->routes) === 0) { |
|
| 108 | 108 | return $found; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - while($found === false && $counter < count($this->routes)) { |
|
| 112 | - if($this->routes[$counter]->getUri() === $uri && $this->routes[$counter]->getMethod() === $method) { |
|
| 111 | + while ($found === false && $counter < count($this->routes)) { |
|
| 112 | + if ($this->routes[$counter]->getUri() === $uri && $this->routes[$counter]->getMethod() === $method) { |
|
| 113 | 113 | $found = true; |
| 114 | 114 | } |
| 115 | 115 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | |
| 131 | 131 | private function addRoute($uri, $method, $response, array $middleware = []) { |
| 132 | - if($this->find($uri, $method)) { // search if exists an apparition |
|
| 132 | + if ($this->find($uri, $method)) { // search if exists an apparition |
|
| 133 | 133 | return false; |
| 134 | 134 | } |
| 135 | 135 | |
@@ -212,8 +212,8 @@ discard block |
||
| 212 | 212 | */ |
| 213 | 213 | |
| 214 | 214 | public function both($uri, $response, $methods = Method::GET, array $middleware = []) { |
| 215 | - if(is_array($methods)) { |
|
| 216 | - foreach($methods as $method) { |
|
| 215 | + if (is_array($methods)) { |
|
| 216 | + foreach ($methods as $method) { |
|
| 217 | 217 | $this->addRoute($uri, $method, $response, $middleware); |
| 218 | 218 | } |
| 219 | 219 | } else { |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | */ |
| 229 | 229 | |
| 230 | 230 | public function notFound($func) { |
| 231 | - if(is_callable($func)) { |
|
| 231 | + if (is_callable($func)) { |
|
| 232 | 232 | $this->notFound = $func; |
| 233 | 233 | } |
| 234 | 234 | } |
@@ -246,17 +246,17 @@ discard block |
||
| 246 | 246 | public function run() { |
| 247 | 247 | $found = false; |
| 248 | 248 | $counter = 0; |
| 249 | - while($found === false && $counter < count($this->routes)) { |
|
| 250 | - if($this->routerParser->match($this->routes[$counter]->getUri()) && $this->routes[$counter]->getMethod() === $this->requestMethod) { |
|
| 249 | + while ($found === false && $counter < count($this->routes)) { |
|
| 250 | + if ($this->routerParser->match($this->routes[$counter]->getUri()) && $this->routes[$counter]->getMethod() === $this->requestMethod) { |
|
| 251 | 251 | $found = true; |
| 252 | 252 | } else { |
| 253 | 253 | $counter++; |
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - if($found) { |
|
| 257 | + if ($found) { |
|
| 258 | 258 | // run the before middleware if it exists |
| 259 | - if($this->routes[$counter]->hasBefore()) { |
|
| 259 | + if ($this->routes[$counter]->hasBefore()) { |
|
| 260 | 260 | call_user_func($this->routes[$counter]->getMiddlewares()['before']); |
| 261 | 261 | } |
| 262 | 262 | |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | $response = call_user_func_array($this->routes[$counter]->getResponse(), $params); |
| 265 | 265 | |
| 266 | 266 | // run the after middleware if it exists |
| 267 | - if($this->routes[$counter]->hasAfter()) { |
|
| 267 | + if ($this->routes[$counter]->hasAfter()) { |
|
| 268 | 268 | call_user_func($this->routes[$counter]->getMiddlewares()['after']); |
| 269 | 269 | } |
| 270 | 270 | |