@@ -107,7 +107,6 @@ |
||
| 107 | 107 | * Router constructor. |
| 108 | 108 | * Create new router. |
| 109 | 109 | * |
| 110 | - * @param array $routes |
|
| 111 | 110 | * @param string $defaultReturnType |
| 112 | 111 | * @param string $method |
| 113 | 112 | * @param string $requestedPath |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | $message = sprintf('%s is nat valid Http request method.', $method); |
| 125 | 125 | throw new InvalidArgumentException($message); |
| 126 | 126 | } |
| 127 | - $this->method = $method; |
|
| 127 | + $this->method = $method; |
|
| 128 | 128 | $this->requestedPath = $this->extractFolder($requestedPath, $folder); |
| 129 | 129 | $this->defaultReturnType = self::$translations[$defaultReturnType] ?? self::$defaultReturnType[0]; |
| 130 | 130 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * @return string |
| 157 | 157 | * @throws InvalidArgumentException |
| 158 | 158 | */ |
| 159 | - public function add($requestMethods, string $route, string $action, string $returnType=null, string $alias=null) |
|
| 159 | + public function add($requestMethods, string $route, string $action, string $returnType = null, string $alias = null) |
|
| 160 | 160 | { |
| 161 | 161 | $requestMethodParameterType = gettype($requestMethods); |
| 162 | 162 | if (!in_array($requestMethodParameterType, ['array', 'string'], true)) { |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | throw new InvalidArgumentException($message); |
| 167 | 167 | } |
| 168 | 168 | $requestMethodsGiven = is_array($requestMethods) ? (array) $requestMethods : [0 => $requestMethods]; |
| 169 | - $returnType = $returnType === null ? $this->defaultReturnType: self::$validReturnTypes[$returnType]?? $this->defaultReturnType; |
|
| 169 | + $returnType = $returnType === null ? $this->defaultReturnType : self::$validReturnTypes[$returnType]?? $this->defaultReturnType; |
|
| 170 | 170 | foreach ($requestMethodsGiven as $requestMethod) { |
| 171 | 171 | if ($alias !== null) { |
| 172 | 172 | $this->aliases[$alias] = $route; |
@@ -203,8 +203,8 @@ discard block |
||
| 203 | 203 | { |
| 204 | 204 | foreach ($this->routes as $definedRoute) { |
| 205 | 205 | $definedRoute[3] = $definedRoute[3] ?? $this->defaultReturnType; |
| 206 | - $route->addRoute(strtoupper($definedRoute[0]), $definedRoute[1], function ($args) use ($definedRoute) { |
|
| 207 | - list(,,$controller, $returnType) = $definedRoute; |
|
| 206 | + $route->addRoute(strtoupper($definedRoute[0]), $definedRoute[1], function($args) use ($definedRoute) { |
|
| 207 | + list(,, $controller, $returnType) = $definedRoute; |
|
| 208 | 208 | $returnType = Router::$translations[$returnType] ?? $this->defaultReturnType; |
| 209 | 209 | return ['controller' => $controller, 'returnType'=> $returnType, 'args'=> $args]; |
| 210 | 210 | }); |