Passed
Push — master ( 3b49e1...f70663 )
by Henri
01:28
created
src/Router.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace HnrAzevedo\Router;
6 6
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     {
35 35
         $route = self::getInstance()->inSave();
36 36
 
37
-        if(null === $value){
37
+        if (null === $value) {
38 38
             return (isset($route['attributes'][$name])) ? $route['attributes'][$name] : null;
39 39
         }
40 40
 
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
     public static function groupAttribute(string $name, $value = null, ?array $excepts = []): Router
48 48
     {
49 49
         $group = self::getInstance()->inSave()['group'];
50
-        foreach(self::getInstance()->getRoutes() as $r => $route){
51
-            if($route['group'] !== $group || in_array($route['name'], $excepts)){
50
+        foreach (self::getInstance()->getRoutes() as $r => $route) {
51
+            if ($route['group'] !== $group || in_array($route['name'], $excepts)) {
52 52
                 continue;
53 53
             }
54 54
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     public static function group(string $prefix, \Closure $closure): Router
62 62
     {
63 63
         $id = sha1(date('d/m/Y h:m:i'));
64
-        while(array_key_exists($id, self::getInstance()->groupsName)){
64
+        while (array_key_exists($id, self::getInstance()->groupsName)) {
65 65
             $id = sha1(date('d/m/Y h:m:i').$id);
66 66
         }
67 67
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     {
83 83
         self::getInstance()->loaded = true;
84 84
 
85
-        if(null !== $name){
85
+        if (null !== $name) {
86 86
             return self::getInstance()->loadByName($name);
87 87
         }
88 88
 
@@ -90,15 +90,15 @@  discard block
 block discarded – undo
90 90
 
91 91
         $requestMethod = (isset($_REQUEST['REQUEST_METHOD'])) ? $_REQUEST['REQUEST_METHOD'] : $_SERVER['REQUEST_METHOD'];
92 92
 
93
-        foreach(self::getInstance()->getRoutes() as $r => $route){
93
+        foreach (self::getInstance()->getRoutes() as $r => $route) {
94 94
             self::getInstance()->currentRoute = $route;
95 95
             self::getInstance()->currentRoute['name'] = $r;
96 96
 
97
-            try{
97
+            try {
98 98
                 self::getInstance()->checkMethod($route, $requestMethod);
99 99
                 self::getInstance()->checkData($route, (new Uri($_SERVER['REQUEST_URI']))->getPath());
100 100
                 return self::getInstance();
101
-            }catch(\Exception $er){
101
+            }catch (\Exception $er) {
102 102
                 continue;
103 103
             }
104 104
         }
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
     public static function run(?string $name = null): RouterInterface
114 114
     {
115
-        if(!self::getInstance()->loaded){
115
+        if (!self::getInstance()->loaded) {
116 116
             self::getInstance()->load($name);
117 117
         }
118 118
 
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
 
123 123
         self::getInstance()->executeBefore();
124 124
         
125
-        try{
125
+        try {
126 126
             $action = unserialize(self::getInstance()->current()['action']);
127
-            self::getInstance()->executeRouteAction( (is_string($action)) ? $action : $action->getClosure()  );
128
-        }catch(\Exception $er){
127
+            self::getInstance()->executeRouteAction((is_string($action)) ? $action : $action->getClosure());
128
+        }catch (\Exception $er) {
129 129
             self::getInstance()->error = $er;
130 130
         }
131 131
         
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 
139 139
     private function checkError(): void
140 140
     {
141
-        if(isset($this->error)){
141
+        if (isset($this->error)) {
142 142
             throw $this->error;
143 143
         }
144 144
     }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 
153 153
     public static function routes(?array $routes = null): array
154 154
     {
155
-        if(null !== $routes){
155
+        if (null !== $routes) {
156 156
             self::getInstance()->setRoutes($routes);
157 157
             self::getInstance()->sortRoutes();
158 158
         }
Please login to merge, or discard this patch.