|
@@ -124,7 +124,7 @@ discard block |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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
|
}); |