Passed
Push — master ( c93993...d9db77 )
by Nícollas
01:38
created
src/Router/RouteManager.php 2 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -88,7 +88,9 @@  discard block
 block discarded – undo
88 88
      */
89 89
     private function compileGroupData()
90 90
     {
91
-        if(!is_a($this->group, RouteGroups::class)) return null;
91
+        if(!is_a($this->group, RouteGroups::class)) {
92
+            return null;
93
+        }
92 94
 
93 95
         $this->defaultName = $this->name = $this->group->name;
94 96
         $this->defaultNamespace = $this->group->namespace;
@@ -144,7 +146,9 @@  discard block
 block discarded – undo
144 146
      */
145 147
     protected function getWhere(String $param): ?String
146 148
     {
147
-        if (!isset($this->where[$param])) return null;
149
+        if (!isset($this->where[$param])) {
150
+            return null;
151
+        }
148 152
 
149 153
         return $this->where[$param];
150 154
     }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -89,12 +89,12 @@  discard block
 block discarded – undo
89 89
      */
90 90
     private function compileGroupData()
91 91
     {
92
-        if(!is_a($this->group, RouteGroups::class)) return null;
92
+        if (!is_a($this->group, RouteGroups::class)) return null;
93 93
 
94 94
         $this->defaultName = $this->name = $this->group->name;
95 95
         $this->defaultNamespace = $this->group->namespace;
96 96
 
97
-        if(is_a($this->group->middlewares, MiddlewareCollection::class)) {
97
+        if (is_a($this->group->middlewares, MiddlewareCollection::class)) {
98 98
             $this->middleware = $this->group->middlewares;
99 99
         }
100 100
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
         preg_match_all("~\{\s*([a-zA-Z_][a-zA-Z0-9_-]*)\??\}~x", $route, $params, PREG_SET_ORDER);
163 163
 
164 164
         if ($wordOnly) {
165
-            $params = array_map(function ($param) {
165
+            $params = array_map(function($param) {
166 166
                 return $param[1];
167 167
             }, $params);
168 168
         }
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
      */
228 228
     private function resolveHandler(String $handler)
229 229
     {
230
-        if(!$this->defaultNamespace) {
230
+        if (!$this->defaultNamespace) {
231 231
             return $handler;
232 232
         }
233 233
 
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
      */
330 330
     public function middleware($middleware): RouteManager
331 331
     {
332
-        if(is_a($this->middleware, MiddlewareCollection::class)) {
332
+        if (is_a($this->middleware, MiddlewareCollection::class)) {
333 333
             $middleware = $this->middleware->storeMiddleware($middleware);
334 334
         }
335 335
 
Please login to merge, or discard this patch.
src/Router/RouteCollection.php 2 patches
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -152,7 +152,9 @@  discard block
 block discarded – undo
152 152
             $routes = $this->routes[$httpMethod];
153 153
         }
154 154
 
155
-        if (!is_array($routes)) return null;
155
+        if (!is_array($routes)) {
156
+            return null;
157
+        }
156 158
 
157 159
         $soughtRoute = null;
158 160
 
@@ -323,7 +325,9 @@  discard block
 block discarded – undo
323 325
      */
324 326
     protected function getHttpCode(String $slug)
325 327
     {
326
-        if (!isset($this->httpCodes[$slug])) return null;
328
+        if (!isset($this->httpCodes[$slug])) {
329
+            return null;
330
+        }
327 331
 
328 332
         return $this->httpCodes[$slug];
329 333
     }
@@ -353,7 +357,9 @@  discard block
 block discarded – undo
353 357
     {
354 358
         $method = strtoupper($method);
355 359
 
356
-        if (!isset($this->routes[$method])) return null;
360
+        if (!isset($this->routes[$method])) {
361
+            return null;
362
+        }
357 363
 
358 364
         return $this->routes[$method];
359 365
     }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@
 block discarded – undo
102 102
 
103 103
         $methods = array_map("strtoupper", $methods);
104 104
 
105
-        array_map(function ($method) use ($uri, $callback) {
105
+        array_map(function($method) use ($uri, $callback) {
106 106
             $this->routes[$method][$uri] = $this->addRouter($uri, $callback);
107 107
         }, $methods);
108 108
     }
Please login to merge, or discard this patch.
src/Router/Middlewares/MiddlewareCollection.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -139,7 +139,9 @@
 block discarded – undo
139 139
     protected function instanceMiddleware($middleware)
140 140
     {
141 141
         if (!preg_match("/\\\/", $middleware)) {
142
-            if (!$middlewareClass = $this->getByAlias($middleware)) return;
142
+            if (!$middlewareClass = $this->getByAlias($middleware)) {
143
+                return;
144
+            }
143 145
 
144 146
             return new $middlewareClass();
145 147
         }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
             $mid = trim(rtrim($mid));
114 114
             
115 115
             if (is_string($currentMiddleware)) {
116
-                $currentMiddleware = rtrim(trim(preg_replace("/\s?".$mid."\,?/", "", $currentMiddleware), ' '), ',');
116
+                $currentMiddleware = rtrim(trim(preg_replace("/\s?" . $mid . "\,?/", "", $currentMiddleware), ' '), ',');
117 117
             } else {
118 118
                 $currentMiddleware = array_values(array_filter($currentMiddleware, fn($middleware) => $middleware != $mid));
119 119
             }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
     {
166 166
         $middlewares = $this->middlewares;
167 167
 
168
-        if(is_string($middlewares)) {
168
+        if (is_string($middlewares)) {
169 169
             $middlewares = explode(',', $middlewares);
170 170
         }
171 171
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
      */
185 185
     protected function resolveNestedMiddleware(Array $middlewares): void
186 186
     {
187
-        $this->queue = array_map(function ($middleware) {
187
+        $this->queue = array_map(function($middleware) {
188 188
             $middleware = trim(rtrim($middleware));
189 189
 
190 190
             return $this->instanceMiddleware($middleware);
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 
282 282
         return $currentMiddleware->handle(
283 283
             $this->currentRequest,
284
-            fn () => $this->next()
284
+            fn() => $this->next()
285 285
         );
286 286
     }
287 287
 }
Please login to merge, or discard this patch.
src/Helpers/helpers.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 
3 3
 use MinasRouter\Helpers\Functions;
4 4
 
5
-if (! function_exists('router')) {
5
+if (!function_exists('router')) {
6 6
     /**
7 7
      * Method responsible for returning a
8 8
      * new instance of Functions.
Please login to merge, or discard this patch.
src/Http/Request.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -295,7 +295,7 @@
 block discarded – undo
295 295
         $allWithExcession = $this->data;
296 296
         $except = explode(',', $except);
297 297
 
298
-        $except = array_map(function ($excession) {
298
+        $except = array_map(function($excession) {
299 299
             return trim(rtrim($excession));
300 300
         }, $except);
301 301
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -69,7 +69,9 @@  discard block
 block discarded – undo
69 69
     {
70 70
         $parsedRoute = parse_url($this->fullUrl ?? "/");
71 71
 
72
-        if (empty($data)) return $parsedRoute;
72
+        if (empty($data)) {
73
+            return $parsedRoute;
74
+        }
73 75
 
74 76
         if (isset($parsedRoute[$data])) {
75 77
             return $parsedRoute[$data];
@@ -101,7 +103,9 @@  discard block
 block discarded – undo
101 103
     {
102 104
         $path = $this->getParsedRoute();
103 105
 
104
-        if (!$path) return null;
106
+        if (!$path) {
107
+            return null;
108
+        }
105 109
 
106 110
         return "{$path['scheme']}://{$path['host']}{$this->path()}";
107 111
     }
@@ -295,7 +299,9 @@  discard block
 block discarded – undo
295 299
         }, $except);
296 300
 
297 301
         foreach ($except as $excession) {
298
-            if (!isset($this->data[$excession])) return;
302
+            if (!isset($this->data[$excession])) {
303
+                return;
304
+            }
299 305
 
300 306
             unset($allWithExcession[$excession]);
301 307
         }
@@ -371,7 +377,9 @@  discard block
 block discarded – undo
371 377
     {
372 378
         $authorizationHeader = $this->header('Authorization');
373 379
 
374
-        if (!$authorizationHeader) return null;
380
+        if (!$authorizationHeader) {
381
+            return null;
382
+        }
375 383
 
376 384
         if (preg_match("/^Bearer\s(.*)+$/", $authorizationHeader, $found)) {
377 385
             return $authorizationHeader;
Please login to merge, or discard this patch.
src/Helpers/Functions.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     {
34 34
         $params = (array) func_get_arg(1);
35 35
 
36
-        if(!$router = $this->get($routerName)) {
36
+        if (!$router = $this->get($routerName)) {
37 37
             return null;
38 38
         }
39 39
 
@@ -41,15 +41,15 @@  discard block
 block discarded – undo
41 41
 
42 42
         preg_match_all("/{\w+\??}/", $originalRoute, $matches);
43 43
   
44
-        if(empty($matches[0])) {
44
+        if (empty($matches[0])) {
45 45
             return $originalRoute;
46 46
         }
47 47
 
48
-        if(count($matches[0]) != count($params)) {
48
+        if (count($matches[0]) != count($params)) {
49 49
             return null;
50 50
         }
51 51
 
52
-        foreach($matches[0] as $index => $match) {
52
+        foreach ($matches[0] as $index => $match) {
53 53
             $paramForReplace = isset($params[$index]) ? $params[$index] : 'undefined';
54 54
 
55 55
             $originalRoute = str_replace($match, $paramForReplace, $originalRoute);
Please login to merge, or discard this patch.
example/app/Models/User.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 
20 20
     public static function userData(Int $id)
21 21
     {
22
-        if(!isset(self::$names[$id])) {
22
+        if (!isset(self::$names[$id])) {
23 23
             return [
24 24
                 'error' => 404,
25 25
                 'message' => 'User not found'
Please login to merge, or discard this patch.
src/Traits/RouteManagerUtils.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      */
23 23
     public function where(array $matches)
24 24
     {
25
-        array_map(function ($key, $value) {
25
+        array_map(function($key, $value) {
26 26
             $this->setWhereData($key, $value);
27 27
         }, array_keys($matches), $matches);
28 28
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      */
102 102
     public function name(String $name, Bool $ignoreDefault = false)
103 103
     {
104
-        if($ignoreDefault) {
104
+        if ($ignoreDefault) {
105 105
             $this->setName($name);
106 106
         } else {
107 107
             $this->setName($this->getDefaultName() . $name);
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public function withoutMiddleware($middleware)
131 131
     {
132
-        if(!is_a($this->middleware, MiddlewareCollection::class)) {
132
+        if (!is_a($this->middleware, MiddlewareCollection::class)) {
133 133
             return;
134 134
         }
135 135
 
Please login to merge, or discard this patch.