@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Selami; |
| 5 | 5 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | private $routerClosures = []; |
| 39 | 39 | |
| 40 | 40 | |
| 41 | - public function __construct(array $routes, int $defaultReturnType, ?string $cachedFile) |
|
| 41 | + public function __construct(array $routes, int $defaultReturnType, ? string $cachedFile) |
|
| 42 | 42 | { |
| 43 | 43 | $this->routes = $routes; |
| 44 | 44 | $this->defaultReturnType = $defaultReturnType; |
@@ -100,10 +100,10 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | private function addRoutes(FastRoute\RouteCollector $route) : void |
| 102 | 102 | { |
| 103 | - $routeIndex=0; |
|
| 103 | + $routeIndex = 0; |
|
| 104 | 104 | foreach ($this->routes as $definedRoute) { |
| 105 | 105 | $definedRoute[3] = $definedRoute[3] ?? $this->defaultReturnType; |
| 106 | - $routeName = 'routeClosure'.$routeIndex; |
|
| 106 | + $routeName = 'routeClosure' . $routeIndex; |
|
| 107 | 107 | $route->addRoute(strtoupper($definedRoute[0]), $definedRoute[1], $routeName); |
| 108 | 108 | $routeIndex++; |
| 109 | 109 | } |
@@ -111,13 +111,13 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | private function setRouteClosures() : void |
| 113 | 113 | { |
| 114 | - $routeIndex=0; |
|
| 114 | + $routeIndex = 0; |
|
| 115 | 115 | foreach ($this->routes as $definedRoute) { |
| 116 | 116 | $definedRoute[3] = $definedRoute[3] ?? $this->defaultReturnType; |
| 117 | - $routeName = 'routeClosure'.$routeIndex; |
|
| 117 | + $routeName = 'routeClosure' . $routeIndex; |
|
| 118 | 118 | [$requestMedhod, $url, $controller, $returnType] = $definedRoute; |
| 119 | - $returnType = ($returnType >=1 && $returnType <=7) ? $returnType : $this->defaultReturnType; |
|
| 120 | - $this->routerClosures[$routeName]= function ($args) use ($controller, $returnType) { |
|
| 119 | + $returnType = ($returnType >= 1 && $returnType <= 7) ? $returnType : $this->defaultReturnType; |
|
| 120 | + $this->routerClosures[$routeName] = function($args) use ($controller, $returnType) { |
|
| 121 | 121 | return ['controller' => $controller, 'returnType'=> $returnType, 'args'=> $args]; |
| 122 | 122 | }; |
| 123 | 123 | $routeIndex++; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | string $method, |
| 119 | 119 | string $requestedPath, |
| 120 | 120 | string $folder = '', |
| 121 | - ?string $cachedFile = null |
|
| 121 | + ? string $cachedFile = null |
|
| 122 | 122 | ) { |
| 123 | 123 | if (!in_array($method, self::$validRequestMethods, true)) { |
| 124 | 124 | $message = sprintf('%s is not valid Http request method.', $method); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | $this->method = $method; |
| 128 | 128 | $this->requestedPath = $this->extractFolder($requestedPath, $folder); |
| 129 | - $this->defaultReturnType = ($defaultReturnType >=1 && $defaultReturnType <=7) ? $defaultReturnType : self::HTML; |
|
| 129 | + $this->defaultReturnType = ($defaultReturnType >= 1 && $defaultReturnType <= 7) ? $defaultReturnType : self::HTML; |
|
| 130 | 130 | $this->cachedFile = $cachedFile; |
| 131 | 131 | } |
| 132 | 132 | |
@@ -163,8 +163,8 @@ discard block |
||
| 163 | 163 | $requestMethods, |
| 164 | 164 | string $route, |
| 165 | 165 | $action, |
| 166 | - ?int $returnType = null, |
|
| 167 | - ?string $alias = null |
|
| 166 | + ? int $returnType = null, |
|
| 167 | + ? string $alias = null |
|
| 168 | 168 | ) : void { |
| 169 | 169 | |
| 170 | 170 | $requestMethodsGiven = is_array($requestMethods) ? (array) $requestMethods : [0 => $requestMethods]; |
@@ -202,12 +202,12 @@ discard block |
||
| 202 | 202 | * @param int|null $returnType |
| 203 | 203 | * @return int |
| 204 | 204 | */ |
| 205 | - private function determineReturnType(?int $returnType) : int |
|
| 205 | + private function determineReturnType(? int $returnType) : int |
|
| 206 | 206 | { |
| 207 | 207 | if ($returnType === null) { |
| 208 | 208 | return $this->defaultReturnType; |
| 209 | 209 | } |
| 210 | - return ($returnType >=1 && $returnType <=7) ? $returnType : self::HTML; |
|
| 210 | + return ($returnType >= 1 && $returnType <= 7) ? $returnType : self::HTML; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |