Passed
Branch v2-dev (ac4b1e)
by Henri
01:33
created
src/WhereTrait.php 1 patch
Spacing   +17 added lines, -17 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
 
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
     public static function groupWhere(array $wheres, array $excepts): Router
22 22
     {
23 23
         $group = self::getInstance()->inSave()['group'];
24
-        foreach(self::getInstance()->getRoutes() as $r => $route){
25
-            if($route['group'] !== $group || in_array($route['name'], $excepts)){
24
+        foreach (self::getInstance()->getRoutes() as $r => $route) {
25
+            if ($route['group'] !== $group || in_array($route['name'], $excepts)) {
26 26
                 continue;
27 27
             }
28 28
 
@@ -47,30 +47,30 @@  discard block
 block discarded – undo
47 47
         unset($uriPath[0]);
48 48
 
49 49
         $corretRoute = true;
50
-        foreach ($routePath as $r => $routeFrag){
50
+        foreach ($routePath as $r => $routeFrag) {
51 51
             $where = is_array($route['where']) ? $route['where'] : [];
52 52
             $routeFrag = $this->replaceParam($where, $routeFrag, $uriPath[$r]);
53 53
 
54
-            if($routeFrag !== $uriPath[$r]){
54
+            if ($routeFrag !== $uriPath[$r]) {
55 55
                 $corretRoute = false;
56 56
             }
57 57
         }
58 58
 
59
-        if(!$corretRoute){
59
+        if (!$corretRoute) {
60 60
             throw new \Exception('continue');
61 61
         }
62 62
 
63
-        $_REQUEST = array_merge($_REQUEST,$this->parameters);
63
+        $_REQUEST = array_merge($_REQUEST, $this->parameters);
64 64
     }
65 65
 
66 66
     private function replaceParam(array $where, string $ref, string $value): string
67 67
     {
68
-        if(((substr($ref,0,1) === '{') && (substr($ref,strlen($ref)-1) === '}'))) {
69
-            $this->parameters[str_replace(['{:','{','}'],'',$ref)] = $value;
68
+        if (((substr($ref, 0, 1) === '{') && (substr($ref, strlen($ref)-1) === '}'))) {
69
+            $this->parameters[str_replace(['{:', '{', '}'], '', $ref)] = $value;
70 70
 
71
-            $this->checkValueRequire($ref,$value);
71
+            $this->checkValueRequire($ref, $value);
72 72
 
73
-            if(array_key_exists(str_replace(['{:','{','}'],'',$ref),$where)){
73
+            if (array_key_exists(str_replace(['{:', '{', '}'], '', $ref), $where)) {
74 74
                 $this->matchParam($where, $ref, $value);
75 75
             }
76 76
 
@@ -81,25 +81,25 @@  discard block
 block discarded – undo
81 81
 
82 82
     private function checkValueRequire(string $ref, string $value): void
83 83
     {
84
-        if(substr($ref,0,2) !== '{:' && strlen($value) === 0){
84
+        if (substr($ref, 0, 2) !== '{:' && strlen($value) === 0) {
85 85
             throw new \Exception('continue');
86 86
         }
87 87
     }
88 88
 
89 89
     private function checkCount(string $routePath, string $uriPath): void
90 90
     {
91
-        $countRequest = substr_count($uriPath,'/') - substr_count($routePath,'{:');
92
-        $countRoute = substr_count($routePath,'/') - substr_count($routePath,'{:');
91
+        $countRequest = substr_count($uriPath, '/')-substr_count($routePath, '{:');
92
+        $countRoute = substr_count($routePath, '/')-substr_count($routePath, '{:');
93 93
 
94
-        if($countRequest !== $countRoute){
94
+        if ($countRequest !== $countRoute) {
95 95
             throw new \Exception('continue');
96 96
         }
97 97
     }
98 98
 
99 99
     private function matchParam(array $where, string $ref, string $value): void
100 100
     {
101
-        if(substr($ref,0,2) === '{' || $value !== ''){
102
-            if(!preg_match("/^{$where[str_replace(['{:','{','}'],'',$ref)]}$/",$value)){
101
+        if (substr($ref, 0, 2) === '{' || $value !== '') {
102
+            if (!preg_match("/^{$where[str_replace(['{:', '{', '}'], '', $ref)]}$/", $value)) {
103 103
                 throw new \Exception('continue');
104 104
             }
105 105
         }
Please login to merge, or discard this patch.
src/RunInTrait.php 1 patch
Spacing   +29 added lines, -29 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
 
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
     protected function getState(string $state, bool $except = false)
19 19
     {
20
-        if($state === 'before'){
20
+        if ($state === 'before') {
21 21
             return ($except) ? $this->beforeExcepts : $this->beforeAll;
22 22
         }
23 23
 
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 
27 27
     protected function setState(string $state, $settable, bool $except = false): bool
28 28
     {
29
-        if($state === 'before'){
30
-            if($except){
29
+        if ($state === 'before') {
30
+            if ($except) {
31 31
                 $this->beforeExcepts = $settable;
32 32
                 return true;
33 33
             }
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
             return true;
37 37
         }
38 38
 
39
-        if($except){
39
+        if ($except) {
40 40
             $this->afterExcepts = $settable;
41 41
             return true;
42 42
         }
@@ -47,24 +47,24 @@  discard block
 block discarded – undo
47 47
 
48 48
     public static function before($closure): RouterInterface
49 49
     {
50
-        return self::addInRoute('before',$closure);
50
+        return self::addInRoute('before', $closure);
51 51
     }
52 52
 
53 53
     public static function after($closure): RouterInterface
54 54
     {
55
-        return self::addInRoute('after',$closure);
55
+        return self::addInRoute('after', $closure);
56 56
     }
57 57
 
58 58
     public static function beforeAll($closure, $excepts): RouterInterface
59 59
     {
60
-        self::getInstance()->setState('before', (is_array($excepts)) ? $excepts : [ $excepts ] ,true);
60
+        self::getInstance()->setState('before', (is_array($excepts)) ? $excepts : [$excepts], true);
61 61
         self::getInstance()->setState('before', $closure, false);
62 62
         return self::getInstance();
63 63
     }
64 64
 
65 65
     public static function afterAll($closure, $excepts): RouterInterface
66 66
     {
67
-        self::getInstance()->setState('after', (is_array($excepts)) ? $excepts : [ $excepts ] ,true);
67
+        self::getInstance()->setState('after', (is_array($excepts)) ? $excepts : [$excepts], true);
68 68
         self::getInstance()->setState('after', $closure, false);
69 69
         return self::getInstance();
70 70
     }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
     protected function executeRouteAction($action): bool
83 83
     {
84
-        if(is_callable($action)){        
84
+        if (is_callable($action)) {        
85 85
             call_user_func_array($action, $_REQUEST);
86 86
             return true;
87 87
         }
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
     private static function addInRoutes(string $state, $closure, $excepts): RouterInterface
94 94
     {
95 95
         self::getInstance()->isInPseudGroup();
96
-        $excepts = (is_array($excepts)) ? $excepts : [ $excepts ];
96
+        $excepts = (is_array($excepts)) ? $excepts : [$excepts];
97 97
         $group = self::getInstance()->inSave()['group'];
98 98
 
99
-        foreach(self::getInstance()->getRoutes() as $r => $route){
100
-            if($route['group'] === $group && !in_array($r,$excepts)){
101
-                self::getInstance()->getRoutes()[$r][$state] = (is_null($route[$state])) ? [ $closure ] : array_merge($route[$state], [ $closure ]); 
99
+        foreach (self::getInstance()->getRoutes() as $r => $route) {
100
+            if ($route['group'] === $group && !in_array($r, $excepts)) {
101
+                self::getInstance()->getRoutes()[$r][$state] = (is_null($route[$state])) ? [$closure] : array_merge($route[$state], [$closure]); 
102 102
             }
103 103
         }
104 104
 
@@ -108,14 +108,14 @@  discard block
 block discarded – undo
108 108
     private static function addInRoute(string $state, $closure): RouterInterface
109 109
     {
110 110
         $route = self::getInstance()->inSave();
111
-        $route[$state] = (!is_null($route[$state])) ? [ $closure ] : array_merge($route[$state], [ $closure ]);
112
-        self::updateRoute($route,array_key_last(self::getInstance()->getRoutes()));
111
+        $route[$state] = (!is_null($route[$state])) ? [$closure] : array_merge($route[$state], [$closure]);
112
+        self::updateRoute($route, array_key_last(self::getInstance()->getRoutes()));
113 113
         return self::getInstance();
114 114
     }
115 115
 
116 116
     protected function executeBefore(): void
117 117
     {
118
-        if(!in_array($this->currentName(), (array) $this->getState('before', true))){
118
+        if (!in_array($this->currentName(), (array) $this->getState('before', true))) {
119 119
             ($this->getState('before', false))();
120 120
         }
121 121
 
@@ -126,15 +126,15 @@  discard block
 block discarded – undo
126 126
     {
127 127
         $this->executeState('after');
128 128
 
129
-        if(!in_array($this->currentName(), (array) $this->getState('after', true))){
129
+        if (!in_array($this->currentName(), (array) $this->getState('after', true))) {
130 130
             ($this->getState('after', false))();
131 131
         }
132 132
     }
133 133
 
134 134
     private function executeState(string $stage): void
135 135
     {
136
-        foreach($this->current()[$stage] as $state){
137
-            if(is_callable($state)){
136
+        foreach ($this->current()[$stage] as $state) {
137
+            if (is_callable($state)) {
138 138
                 $state();
139 139
                 continue;
140 140
             }
@@ -145,31 +145,31 @@  discard block
 block discarded – undo
145 145
 
146 146
     private function executeController(string $controllerMeth): void
147 147
     {
148
-        if(count(explode('@',$controllerMeth)) !== 2){
148
+        if (count(explode('@', $controllerMeth)) !== 2) {
149 149
             $path = urldecode($this->current()['uri']->getPath());
150 150
             throw new \RuntimeException("Misconfigured route action ({$path})");
151 151
         }
152 152
 
153
-        $controller = (string) explode('@',$controllerMeth)[0];
154
-        $method = (string) explode('@',$controllerMeth)[1];
153
+        $controller = (string) explode('@', $controllerMeth)[0];
154
+        $method = (string) explode('@', $controllerMeth)[1];
155 155
 
156 156
         $this->checkControllerMeth($controllerMeth);
157 157
 
158
-        call_user_func_array([(new $controller()),$method], $_REQUEST);
158
+        call_user_func_array([(new $controller()), $method], $_REQUEST);
159 159
     }
160 160
 
161 161
     private function checkControllerMeth(string $controllerMeth): void
162 162
     {
163
-        $routeURI = str_replace(['{:','{','}'],'',urldecode($this->current()['uri']->getPath()));
163
+        $routeURI = str_replace(['{:', '{', '}'], '', urldecode($this->current()['uri']->getPath()));
164 164
 
165
-        $controller = (string) explode('@',$controllerMeth)[0];
166
-        $method = (string) explode('@',$controllerMeth)[1];
165
+        $controller = (string) explode('@', $controllerMeth)[0];
166
+        $method = (string) explode('@', $controllerMeth)[1];
167 167
 
168
-        if(!class_exists($controller)){
168
+        if (!class_exists($controller)) {
169 169
             throw new \RuntimeException("Controller not found in route URI {$routeURI}");
170 170
         }
171 171
 
172
-        if(!method_exists($controller, $method)){
172
+        if (!method_exists($controller, $method)) {
173 173
             throw new \RuntimeException("Method {$method} not found in controller {$controller} in route URI {$routeURI}");
174 174
         }
175 175
         
Please login to merge, or discard this patch.
src/Router.php 2 patches
Spacing   +9 added lines, -9 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
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     public static function group(string $prefix, \Closure $closure): Router
34 34
     {
35 35
         $id = sha1(date('d/m/Y h:m:i'));
36
-        while(array_key_exists($id, self::getInstance()->groupsName)){
36
+        while (array_key_exists($id, self::getInstance()->groupsName)) {
37 37
             $id = sha1(date('d/m/Y h:m:i').$id);
38 38
         }
39 39
 
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
         self::getInstance()->loaded = true;
56 56
         self::getInstance()->sortRoutes();
57 57
 
58
-        foreach(self::getInstance()->getRoutes() as $r => $route){
58
+        foreach (self::getInstance()->getRoutes() as $r => $route) {
59 59
             self::getInstance()->currentRoute = $route;
60 60
             self::getInstance()->currentRoute['name'] = $r;
61 61
 
62
-            try{
62
+            try {
63 63
                 self::getInstance()->checkMethod($route, $_SERVER['REQUEST_METHOD']);
64 64
                 self::getInstance()->checkData($route, (new Uri($_SERVER['REQUEST_URI']))->getPath());
65 65
                 return self::getInstance();
66
-            }catch(\Exception $er){
66
+            }catch (\Exception $er) {
67 67
                 continue;
68 68
             }
69 69
         }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
     public static function run(): RouterInterface
79 79
     {
80
-        if(!self::getInstance()->loaded){
80
+        if (!self::getInstance()->loaded) {
81 81
             self::getInstance()->load();
82 82
         }
83 83
 
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
 
88 88
         self::getInstance()->executeBefore();
89 89
         
90
-        try{
90
+        try {
91 91
             self::getInstance()->executeRouteAction(self::getInstance()->current()['action']);
92
-        }catch(\Exception $er){
92
+        }catch (\Exception $er) {
93 93
             self::getInstance()->error = $er;
94 94
         }
95 95
         
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 
103 103
     private function checkError(): void
104 104
     {
105
-        if(isset($this->error)){
105
+        if (isset($this->error)) {
106 106
             throw $this->error;
107 107
         }
108 108
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
                 self::getInstance()->checkMethod($route, $_SERVER['REQUEST_METHOD']);
64 64
                 self::getInstance()->checkData($route, (new Uri($_SERVER['REQUEST_URI']))->getPath());
65 65
                 return self::getInstance();
66
-            }catch(\Exception $er){
66
+            } catch(\Exception $er){
67 67
                 continue;
68 68
             }
69 69
         }
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
         
90 90
         try{
91 91
             self::getInstance()->executeRouteAction(self::getInstance()->current()['action']);
92
-        }catch(\Exception $er){
92
+        } catch(\Exception $er){
93 93
             self::getInstance()->error = $er;
94 94
         }
95 95
         
Please login to merge, or discard this patch.
src/MiddlewareTrait.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
 
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 
21 21
     public static function globalMiddlewares(array $middlewares): RouterInterface
22 22
     {
23
-        foreach($middlewares as $middleware){
24
-            if(!class_exists($middleware)){
23
+        foreach ($middlewares as $middleware) {
24
+            if (!class_exists($middleware)) {
25 25
                 throw new \RuntimeException("Middleware class {$middleware} not exists");
26 26
             }
27 27
         }
@@ -37,25 +37,25 @@  discard block
 block discarded – undo
37 37
     public static function middleware(array $middlewares): RouterInterface
38 38
     {
39 39
         $route = self::getInstance()->inSave();
40
-        $route['middlewares'] = (is_array($route['middlewares'])) ? array_merge($route['middlewares'],$middlewares) : $middlewares;
41
-        self::getInstance()->updateRoute($route,array_key_last(self::getInstance()->getRoutes()));
40
+        $route['middlewares'] = (is_array($route['middlewares'])) ? array_merge($route['middlewares'], $middlewares) : $middlewares;
41
+        self::getInstance()->updateRoute($route, array_key_last(self::getInstance()->getRoutes()));
42 42
         return self::getInstance();
43 43
     }
44 44
 
45 45
     public static function groupMiddlewares(array $middlewares, array $excepts): RouterInterface
46 46
     {
47
-        $middlewares = (is_array($middlewares)) ? $middlewares : [ $middlewares ];
47
+        $middlewares = (is_array($middlewares)) ? $middlewares : [$middlewares];
48 48
 
49 49
 
50 50
         $route = self::getInstance()->inSave();
51
-        $route['middlewares'] = (is_array($route['middlewares'])) ? array_merge($route['middlewares'],$middlewares) : $middlewares;
52
-        self::getInstance()->updateRoute($route,array_key_last(self::getInstance()->getRoutes()));
51
+        $route['middlewares'] = (is_array($route['middlewares'])) ? array_merge($route['middlewares'], $middlewares) : $middlewares;
52
+        self::getInstance()->updateRoute($route, array_key_last(self::getInstance()->getRoutes()));
53 53
         return self::getInstance();
54 54
     }
55 55
 
56 56
     private static function existMiddleware(string $name): void
57 57
     {
58
-        if(!class_exists($name) && !array_key_exists($name,self::$globalMiddlewares)){
58
+        if (!class_exists($name) && !array_key_exists($name, self::$globalMiddlewares)) {
59 59
             throw new \RuntimeException("Middleware {$name} does not exist");
60 60
         }
61 61
     }
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
     {
65 65
         $factory = new Factory();
66 66
 
67
-        $this->serverRequest = (!isset($this->serverRequest)) ? $factory->createServerRequest($_SERVER['REQUEST_METHOD'], $this->current()['uri'],['route' => $this->current()]) : $this->serverRequest;
67
+        $this->serverRequest = (!isset($this->serverRequest)) ? $factory->createServerRequest($_SERVER['REQUEST_METHOD'], $this->current()['uri'], ['route' => $this->current()]) : $this->serverRequest;
68 68
         
69
-        foreach ($this->current()['middlewares'] as $middleware){
69
+        foreach ($this->current()['middlewares'] as $middleware) {
70 70
             $this->currentMiddlewares[] = (class_exists($middleware)) ? new $middleware() : new $this->globalMiddlewares[$middleware]();
71 71
         }
72 72
 
@@ -81,20 +81,20 @@  discard block
 block discarded – undo
81 81
 
82 82
     public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
83 83
     {
84
-        if(!$this->getInstance()->loaded){
84
+        if (!$this->getInstance()->loaded) {
85 85
             $this->getInstance()->load();
86 86
         }
87 87
 
88 88
         $route = $this->getInstance()->current();
89
-        if(!empty($route)){
90
-            $route['action'] = function(){
89
+        if (!empty($route)) {
90
+            $route['action'] = function() {
91 91
                 $this->getInstance()->executeBefore();
92 92
                 $this->getInstance()->executeRouteAction($this->getInstance()->current()['action']);
93 93
                 $this->getInstance()->executeAfter();
94 94
             };
95 95
         }
96 96
 
97
-        return $this->next($handler)->handle($request->withAttribute('route',$route));
97
+        return $this->next($handler)->handle($request->withAttribute('route', $route));
98 98
     }
99 99
 
100 100
     private function next(RequestHandlerInterface $defaultHandler): RequestHandlerInterface
Please login to merge, or discard this patch.
src/DefinitionsTrait.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
         }
67 67
 
68 68
         $routes[$index] = [
69
-			'uri' => new Uri(self::getInstance()->getHost().self::getInstance()->getPrefix().$uri),
70
-			'action' => $closure,
71
-			'method' => strtoupper($method),
69
+            'uri' => new Uri(self::getInstance()->getHost().self::getInstance()->getPrefix().$uri),
70
+            'action' => $closure,
71
+            'method' => strtoupper($method),
72 72
             'middlewares' => [],
73 73
             'where' => [],
74 74
             'before' => [],
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
     private static function checkDuplicity(string $uri, string $method): void
87 87
     {
88 88
         foreach(self::getInstance()->getRoutes() as $route){
89
-    		if( md5($route['uri'].$route['method']) === md5($uri.$method) ){
89
+            if( md5($route['uri'].$route['method']) === md5($uri.$method) ){
90 90
                 throw new \RuntimeException("There is already a route with the URI {$uri} and with the {$method} METHOD configured.");
91 91
             }
92 92
         }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 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
 
@@ -12,32 +12,32 @@  discard block
 block discarded – undo
12 12
     
13 13
     public static function get(string $uri, $closure): RouterInterface
14 14
     {
15
-        return self::set('get',$uri,$closure);
15
+        return self::set('get', $uri, $closure);
16 16
     }
17 17
 
18 18
     public static function post(string $uri, $closure): RouterInterface
19 19
     {
20
-        return self::set('post',$uri,$closure);
20
+        return self::set('post', $uri, $closure);
21 21
     }
22 22
 
23 23
     public static function ajax(string $uri, $closure): RouterInterface
24 24
     {
25
-        return self::set('ajax',$uri,$closure);
25
+        return self::set('ajax', $uri, $closure);
26 26
     }
27 27
 
28 28
     public static function delete(string $uri, $closure): RouterInterface
29 29
     {
30
-        return self::set('delete',$uri,$closure);
30
+        return self::set('delete', $uri, $closure);
31 31
     }
32 32
 
33 33
     public static function put(string $uri, $closure): RouterInterface
34 34
     {
35
-        return self::set('put',$uri,$closure);
35
+        return self::set('put', $uri, $closure);
36 36
     }
37 37
 
38 38
     public static function patch(string $uri, $closure): RouterInterface
39 39
     {
40
-        return self::set('patch',$uri,$closure);
40
+        return self::set('patch', $uri, $closure);
41 41
     }
42 42
 
43 43
     public static function match(string $method, string $uri, $closure): RouterInterface
@@ -48,20 +48,20 @@  discard block
 block discarded – undo
48 48
 
49 49
     public static function any(string $uri, $closure): RouterInterface
50 50
     {
51
-        return self::set('*',$uri,$closure);
51
+        return self::set('*', $uri, $closure);
52 52
     }
53 53
 
54 54
     private static function set(string $method, string $uri, $closure): RouterInterface
55 55
     {   
56
-        $uri = (substr($uri,0,1) !=='/' and strlen($uri) > 0) ? "/{$uri}" : $uri;
56
+        $uri = (substr($uri, 0, 1) !== '/' and strlen($uri) > 0) ? "/{$uri}" : $uri;
57 57
         
58
-        self::checkDuplicity($uri,$method);
58
+        self::checkDuplicity($uri, $method);
59 59
         
60 60
         $routes = self::getInstance()->getRoutes();
61 61
 
62 62
         $index = sha1(date('d/m/Y H:i:s').count($routes));
63 63
 
64
-        while(array_key_exists($index,$routes)){
64
+        while (array_key_exists($index, $routes)) {
65 65
             $index = sha1(date('d/m/Y H:i:s').rand(count($routes)));
66 66
         }
67 67
 
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 
86 86
     private static function checkDuplicity(string $uri, string $method): void
87 87
     {
88
-        foreach(self::getInstance()->getRoutes() as $route){
89
-    		if( md5($route['uri'].$route['method']) === md5($uri.$method) ){
88
+        foreach (self::getInstance()->getRoutes() as $route) {
89
+    		if (md5($route['uri'].$route['method']) === md5($uri.$method)) {
90 90
                 throw new \RuntimeException("There is already a route with the URI {$uri} and with the {$method} METHOD configured.");
91 91
             }
92 92
         }
Please login to merge, or discard this patch.
src/OwnerTrait.php 1 patch
Spacing   +3 added lines, -3 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
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     {
22 22
         $this->hasRouteName($name);
23 23
 
24
-        if(!$this->loaded){
24
+        if (!$this->loaded) {
25 25
             $this->loadIn($name);
26 26
         }
27 27
         
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
     public function hasCurrentRoute(): void
32 32
     {
33
-        if(!isset($this->currentRoute)){
33
+        if (!isset($this->currentRoute)) {
34 34
             throw new \RuntimeException('Route not yet loaded');
35 35
         }
36 36
     }
Please login to merge, or discard this patch.
src/CurrentTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 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
 
Please login to merge, or discard this patch.