Passed
Push — master ( 388b38...3472d9 )
by Henri
01:19
created
src/Router.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -79,23 +79,23 @@  discard block
 block discarded – undo
79 79
 
80 80
     public function set($url , $role , $protocol = null): Router
81 81
     {
82
-		$url = (substr($url,0,1) !=='/' and strlen($url) > 0) ? "/{$url}" : $url;
82
+        $url = (substr($url,0,1) !=='/' and strlen($url) > 0) ? "/{$url}" : $url;
83 83
 
84
-    	foreach($this->routers as $key => $value){
85
-    		if( md5($this->prefix . $value['url'] . $value['protocol'] ) === md5( $url . $protocol ) ){
84
+        foreach($this->routers as $key => $value){
85
+            if( md5($this->prefix . $value['url'] . $value['protocol'] ) === md5( $url . $protocol ) ){
86 86
                 throw new Exception("There is already a route with the url {$url} and with the {$protocol} protocol configured.");
87 87
             }
88
-    	}
88
+        }
89 89
 
90
-		$route = [
91
-			'url' => $this->prefix.$url,
92
-			'role' => $role,
93
-			'protocol' => $protocol,
94
-			'filters' => null,
90
+        $route = [
91
+            'url' => $this->prefix.$url,
92
+            'role' => $role,
93
+            'protocol' => $protocol,
94
+            'filters' => null,
95 95
             'group' => self::getInstance()->group
96
-		];
96
+        ];
97 97
 
98
-		$this->routers[] = $route;		
98
+        $this->routers[] = $route;		
99 99
         
100 100
         return self::getInstance();
101 101
     }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
             return $this->byName($route_name);
170 170
         }
171 171
 
172
-		$currentProtocol = $this->getProtocol();
172
+        $currentProtocol = $this->getProtocol();
173 173
 
174 174
         foreach(array_reverse($this->routers) as $r => $route){
175 175
             if(is_array($route['protocol'])){
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
                         continue;
179 179
                     }
180 180
                 }
181
-	        }else{
182
-				if($route['protocol'] !== $currentProtocol){
181
+            }else{
182
+                if($route['protocol'] !== $currentProtocol){
183 183
                     continue;
184 184
                 }
185
-			}
185
+            }
186 186
 
187
-	        $route_loop = explode(
187
+            $route_loop = explode(
188 188
                 '/',
189 189
                 (substr($route['url'],strlen($route['url'])-1,1) === '/') 
190 190
                     ? substr($route['url'], 0, -1) 
@@ -193,45 +193,45 @@  discard block
 block discarded – undo
193 193
 
194 194
             /* ONLY FOR DEBUG CONDITION */
195 195
             $route_request = $route_loop;
196
-	        /*$route_request = explode(
196
+            /*$route_request = explode(
197 197
                 '/',
198 198
                 (substr($_SERVER['REQUEST_URI'],strlen($_SERVER['REQUEST_URI'])-1,1) === '/') 
199 199
                 ? substr($_SERVER['REQUEST_URI'], 0, -1) 
200 200
                 : $_SERVER['REQUEST_URI'] 
201 201
             );*/
202 202
 
203
-	        if(count($route_loop) !== count($route_request)){
203
+            if(count($route_loop) !== count($route_request)){
204 204
                 continue;
205 205
             }
206 206
 
207
-	        for($rr = 0; $rr < count($route_loop); $rr++){
208
-	            $param = (substr($route_loop[$rr],0,1)==='{');
207
+            for($rr = 0; $rr < count($route_loop); $rr++){
208
+                $param = (substr($route_loop[$rr],0,1)==='{');
209 209
 
210
-	            if($param){
210
+                if($param){
211 211
                     $param_name = substr($route_loop[$rr],1,strlen($route_loop[$rr])-2);
212
-	                $data[$param_name] = $route_request[$rr];
213
-	            }
212
+                    $data[$param_name] = $route_request[$rr];
213
+                }
214 214
 
215
-	            if(!$param and $route_loop[$rr] !== $route_request[$rr]){
215
+                if(!$param and $route_loop[$rr] !== $route_request[$rr]){
216 216
                     continue 2;
217 217
                 }
218
-	        }
219
-
220
-	        if(!empty($route['filters'])){
221
-	            if(is_array($route['filters'])){
222
-	                foreach($route['filters'] as $filter){
223
-	                    $this->filter->filtering($filter);
224
-	                }
225
-	            }else{
226
-	                $this->filter->filtering($route['filters']);
227
-	            }
228
-	        }
218
+            }
219
+
220
+            if(!empty($route['filters'])){
221
+                if(is_array($route['filters'])){
222
+                    foreach($route['filters'] as $filter){
223
+                        $this->filter->filtering($filter);
224
+                    }
225
+                }else{
226
+                    $this->filter->filtering($route['filters']);
227
+                }
228
+            }
229 229
 
230 230
             $this->Controller($route['role']);
231
-	        return true;
232
-	    }
231
+            return true;
232
+        }
233 233
 
234
-	    throw new Exception('Page not found.',404);
234
+        throw new Exception('Page not found.',404);
235 235
     }
236 236
 
237 237
     public static function filter($filters): Router
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
     }    
320 320
 
321 321
     public function ControllerForm($controller, string $method, array $values){
322
-		if(Validator::execute($values)){
322
+        if(Validator::execute($values)){
323 323
             if(!array_key_exists('role',$this->getData()['POST'])){
324 324
                 throw new Exception('O servidor não conseguiu identificar a finalidade deste formulário.');
325 325
             }
Please login to merge, or discard this patch.
Braces   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
                 foreach($route['filters'] as $filter){
155 155
                     $this->filter->filtering($filter);
156 156
                 }
157
-            }else{
157
+            } else{
158 158
                 $this->filter->filtering($route['filters']);
159 159
             }
160 160
         }
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
                         continue;
179 179
                     }
180 180
                 }
181
-	        }else{
181
+	        } else{
182 182
 				if($route['protocol'] !== $currentProtocol){
183 183
                     continue;
184 184
                 }
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	                foreach($route['filters'] as $filter){
223 223
 	                    $this->filter->filtering($filter);
224 224
 	                }
225
-	            }else{
225
+	            } else{
226 226
 	                $this->filter->filtering($route['filters']);
227 227
 	            }
228 228
 	        }
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
                 }
247 247
             }
248 248
             
249
-        }else{
249
+        } else{
250 250
             $currentRoute = self::getInstance()->addFilter(end(self::getInstance()->routers),$filters);
251 251
             self::getInstance()->routers[count(self::getInstance()->routers)-1] = $currentRoute;
252 252
         }
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
             foreach ($route['filters'] as $key => $value) {
268 268
                 $filters[] = $value;
269 269
             }
270
-        }else{
270
+        } else{
271 271
             $filters[] = $route['filters'];
272 272
         }
273 273
 
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 
314 314
         if($isform){
315 315
             $this->ControllerForm($controller, $method, $data['POST']);
316
-        }else {
316
+        } else {
317 317
             $controller->$method($data);
318 318
         }
319 319
     }    
Please login to merge, or discard this patch.