Passed
Push — master ( fd89c5...e7fa6c )
by Henri
01:26
created
src/Helper.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -2,12 +2,12 @@  discard block
 block discarded – undo
2 2
 
3 3
 namespace HnrAzevedo\Router;
4 4
 
5
-trait Helper{
5
+trait Helper {
6 6
     use CheckTrait, ControllerTrait;
7 7
     
8 8
     public function getProtocol(): string
9 9
     {
10
-        if((isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')){
10
+        if ((isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')) {
11 11
             return 'ajax';
12 12
         }
13 13
 
@@ -27,13 +27,13 @@  discard block
 block discarded – undo
27 27
     protected function import(string $path)
28 28
     {
29 29
         foreach (scandir($path) as $routeFile) {
30
-            if(pathinfo($path.DIRECTORY_SEPARATOR.$routeFile, PATHINFO_EXTENSION) === 'php'){
31
-                require_once($path. DIRECTORY_SEPARATOR .$routeFile);
30
+            if (pathinfo($path.DIRECTORY_SEPARATOR.$routeFile, PATHINFO_EXTENSION) === 'php') {
31
+                require_once($path.DIRECTORY_SEPARATOR.$routeFile);
32 32
             }
33 33
         }
34 34
     }
35 35
 
36
-    protected function ControllerForm($controller, string $method, array $values){
36
+    protected function ControllerForm($controller, string $method, array $values) {
37 37
 		$this->check_role();
38 38
         $role = ($method !== 'method') ? $method : $this->getData()['POST']['role'];
39 39
         $data = (!is_null($values)) ? json_decode($values['data']) : null;
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
         $data = $this->getData();
46 46
 
47 47
         foreach ($data['GET'] as $name => $value) {
48
-            $controll = str_replace('{'.$name.'}',$value,$controll);
48
+            $controll = str_replace('{'.$name.'}', $value, $controll);
49 49
         }
50 50
 
51 51
         $this->check_controllsettable($controll);
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
 
55 55
         $this->check_controllmethod($controll);
56 56
 
57
-        $controller = ROUTER_CONFIG['controller.namespace'].'\\'. ucfirst(explode(':',$controll)[0]);
57
+        $controller = ROUTER_CONFIG['controller.namespace'].'\\'.ucfirst(explode(':', $controll)[0]);
58 58
         $controller = new $controller();
59
-        $method = explode(':',$controll)[1];
59
+        $method = explode(':', $controll)[1];
60 60
 
61
-        if( ( $this->getProtocol() == 'form') ){
61
+        if (($this->getProtocol() == 'form')) {
62 62
             $this->ControllerForm($controller, $method, $data['POST']);
63 63
         }else {
64 64
             $controller->$method($data);
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
 
68 68
     protected function explodeRoute(bool $bar, string $url): array
69 69
     {   
70
-        return explode( '/', $bar ? substr($url, 0, -1) : $url );
70
+        return explode('/', $bar ? substr($url, 0, -1) : $url);
71 71
     }
72 72
 
73 73
     protected function toHiking($walking)
74 74
     {
75
-        if(is_string($walking)){
75
+        if (is_string($walking)) {
76 76
             $this->Controller($walking);
77 77
             return true;
78 78
         }
Please login to merge, or discard this patch.