Passed
Push — master ( 6af488...2e6c5a )
by Henri
01:21
created
examples/MiddlewareUseExample.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@
 block discarded – undo
77 77
 
78 78
     runMiddlewares($serverRequest);
79 79
 
80
-}catch(Exception $er){
80
+} catch(Exception $er){
81 81
 
82 82
     die("Code Error: {$er->getCode()}<br>Line: {$er->getLine()}<br>File: {$er->getFile()}<br>Message: {$er->getMessage()}.");
83 83
 
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,24 +11,24 @@  discard block
 block discarded – undo
11 11
 use Psr\Http\Message\ResponseInterface;
12 12
 use Psr\Http\Server\MiddlewareInterface;
13 13
 
14
-try{
14
+try {
15 15
     $serverRequest = (new Factory())->createServerRequest('GET', new Uri('/'));
16
-    $serverRequest = $serverRequest->withAttribute('validator',[
16
+    $serverRequest = $serverRequest->withAttribute('validator', [
17 17
         'namespace' => 'HnrAzevedo\\Validator\\Example\\Rules',
18 18
         'data' => $data,
19 19
         'lang' => 'pt_br'
20 20
     ]);
21 21
 
22
-    class App implements MiddlewareInterface{
22
+    class App implements MiddlewareInterface {
23 23
         public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
24 24
         {
25
-            if(!$request->getAttribute('validator')['valid']){
25
+            if (!$request->getAttribute('validator')['valid']) {
26 26
                 
27 27
                 $errors = [];
28 28
 
29
-                foreach($request->getAttribute('validator')['errors'] as $error){
29
+                foreach ($request->getAttribute('validator')['errors'] as $error) {
30 30
                     $errors[] = [
31
-                        'input' => array_keys($error)[0],                 // Return name input error
31
+                        'input' => array_keys($error)[0], // Return name input error
32 32
                         'message' => array_values($error)[0]            // Return message error
33 33
                     ];
34 34
                 }
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         }
43 43
     }
44 44
 
45
-    define('GLOBAL_MIDDLEWARES',[
45
+    define('GLOBAL_MIDDLEWARES', [
46 46
         Validator::class,
47 47
         App::class
48 48
     ]);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
     function runMiddlewares($serverRequest)
80 80
     {
81
-        nextExample(new class implements RequestHandlerInterface{
81
+        nextExample(new class implements RequestHandlerInterface {
82 82
             public function handle(ServerRequestInterface $request): ResponseInterface
83 83
             {
84 84
                 return (new Factory())->createResponse(200);
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 
89 89
     runMiddlewares($serverRequest);
90 90
 
91
-}catch(Exception $er){
91
+}catch (Exception $er) {
92 92
 
93 93
     die("Code Error: {$er->getCode()}<br>Line: {$er->getLine()}<br>File: {$er->getFile()}<br>Message: {$er->getMessage()}.");
94 94
 
Please login to merge, or discard this patch.
examples/DefaultUseExample.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
     /* Transforms validation to Json format to be validated on the client if desired */
24 24
     $json = Validator::namespace('HnrAzevedo\\Validator\\Example\\Rules')->toJson($data);
25 25
 
26
-}catch(Exception $er){
26
+} catch(Exception $er){
27 27
 
28 28
     die("Code Error: {$er->getCode()}<br> Line: {$er->getLine()}<br> File: {$er->getFile()}<br> Message: {$er->getMessage()}");
29 29
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -4,17 +4,17 @@  discard block
 block discarded – undo
4 4
 
5 5
 use HnrAzevedo\Validator\Validator;
6 6
 
7
-try{
7
+try {
8 8
 
9 9
     /* Checks whether the passed data is valid for the selected function */
10 10
     $valid = Validator::lang('pt_br')->namespace('HnrAzevedo\\Validator\\Example\\Rules')->execute($data);
11 11
     
12 12
     $errors = [];
13 13
 
14
-    if(!$valid){
15
-        foreach(Validator::getErrors() as $error){
14
+    if (!$valid) {
15
+        foreach (Validator::getErrors() as $error) {
16 16
             $errors[] = [
17
-                'input' => array_keys($error)[0],                 // Return name input error
17
+                'input' => array_keys($error)[0], // Return name input error
18 18
                 'message' => array_values($error)[0]            // Return message error
19 19
             ];
20 20
         }
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     /* Transforms validation to Json format to be validated on the client if desired */
26 26
     $json = Validator::namespace('HnrAzevedo\\Validator\\Example\\Rules')->toJson($data);
27 27
 
28
-}catch(Exception $er){
28
+}catch (Exception $er) {
29 29
 
30 30
     die("Code Error: {$er->getCode()}<br> Line: {$er->getLine()}<br> File: {$er->getFile()}<br> Message: {$er->getMessage()}");
31 31
 
Please login to merge, or discard this patch.
src/ExtraCheck.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,15 +8,15 @@  discard block
 block discarded – undo
8 8
     
9 9
     protected function requireds(): void
10 10
     {
11
-        if(count(self::getInstance()->required()) > 0){
12
-            self::getInstance()->error([ self::$err['needed'].implode(', ', array_keys(self::getInstance()->required())) ]);
11
+        if (count(self::getInstance()->required())>0) {
12
+            self::getInstance()->error([self::$err['needed'].implode(', ', array_keys(self::getInstance()->required()))]);
13 13
         }
14 14
     }
15 15
 
16 16
     public function validateDate($date, $format = 'Y-m-d H:i:s')
17 17
     {
18 18
         $d = \DateTime::createFromFormat($format, $date);
19
-        return $d && $d->format($format) == $date;
19
+        return $d && $d->format($format)==$date;
20 20
     }
21 21
 
22 22
     protected function isRequired(string $param): bool
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
     protected function valid(string $param, $value): bool
29 29
     {
30
-        return (self::getInstance()->isRequired($param) || strlen($value > 0));
30
+        return (self::getInstance()->isRequired($param) || strlen($value>0));
31 31
     }
32 32
 
33 33
 }
Please login to merge, or discard this patch.
examples/Rules/User.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -11,38 +11,38 @@
 block discarded – undo
11 11
     {
12 12
         Validator::add($this, function(Rules $rules){
13 13
             $rules->action('login')
14
-                  ->field(
15
-                      'field_email',
16
-                      ['minlength' => 1, 'filter' => FILTER_VALIDATE_EMAIL, 'regex' => '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/', 'required' => true],
17
-                      'Email address'
14
+                    ->field(
15
+                        'field_email',
16
+                        ['minlength' => 1, 'filter' => FILTER_VALIDATE_EMAIL, 'regex' => '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/', 'required' => true],
17
+                        'Email address'
18 18
                     )
19
-                  ->field(
20
-                      'field_password',
21
-                      ['minlength' => 6, 'maxlength' => 20, 'required' => true],
22
-                      'Password'
19
+                    ->field(
20
+                        'field_password',
21
+                        ['minlength' => 6, 'maxlength' => 20, 'required' => true],
22
+                        'Password'
23 23
                     )
24
-                  ->field(
25
-                      'field_password2',
26
-                      ['minlength' => 6, 'maxlength' => 20, 'equals' => 'field_password', 'required' => true],
27
-                      'Confirm password'
24
+                    ->field(
25
+                        'field_password2',
26
+                        ['minlength' => 6, 'maxlength' => 20, 'equals' => 'field_password', 'required' => true],
27
+                        'Confirm password'
28 28
                     )
29
-                  ->field(
30
-                      'field_remember',
31
-                      ['minlength' => 2, 'maxlength' => 2, 'required' => false],
32
-                      'Keep connected'
29
+                    ->field(
30
+                        'field_remember',
31
+                        ['minlength' => 2, 'maxlength' => 2, 'required' => false],
32
+                        'Keep connected'
33 33
                     )
34
-                  ->field(
35
-                      'field_birth',
36
-                      ['type' => 'date', 'required' => true],
37
-                      'Date of birth'
34
+                    ->field(
35
+                        'field_birth',
36
+                        ['type' => 'date', 'required' => true],
37
+                        'Date of birth'
38 38
                     )
39
-                  ->field(
40
-                      'field_phones',
41
-                      ['mincount' => 2, 'maxcount' => 3, 'required' => true, 'minlength' => 8, 'maxlength' => 9],
42
-                      'Phones'
39
+                    ->field(
40
+                        'field_phones',
41
+                        ['mincount' => 2, 'maxcount' => 3, 'required' => true, 'minlength' => 8, 'maxlength' => 9],
42
+                        'Phones'
43 43
                     );
44 44
 
45
-			return $rules;
45
+            return $rules;
46 46
         });
47 47
     }
48 48
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
 {
10 10
     public function __construct()
11 11
     {
12
-        Validator::add($this, function(Rules $rules){
12
+        Validator::add($this, function(Rules $rules) {
13 13
             $rules->action('login')
14 14
                   ->field(
15 15
                       'field_email',
Please login to merge, or discard this patch.
examples/index.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
     'field_password' => '123456',
7 7
     'field_password2' => '1234567',
8 8
     'field_phones' => [
9
-        '949164770','949164771','949164772'
9
+        '949164770', '949164771', '949164772'
10 10
     ],
11 11
     'field_birth' => '28/09/1996',
12 12
     '_PROVIDER' => 'user',
Please login to merge, or discard this patch.
src/Helper.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
     protected static function array($value): Array
17 17
     {
18
-        return (is_array($value)) ? $value : [ $value ];
18
+        return (is_array($value)) ? $value : [$value];
19 19
     }
20 20
 
21 21
     protected static function getInstance(?string $lang = null): Validator
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
 
32 32
     protected function data($field = null, ?array $values = null)
33 33
     {
34
-        if(null !== $values){
34
+        if (null!==$values) {
35 35
             $this->data[$field] = $values;
36 36
         }
37
-        if(null !== $field){
37
+        if (null!==$field) {
38 38
             return $this->data[$field];
39 39
         }
40 40
         return $this->data;
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
     protected function validator(string $model, ?object $callback = null)
44 44
     {
45
-        if(null !== $callback){
45
+        if (null!==$callback) {
46 46
             $this->validators[$model] = $callback;
47 47
         }
48 48
         return $this->validators[$model];
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
     protected function model(?string $model = null): string
52 52
     {
53
-        if(null !== $model){
53
+        if (null!==$model) {
54 54
             $this->model = $model;
55 55
         }
56 56
         return $this->model;
Please login to merge, or discard this patch.
src/Rules.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -11,29 +11,29 @@
 block discarded – undo
11 11
 
12 12
     public function __construct(string $model)
13 13
     {
14
-	    $this->form['model'] = ucfirst($model);
15
-	}
14
+        $this->form['model'] = ucfirst($model);
15
+    }
16 16
 
17 17
     public function action(string $action): Rules
18 18
     {
19
-	    $this->action = $action;
20
-	    return $this;
21
-	}
19
+        $this->action = $action;
20
+        return $this;
21
+    }
22 22
 
23 23
     public function field(string $field, array $test, ?string $placeholder = null): Rules
24 24
     {
25
-	    if(empty($this->action)){
25
+        if(empty($this->action)){
26 26
             $this->error([ 'form' => self::$err['nFoundForm'] ]);
27 27
             return $this;
28 28
         }
29 29
 
30 30
         $this->form[$this->action][$field] = $test;
31 31
         $this->form[$this->action][$field]['placeholder'] = (null !== $placeholder) ? $placeholder : $field;
32
-	    return $this;
33
-  	}
32
+        return $this;
33
+        }
34 34
 
35 35
     public function getRules(string $action): Array
36 36
     {
37
-		return (array_key_exists($action, $this->form)) ? $this->form[$action] : [];
38
-	}
37
+        return (array_key_exists($action, $this->form)) ? $this->form[$action] : [];
38
+    }
39 39
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,13 +22,13 @@
 block discarded – undo
22 22
 
23 23
     public function field(string $field, array $test, ?string $placeholder = null): Rules
24 24
     {
25
-	    if(empty($this->action)){
26
-            $this->error([ 'form' => self::$err['nFoundForm'] ]);
25
+	    if (empty($this->action)) {
26
+            $this->error(['form' => self::$err['nFoundForm']]);
27 27
             return $this;
28 28
         }
29 29
 
30 30
         $this->form[$this->action][$field] = $test;
31
-        $this->form[$this->action][$field]['placeholder'] = (null !== $placeholder) ? $placeholder : $field;
31
+        $this->form[$this->action][$field]['placeholder'] = (null!==$placeholder) ? $placeholder : $field;
32 32
 	    return $this;
33 33
   	}
34 34
 
Please login to merge, or discard this patch.
src/Validator.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@
 block discarded – undo
88 88
         
89 89
             self::getInstance()->validate();
90 90
             self::getInstance()->requireds();
91
-        }catch(\Exception $er){
91
+        } catch(\Exception $er){
92 92
             self::getInstance()->errors[] = ['form' => $er->getMessage()];
93 93
         }
94 94
         
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
             self::getInstance()->errors[] = ['form' => $er->getMessage()];
93 93
         }
94 94
         
95
-		return self::errors();
95
+        return self::errors();
96 96
     }
97 97
 
98 98
     public static function errors(): bool
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
     {
105 105
         foreach ( (self::getInstance()->validator(self::getInstance()->model)->getRules(self::getInstance()->data['_ROLE'])) as $key => $value) {
106 106
 
107
-			foreach (self::getInstance()->data as $keyy => $valuee) {
107
+            foreach (self::getInstance()->data as $keyy => $valuee) {
108 108
 
109 109
                 if($keyy!==$key){
110 110
                     continue;
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
 
115 115
                 unset(self::getInstance()->required[$key]);
116 116
 
117
-				foreach ($value as $subkey => $subvalue) {
117
+                foreach ($value as $subkey => $subvalue) {
118 118
 
119 119
                     $function = strtolower($subkey);
120 120
 
121 121
                     self::getInstance()->hasMethod($function)->$function($keyy, $subvalue, (self::getInstance()->validator(self::getInstance()->model)->getRules(self::getInstance()->data['_ROLE'])) );
122 122
                 }
123 123
 				
124
-			}
124
+            }
125 125
         }
126 126
     }
127 127
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 
169 169
         self::getInstance()->existRole(self::getInstance()->model());
170 170
 
171
-		foreach ( self::getInstance()->validator(self::getInstance()->model())->getRules($request['_ROLE'])  as $field => $r) {
171
+        foreach ( self::getInstance()->validator(self::getInstance()->model())->getRules($request['_ROLE'])  as $field => $r) {
172 172
             $r = self::getInstance()->replaceRegex($r);
173 173
             $response .= ("'$field':".json_encode(array_reverse($r))).',';
174 174
         }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
 
15 15
     public function __construct(?string $lang = null)
16 16
     {
17
-        $lang = (null !== $lang) ? $lang : 'en';
18
-        require __DIR__.DIRECTORY_SEPARATOR.'languages'. DIRECTORY_SEPARATOR . $lang .'.php';
17
+        $lang = (null!==$lang) ? $lang : 'en';
18
+        require __DIR__.DIRECTORY_SEPARATOR.'languages'.DIRECTORY_SEPARATOR.$lang.'.php';
19 19
         self::$err = $VALIDATOR_LANG;
20 20
     }
21 21
 
22 22
     public static function lang(string $lang): Validator
23 23
     {
24 24
         unset($VALIDATOR_LANG);
25
-        require __DIR__.DIRECTORY_SEPARATOR.'languages'. DIRECTORY_SEPARATOR . $lang .'.php';
25
+        require __DIR__.DIRECTORY_SEPARATOR.'languages'.DIRECTORY_SEPARATOR.$lang.'.php';
26 26
         self::$err = $VALIDATOR_LANG;
27 27
         return self::getInstance($lang);
28 28
     }
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
     private static function getClass(string $class)
44 44
     {
45
-        if(!class_exists($class)){
45
+        if (!class_exists($class)) {
46 46
             throw new \RuntimeException(self::$err['nFormID']);
47 47
         }
48 48
 
@@ -53,21 +53,21 @@  discard block
 block discarded – undo
53 53
 
54 54
     private function existRole($getRules)
55 55
     {
56
-        if(empty(self::getInstance()->validator($getRules)->getRules(self::getInstance()->data['_ROLE']))){
56
+        if (empty(self::getInstance()->validator($getRules)->getRules(self::getInstance()->data['_ROLE']))) {
57 57
             throw new \RuntimeException(self::$err['nFoundForm']);
58 58
         }
59 59
     }
60 60
 
61 61
     public function checkDatas(array $data): void
62 62
     {
63
-        if(!isset($data['_PROVIDER']) || !isset($data['_ROLE'])){
63
+        if (!isset($data['_PROVIDER']) || !isset($data['_ROLE'])) {
64 64
             throw new \RuntimeException(self::$err['issetData']);
65 65
         }
66 66
     }
67 67
 
68 68
     public static function execute(array $data): bool
69 69
     {
70
-        try{
70
+        try {
71 71
             self::getInstance()->checkDatas($data);
72 72
 
73 73
             self::getInstance()->data = $data;
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 
79 79
             self::getInstance()->existRole(self::getInstance()->model);
80 80
                 
81
-            foreach ( (self::getInstance()->validator(self::getInstance()->model)->getRules($data['_ROLE'])) as $key => $value) {
82
-                if(@$value['required'] === true){
81
+            foreach ((self::getInstance()->validator(self::getInstance()->model)->getRules($data['_ROLE'])) as $key => $value) {
82
+                if (@$value['required']===true) {
83 83
                     self::getInstance()->required[$key] = $value;
84 84
                 }
85 85
             }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
         
89 89
             self::getInstance()->validate();
90 90
             self::getInstance()->requireds();
91
-        }catch(\Exception $er){
91
+        }catch (\Exception $er) {
92 92
             self::getInstance()->errors[] = ['form' => $er->getMessage()];
93 93
         }
94 94
         
@@ -97,16 +97,16 @@  discard block
 block discarded – undo
97 97
 
98 98
     public static function errors(): bool
99 99
     {
100
-        return (count(self::getInstance()->errors) === 0);
100
+        return (count(self::getInstance()->errors)===0);
101 101
     }
102 102
     
103 103
     public function validate(): void
104 104
     {
105
-        foreach ( (self::getInstance()->validator(self::getInstance()->model)->getRules(self::getInstance()->data['_ROLE'])) as $key => $value) {
105
+        foreach ((self::getInstance()->validator(self::getInstance()->model)->getRules(self::getInstance()->data['_ROLE'])) as $key => $value) {
106 106
 
107 107
 			foreach (self::getInstance()->data as $keyy => $valuee) {
108 108
 
109
-                if($keyy!==$key){
109
+                if ($keyy!==$key) {
110 110
                     continue;
111 111
                 }
112 112
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
                     $function = strtolower($subkey);
120 120
 
121
-                    self::getInstance()->hasMethod($function)->$function($keyy, $subvalue, (self::getInstance()->validator(self::getInstance()->model)->getRules(self::getInstance()->data['_ROLE'])) );
121
+                    self::getInstance()->hasMethod($function)->$function($keyy, $subvalue, (self::getInstance()->validator(self::getInstance()->model)->getRules(self::getInstance()->data['_ROLE'])));
122 122
                 }
123 123
 				
124 124
 			}
@@ -127,16 +127,16 @@  discard block
 block discarded – undo
127 127
 
128 128
     private function checkExpected(string $keyy): void
129 129
     {
130
-        if(!array_key_exists($keyy, (self::getInstance()->validator(self::getInstance()->model)->getRules(self::getInstance()->data['_ROLE'])) ) && !in_array($keyy, self::getInstance()->defaultData)){
131
-            if(!$this->checkExpectedArray($keyy)){
132
-                throw new \RuntimeException($keyy . self::$err['nExpected']);
130
+        if (!array_key_exists($keyy, (self::getInstance()->validator(self::getInstance()->model)->getRules(self::getInstance()->data['_ROLE']))) && !in_array($keyy, self::getInstance()->defaultData)) {
131
+            if (!$this->checkExpectedArray($keyy)) {
132
+                throw new \RuntimeException($keyy.self::$err['nExpected']);
133 133
             }
134 134
         }
135 135
     }
136 136
 
137 137
     private function checkExpectedArray(string $keyy): bool
138 138
     {
139
-        return (!array_key_exists($keyy.'[]', (self::getInstance()->validator(self::getInstance()->model)->getRules(self::getInstance()->data['_ROLE'])) ) && !in_array($keyy.'[]', self::getInstance()->defaultData));
139
+        return (!array_key_exists($keyy.'[]', (self::getInstance()->validator(self::getInstance()->model)->getRules(self::getInstance()->data['_ROLE']))) && !in_array($keyy.'[]', self::getInstance()->defaultData));
140 140
     }
141 141
 
142 142
     public static function getErrors(): array
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 
147 147
     public function hasMethod($method): Validator
148 148
     {
149
-        if(!method_exists(static::class, $method)){
150
-            throw new \RuntimeException($method . self::$err['nMethod']);
149
+        if (!method_exists(static::class, $method)) {
150
+            throw new \RuntimeException($method.self::$err['nMethod']);
151 151
         }
152 152
         
153 153
         return $this;
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 
169 169
         self::getInstance()->existRole(self::getInstance()->model());
170 170
 
171
-		foreach ( self::getInstance()->validator(self::getInstance()->model())->getRules($request['_ROLE'])  as $field => $r) {
171
+		foreach (self::getInstance()->validator(self::getInstance()->model())->getRules($request['_ROLE'])  as $field => $r) {
172 172
             $r = self::getInstance()->replaceRegex($r);
173 173
             $response .= ("'$field':".json_encode(array_reverse($r))).',';
174 174
         }
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
     
179 179
     private function replaceRegex(array $getRules): array
180 180
     {
181
-        if(array_key_exists('regex', $getRules)){ 
181
+        if (array_key_exists('regex', $getRules)) { 
182 182
             $getRules['regex'] = substr($getRules['regex'], 1, -2);
183 183
         }
184 184
 
Please login to merge, or discard this patch.
src/MiddlewareTrait.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@
 block discarded – undo
12 12
     {
13 13
         return $handler->handle($request->withAttribute('validator', [
14 14
             'valid' => self::lang($this->requestLang($request))
15
-                           ->namespace($this->requestNamespace($request))
16
-                           ->execute($this->requestData($request)),
15
+                            ->namespace($this->requestNamespace($request))
16
+                            ->execute($this->requestData($request)),
17 17
             'errors' => self::getErrors()
18 18
         ]));
19 19
     }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 use Psr\Http\Server\RequestHandlerInterface;
7 7
 use Psr\Http\Message\ResponseInterface;
8 8
 
9
-trait MiddlewareTrait{
9
+trait MiddlewareTrait {
10 10
 
11 11
     public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
12 12
     {
@@ -20,17 +20,17 @@  discard block
 block discarded – undo
20 20
 
21 21
     private function requestData(ServerRequestInterface $request): array
22 22
     {
23
-        return ($request->getAttribute('validator') !== null && isset($request->getAttribute('validator')['data'])) ? $request->getAttribute('validator')['data'] : $_REQUEST;
23
+        return ($request->getAttribute('validator')!==null && isset($request->getAttribute('validator')['data'])) ? $request->getAttribute('validator')['data'] : $_REQUEST;
24 24
     }
25 25
 
26 26
     private function requestNamespace(ServerRequestInterface $request): string
27 27
     {
28
-        return ($request->getAttribute('validator') !== null && isset($request->getAttribute('validator')['namespace'])) ? $request->getAttribute('validator')['namespace'] : '';
28
+        return ($request->getAttribute('validator')!==null && isset($request->getAttribute('validator')['namespace'])) ? $request->getAttribute('validator')['namespace'] : '';
29 29
     }
30 30
 
31 31
     private function requestLang(ServerRequestInterface $request): string
32 32
     {
33
-        return ($request->getAttribute('validator') !== null && isset($request->getAttribute('validator')['lang'])) ? $request->getAttribute('validator')['lang'] : 'en';
33
+        return ($request->getAttribute('validator')!==null && isset($request->getAttribute('validator')['lang'])) ? $request->getAttribute('validator')['lang'] : 'en';
34 34
     }
35 35
     
36 36
 }
37 37
\ No newline at end of file
Please login to merge, or discard this patch.