Passed
Branch v2-dev (abcc50)
by Henri
02:14
created
src/Router.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
         $route = self::getInstance()->inSave();
33 33
         $route['name'] = $name;
34 34
         self::getInstance()->routesName[$name] = $name;
35
-        self::getInstance()->unsetRoute(array_key_last(self::getInstance()->routes))->updateRoute($route,$name);
35
+        self::getInstance()->unsetRoute(array_key_last(self::getInstance()->routes))->updateRoute($route, $name);
36 36
         return self::getInstance();
37 37
     }
38 38
 
@@ -71,15 +71,15 @@  discard block
 block discarded – undo
71 71
         self::getInstance()->loaded = true;
72 72
         self::getInstance()->sortRoutes();
73 73
 
74
-        foreach(self::getInstance()->routes as $r => $route){
74
+        foreach (self::getInstance()->routes as $r => $route) {
75 75
             self::getInstance()->currentRoute = $route;
76 76
             self::getInstance()->currentRoute['name'] = $r;
77 77
 
78
-            try{
78
+            try {
79 79
                 self::getInstance()->checkMethod($route, $_SERVER['REQUEST_METHOD']);
80 80
                 self::getInstance()->checkData($route, (new Uri($_SERVER['REQUEST_URI']))->getPath());
81 81
                 return self::getInstance();
82
-            }catch(\Exception $er){
82
+            }catch (\Exception $er) {
83 83
                 continue;
84 84
             }
85 85
         }
@@ -90,15 +90,15 @@  discard block
 block discarded – undo
90 90
 
91 91
     public static function run(): RouterInterface
92 92
     {
93
-        if(!self::getInstance()->loaded){
93
+        if (!self::getInstance()->loaded) {
94 94
             self::getInstance()->load();
95 95
         }
96 96
 
97 97
         self::getInstance()->executeBefore();
98 98
         
99
-        try{
99
+        try {
100 100
             self::getInstance()->executeRouteAction();
101
-        }catch(\Exception $er){
101
+        }catch (\Exception $er) {
102 102
             self::getInstance()->error = $er;
103 103
         }
104 104
         
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 
112 112
     private function checkError(): void
113 113
     {
114
-        if(isset($this->error)){
114
+        if (isset($this->error)) {
115 115
             throw $this->error;
116 116
         }
117 117
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
                 self::getInstance()->checkMethod($route, $_SERVER['REQUEST_METHOD']);
80 80
                 self::getInstance()->checkData($route, (new Uri($_SERVER['REQUEST_URI']))->getPath());
81 81
                 return self::getInstance();
82
-            }catch(\Exception $er){
82
+            } catch(\Exception $er){
83 83
                 continue;
84 84
             }
85 85
         }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
         
99 99
         try{
100 100
             self::getInstance()->executeRouteAction();
101
-        }catch(\Exception $er){
101
+        } catch(\Exception $er){
102 102
             self::getInstance()->error = $er;
103 103
         }
104 104
         
Please login to merge, or discard this patch.
examples/Middleware/Lasted.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,8 +8,8 @@
 block discarded – undo
8 8
 use Psr\Http\Server\RequestHandlerInterface;
9 9
 
10 10
 /** 
11
-  * @property string $error
12
-  */ 
11
+ * @property string $error
12
+ */ 
13 13
 class Lasted extends Middleware{
14 14
 
15 15
     public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@
 block discarded – undo
10 10
 /** 
11 11
   * @property string $error
12 12
   */ 
13
-class Lasted extends Middleware{
13
+class Lasted extends Middleware {
14 14
 
15 15
     public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
16 16
     {
17
-        if(!isset($this->error)){
17
+        if (!isset($this->error)) {
18 18
             throw new Exception("Access not belonged: {$this->error}");
19 19
         }
20 20
 
Please login to merge, or discard this patch.
examples/Middleware/Auth.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@
 block discarded – undo
7 7
 use Psr\Http\Server\RequestHandlerInterface;
8 8
 
9 9
 /** 
10
-  * @property string $error
11
-  */ 
10
+ * @property string $error
11
+ */ 
12 12
 class Auth extends Middleware{
13 13
 
14 14
     public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@
 block discarded – undo
9 9
 /** 
10 10
   * @property string $error
11 11
   */ 
12
-class Auth extends Middleware{
12
+class Auth extends Middleware {
13 13
 
14 14
     public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
15 15
     {
16
-        if(!array_key_exists('user',$_SESSION)){
16
+        if (!array_key_exists('user', $_SESSION)) {
17 17
             $this->error = 'The user must be logged in to the system';
18 18
         }
19 19
 
Please login to merge, or discard this patch.
examples/Routes/default.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -4,28 +4,28 @@  discard block
 block discarded – undo
4 4
 
5 5
 
6 6
 
7
-Router::beforeAll(function(){
7
+Router::beforeAll(function() {
8 8
     echo '<br><b>beforeAll</b><br>';
9 9
 },['testes']);
10 10
 
11
-Router::afterAll(function(){
11
+Router::afterAll(function() {
12 12
     echo '<br><b>afterAll</b><br>';
13 13
 },['testes']);
14 14
 
15 15
 
16
-Router::match('GET|POST|AJAX','/{1parameter}/{otherparameter}', function($parameter, $otherparameter){
16
+Router::match('GET|POST|AJAX', '/{1parameter}/{otherparameter}', function($parameter, $otherparameter) {
17 17
     echo "Parameter 1:{$parameter}, Parameter 2:{$otherparameter}.";
18 18
 });
19 19
 
20
-Router::get('/{2controller}/{method}','{controller}:{method}');
20
+Router::get('/{2controller}/{method}', '{controller}:{method}');
21 21
 
22
-Router::get('/3my-account','Controller\\User:my_account')->before(function(){
22
+Router::get('/3my-account', 'Controller\\User:my_account')->before(function() {
23 23
     echo '1';
24 24
 });
25 25
 
26
-Router::get('/4my-account/teste/teste','Controller\\User:my_account')->name('2');
26
+Router::get('/4my-account/teste/teste', 'Controller\\User:my_account')->name('2');
27 27
 
28
-Router::get('/5my-account/{:teste}/{teste2}',function($teste, $teste2){
28
+Router::get('/5my-account/{:teste}/{teste2}', function($teste, $teste2) {
29 29
     echo $teste.'-'.$teste2;
30 30
 })->where([
31 31
     'teste'=>'[a-zA-Z]{1,10}',
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
 ]);
34 34
 
35 35
 
36
-Router::get('/6my-accounttttt/{param1}/{param2}','\Example\Controllers\User@requireLogin');
36
+Router::get('/6my-accounttttt/{param1}/{param2}', '\Example\Controllers\User@requireLogin');
37 37
 //->middleware(['\Example\Middleware\Auth::class','Lasted']);
38 38
 
39
-Router::get('/5my-account/{:teste}','Controller\\User:my_account')->where([
39
+Router::get('/5my-account/{:teste}', 'Controller\\User:my_account')->where([
40 40
     'teste'=>'[a-zA-Z]{1,10}'
41 41
 ]);
42 42
 
43 43
 
44
-Router::any('/8',function(){
44
+Router::any('/8', function() {
45 45
     //
46 46
 })->name('index');
Please login to merge, or discard this patch.