Passed
Push — master ( be4e4a...469584 )
by Mehmet
02:53
created
src/Router.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -160,6 +160,7 @@
 block discarded – undo
160 160
      * @param  string                      $action
161 161
      * @param  int                         $returnType
162 162
      * @param  string                      $alias
163
+     * @param string $requestMethods
163 164
      * @throws InvalidArgumentException
164 165
      * @throws UnexpectedValueException
165 166
      */
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,6 @@
 block discarded – undo
14 14
 
15 15
 namespace Selami;
16 16
 
17
-use FastRoute;
18 17
 use InvalidArgumentException;
19 18
 use UnexpectedValueException;
20 19
 use RuntimeException;
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     /**
Please login to merge, or discard this patch.
src/Dispatcher.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -38,6 +38,9 @@  discard block
 block discarded – undo
38 38
     private $routerClosures = [];
39 39
 
40 40
 
41
+    /**
42
+     * @param null|string $cachedFile
43
+     */
41 44
     public function __construct(array $routes, int $defaultReturnType, ?string  $cachedFile)
42 45
     {
43 46
         $this->routes = $routes;
@@ -69,6 +72,9 @@  discard block
 block discarded – undo
69 72
         return new FastRoute\Dispatcher\GroupCountBased($routeCollector->getData());
70 73
     }
71 74
 
75
+    /**
76
+     * @param FastRoute\RouteCollector $routeCollector
77
+     */
72 78
     private function createCachedRoute($routeCollector) : void
73 79
     {
74 80
         if ($this->cachedFile !== null && !file_exists($this->cachedFile)) {
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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++;
Please login to merge, or discard this patch.