Passed
Branch master (9353c8)
by Henri
02:26 queued 01:07
created
examples/Validations/User.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,15 +9,15 @@
 block discarded – undo
9 9
 
10 10
         Validator::add($this, function(Rules $rules){
11 11
             $rules->setAction('login')
12
-                  //->addField('email',['minlength'=>1,'regex'=>'/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/','required'=>true])
13
-                  ->addField('email',['minlength'=>1,'filter'=>FILTER_VALIDATE_EMAIL,'required'=>true])
14
-                  ->addField('password',['minlength'=>6,'maxlength'=>20,'required'=>true])
15
-                  ->addField('password2',['equals'=>'password','required'=>true])
16
-                  ->addField('remember',['minlength'=>2,'maxlength'=>2,'required'=>false])
17
-                  ->addField('birth',['type'=>'date','required'=>true])
18
-                  ->addField('phones',['mincount'=>2,'maxcount'=>3,'required'=>true,'minlength'=>8,'maxlength'=>9]);
12
+                    //->addField('email',['minlength'=>1,'regex'=>'/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/','required'=>true])
13
+                    ->addField('email',['minlength'=>1,'filter'=>FILTER_VALIDATE_EMAIL,'required'=>true])
14
+                    ->addField('password',['minlength'=>6,'maxlength'=>20,'required'=>true])
15
+                    ->addField('password2',['equals'=>'password','required'=>true])
16
+                    ->addField('remember',['minlength'=>2,'maxlength'=>2,'required'=>false])
17
+                    ->addField('birth',['type'=>'date','required'=>true])
18
+                    ->addField('phones',['mincount'=>2,'maxcount'=>3,'required'=>true,'minlength'=>8,'maxlength'=>9]);
19 19
 
20
-			return $rules;
20
+            return $rules;
21 21
         });
22 22
 
23 23
         return $this;
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -2,20 +2,20 @@
 block discarded – undo
2 2
 
3 3
 namespace HnrAzevedo\Validator;
4 4
 
5
-Class User{
5
+Class User {
6 6
 
7 7
     public function __construct()
8 8
     {
9 9
 
10
-        Validator::add($this, function(Rules $rules){
10
+        Validator::add($this, function(Rules $rules) {
11 11
             $rules->setAction('login')
12 12
                   //->addField('email',['minlength'=>1,'regex'=>'/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/','required'=>true])
13
-                  ->addField('email',['minlength'=>1,'filter'=>FILTER_VALIDATE_EMAIL,'required'=>true])
14
-                  ->addField('password',['minlength'=>6,'maxlength'=>20,'required'=>true])
15
-                  ->addField('password2',['equals'=>'password','required'=>true])
16
-                  ->addField('remember',['minlength'=>2,'maxlength'=>2,'required'=>false])
17
-                  ->addField('birth',['type'=>'date','required'=>true])
18
-                  ->addField('phones',['mincount'=>2,'maxcount'=>3,'required'=>true,'minlength'=>8,'maxlength'=>9]);
13
+                  ->addField('email', ['minlength'=>1, 'filter'=>FILTER_VALIDATE_EMAIL, 'required'=>true])
14
+                  ->addField('password', ['minlength'=>6, 'maxlength'=>20, 'required'=>true])
15
+                  ->addField('password2', ['equals'=>'password', 'required'=>true])
16
+                  ->addField('remember', ['minlength'=>2, 'maxlength'=>2, 'required'=>false])
17
+                  ->addField('birth', ['type'=>'date', 'required'=>true])
18
+                  ->addField('phones', ['mincount'=>2, 'maxcount'=>3, 'required'=>true, 'minlength'=>8, 'maxlength'=>9]);
19 19
 
20 20
 			return $rules;
21 21
         });
Please login to merge, or discard this patch.
src/Rules.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,30 +9,30 @@
 block discarded – undo
9 9
 
10 10
     public function __construct(object $model)
11 11
     {
12
-	    $this->form['model'] = ucfirst(get_class($model));
13
-	}
12
+        $this->form['model'] = ucfirst(get_class($model));
13
+    }
14 14
 
15 15
     public function setAction(string $action): Rules
16 16
     {
17
-	    $this->action = $action;
18
-	    return $this;
19
-	}
17
+        $this->action = $action;
18
+        return $this;
19
+    }
20 20
 
21 21
     public function addField(string $field, array $test): Rules
22 22
     {
23
-	    if(empty($this->action)){
23
+        if(empty($this->action)){
24 24
             self::$errors[] = "Form action not registered.";
25 25
         }
26 26
 
27
-	    if(empty($this->form[$this->action][$field])){
27
+        if(empty($this->form[$this->action][$field])){
28 28
             $this->form[$this->action][$field] = $test;
29 29
         }
30 30
 
31
-	    return $this;
32
-  	}
31
+        return $this;
32
+        }
33 33
 
34 34
     public function getRules(string $action): ?array
35 35
     {
36
-		return (array_key_exists($action, $this->form)) ? $this->form[$action] : null;
37
-	}
36
+        return (array_key_exists($action, $this->form)) ? $this->form[$action] : null;
37
+    }
38 38
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 namespace HnrAzevedo\Validator;
4 4
 
5
-Class Rules{
5
+Class Rules {
6 6
     private string $action;
7 7
 
8 8
     private array $form = array();
@@ -20,11 +20,11 @@  discard block
 block discarded – undo
20 20
 
21 21
     public function addField(string $field, array $test): Rules
22 22
     {
23
-	    if(empty($this->action)){
23
+	    if (empty($this->action)) {
24 24
             self::$errors[] = "Form action not registered.";
25 25
         }
26 26
 
27
-	    if(empty($this->form[$this->action][$field])){
27
+	    if (empty($this->form[$this->action][$field])) {
28 28
             $this->form[$this->action][$field] = $test;
29 29
         }
30 30
 
Please login to merge, or discard this patch.
examples/index.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
         'password' => 123456,
13 13
         'password2' => 123456,
14 14
         'phones' => [
15
-            '949164770','949164771','949164772'
15
+            '949164770', '949164771', '949164772'
16 16
         ],
17 17
         'birth' => '28/09/1996' 
18 18
     ]),
@@ -20,21 +20,21 @@  discard block
 block discarded – undo
20 20
     'role' => 'login'
21 21
 ];
22 22
 
23
-try{
23
+try {
24 24
 
25 25
     /* Checks whether the passed data is valid for the selected function */
26 26
     $valid = Validator::execute($data);
27 27
     
28
-    if(!$valid){
29
-        foreach(Validator::getErrors() as $err => $message){
30
-            echo $message . PHP_EOL;
28
+    if (!$valid) {
29
+        foreach (Validator::getErrors() as $err => $message) {
30
+            echo $message.PHP_EOL;
31 31
         }
32 32
     }
33 33
 
34 34
     /* Transforms validation to Json format to be validated on the client if desired */
35 35
     $json = Validator::toJson($data);
36 36
 
37
-}catch(Exception $er){
37
+}catch (Exception $er) {
38 38
 
39 39
     die("Code Error: {$er->getCode()}, Line: {$er->getLine()}, File: {$er->getFile()}, Message: {$er->getMessage()}.");
40 40
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
     /* Transforms validation to Json format to be validated on the client if desired */
35 35
     $json = Validator::toJson($data);
36 36
 
37
-}catch(Exception $er){
37
+} catch(Exception $er){
38 38
 
39 39
     die("Code Error: {$er->getCode()}, Line: {$er->getLine()}, File: {$er->getFile()}, Message: {$er->getMessage()}.");
40 40
 
Please login to merge, or discard this patch.
src/Validator.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
     public static function checkDatas()
69 69
     {
70
-		self::existData();
70
+        self::existData();
71 71
         self::jsonData();
72 72
         self::hasProvider();
73 73
         self::hasRole();
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
 
84 84
         self::$model = get_class(self::getClass('HnrAzevedo\\Validator\\'.ucfirst(self::$data['provider'])));
85 85
 
86
-		self::existRole(self::$model);
86
+        self::existRole(self::$model);
87 87
             
88
-		foreach ( (self::$validators[self::$model]->getRules($datas['role'])) as $key => $value) {
88
+        foreach ( (self::$validators[self::$model]->getRules($datas['role'])) as $key => $value) {
89 89
             if(@$value['required'] === true){
90 90
                 self::$required[$key] = $value;
91 91
             }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         
98 98
         self::check_requireds();
99 99
 				
100
-		return self::check_errors();
100
+        return self::check_errors();
101 101
     }
102 102
 
103 103
     public static function check_errors(): bool
@@ -109,23 +109,23 @@  discard block
 block discarded – undo
109 109
     {
110 110
         foreach ( (self::$validators[self::$model]->getRules(self::$data['role'])) as $key => $value) {
111 111
 
112
-			foreach (json_decode(self::$data['data']) as $keyy => $valuee) {
112
+            foreach (json_decode(self::$data['data']) as $keyy => $valuee) {
113 113
 
114
-				if(!array_key_exists($keyy, (self::$validators[self::$model]->getRules(self::$data['role'])) )){
114
+                if(!array_key_exists($keyy, (self::$validators[self::$model]->getRules(self::$data['role'])) )){
115 115
                     throw new Exception("O campo '{$keyy}' não é esperado para está operação.");
116 116
                 }
117 117
 
118
-				if($keyy===$key){
118
+                if($keyy===$key){
119 119
 
120 120
                     unset(self::$required[$key]);
121 121
 
122
-					foreach ($value as $subkey => $subvalue) {
122
+                    foreach ($value as $subkey => $subvalue) {
123 123
                         $function = "check_{$subkey}";
124 124
                         self::testMethod($function);
125 125
                         self::$function($keyy,$subvalue);
126
-					}
127
-				}
128
-			}
126
+                    }
127
+                }
128
+            }
129 129
         }
130 130
     }
131 131
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 
155 155
         self::existRole(self::$model);
156 156
 
157
-		foreach ( self::$validators[self::$model]->getRules($request['role'])  as $field => $r) {
157
+        foreach ( self::$validators[self::$model]->getRules($request['role'])  as $field => $r) {
158 158
             
159 159
             $response .= ("{$field}:".json_encode(array_reverse($r))).',';
160 160
             
@@ -165,6 +165,6 @@  discard block
 block discarded – undo
165 165
         $response = str_replace('{"','',$response);
166 166
         $response = str_replace('":',':',$response);
167 167
 
168
-		return $response;
169
-	}
168
+        return $response;
169
+    }
170 170
 }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -5,10 +5,10 @@  discard block
 block discarded – undo
5 5
 use HnrAzevedo\Validator\Rules;
6 6
 use Exception;
7 7
 
8
-Class Validator{
8
+Class Validator {
9 9
     use Check;
10 10
 
11
-    public static function add(object $model,callable $return): void
11
+    public static function add(object $model, callable $return): void
12 12
     {
13 13
         self::$model = get_class($model);
14 14
         self::$validators[self::$model] = $return($Rules = new Rules($model));
@@ -16,42 +16,42 @@  discard block
 block discarded – undo
16 16
     
17 17
     private static function existData()
18 18
     {
19
-        if(!array_key_exists('data', self::$data)){
19
+        if (!array_key_exists('data', self::$data)) {
20 20
             throw new Exception('Informações cruciais não foram recebidas.');
21 21
         }
22 22
     }
23 23
 
24 24
     private static function jsonData()
25 25
     {
26
-        if(json_decode(self::$data['data']) === null){
26
+        if (json_decode(self::$data['data'])===null) {
27 27
             throw new Exception('O servidor recebeu as informações no formato esperado.');
28 28
         }
29 29
     }
30 30
 
31 31
     private static function hasProvider()
32 32
     {
33
-        if(!array_key_exists('provider',self::$data)){
33
+        if (!array_key_exists('provider', self::$data)) {
34 34
             throw new Exception('O servidor não recebeu o ID do formulário.');
35 35
         }
36 36
     }
37 37
 
38 38
     private static function hasRole()
39 39
     {
40
-        if(!array_key_exists('role',self::$data)){
40
+        if (!array_key_exists('role', self::$data)) {
41 41
             throw new Exception('O servidor não conseguiu identificar a finalidade deste formulário.');
42 42
         }
43 43
     }
44 44
 
45 45
     private static function includeValidations()
46 46
     {
47
-        if( file_exists(VALIDATOR_CONFIG['path'] . ucfirst(self::$data['provider']) . '.php') ){
48
-            require_once(VALIDATOR_CONFIG['path'] . ucfirst(self::$data['provider']) . '.php');
47
+        if (file_exists(VALIDATOR_CONFIG['path'].ucfirst(self::$data['provider']).'.php')) {
48
+            require_once(VALIDATOR_CONFIG['path'].ucfirst(self::$data['provider']).'.php');
49 49
         }
50 50
     }
51 51
 
52 52
     private static function getClass(string $class)
53 53
     {
54
-        if(!class_exists($class)){
54
+        if (!class_exists($class)) {
55 55
             throw new Exception("Form ID {$class} inválido.");
56 56
         }
57 57
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 
61 61
     private static function existRole($rules)
62 62
     {
63
-        if(empty(self::$validators[$rules]->getRules(self::$data['role']))){
63
+        if (empty(self::$validators[$rules]->getRules(self::$data['role']))) {
64 64
             throw new Exception('Não existe regras para validar este formulário.');
65 65
         }
66 66
     }
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 
86 86
 		self::existRole(self::$model);
87 87
             
88
-		foreach ( (self::$validators[self::$model]->getRules($datas['role'])) as $key => $value) {
89
-            if(@$value['required'] === true){
88
+		foreach ((self::$validators[self::$model]->getRules($datas['role'])) as $key => $value) {
89
+            if (@$value['required']===true) {
90 90
                 self::$required[$key] = $value;
91 91
             }
92 92
         }
@@ -102,27 +102,27 @@  discard block
 block discarded – undo
102 102
 
103 103
     public static function check_errors(): bool
104 104
     {
105
-        return (count(self::$errors) === 0);
105
+        return (count(self::$errors)===0);
106 106
     }
107 107
     
108 108
     public static function validate()
109 109
     {
110
-        foreach ( (self::$validators[self::$model]->getRules(self::$data['role'])) as $key => $value) {
110
+        foreach ((self::$validators[self::$model]->getRules(self::$data['role'])) as $key => $value) {
111 111
 
112 112
 			foreach (json_decode(self::$data['data']) as $keyy => $valuee) {
113 113
 
114
-				if(!array_key_exists($keyy, (self::$validators[self::$model]->getRules(self::$data['role'])) )){
114
+				if (!array_key_exists($keyy, (self::$validators[self::$model]->getRules(self::$data['role'])))) {
115 115
                     throw new Exception("O campo '{$keyy}' não é esperado para está operação.");
116 116
                 }
117 117
 
118
-				if($keyy===$key){
118
+				if ($keyy===$key) {
119 119
 
120 120
                     unset(self::$required[$key]);
121 121
 
122 122
 					foreach ($value as $subkey => $subvalue) {
123 123
                         $function = "check_{$subkey}";
124 124
                         self::testMethod($function);
125
-                        self::$function($keyy,$subvalue);
125
+                        self::$function($keyy, $subvalue);
126 126
 					}
127 127
 				}
128 128
 			}
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 
137 137
     public static function testMethod($method)
138 138
     {
139
-        if(!method_exists(static::class, $method)){
139
+        if (!method_exists(static::class, $method)) {
140 140
             throw new Exception("{$method} não é uma validação válida.");
141 141
         }
142 142
     }
@@ -150,20 +150,20 @@  discard block
 block discarded – undo
150 150
 
151 151
         self::includeValidations();
152 152
 
153
-        self::$model = get_class( self::getClass('HnrAzevedo\\Validator\\'.ucfirst($request['provider'])) );
153
+        self::$model = get_class(self::getClass('HnrAzevedo\\Validator\\'.ucfirst($request['provider'])));
154 154
 
155 155
         self::existRole(self::$model);
156 156
 
157
-		foreach ( self::$validators[self::$model]->getRules($request['role'])  as $field => $r) {
157
+		foreach (self::$validators[self::$model]->getRules($request['role'])  as $field => $r) {
158 158
             
159 159
             $response .= ("{$field}:".json_encode(array_reverse($r))).',';
160 160
             
161 161
         }
162 162
 
163
-        $response = '{'.substr($response,0,-1).'}';
164
-        $response = str_replace(',"',',',$response);
165
-        $response = str_replace('{"','',$response);
166
-        $response = str_replace('":',':',$response);
163
+        $response = '{'.substr($response, 0, -1).'}';
164
+        $response = str_replace(',"', ',', $response);
165
+        $response = str_replace('{"', '', $response);
166
+        $response = str_replace('":', ':', $response);
167 167
 
168 168
 		return $response;
169 169
 	}
Please login to merge, or discard this patch.
src/Check.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 namespace HnrAzevedo\Validator;
4 4
 
5
-Trait Check{
5
+Trait Check {
6 6
     protected static array $data = [];
7 7
     protected static array $validators = [];
8 8
     protected static string $model = '';
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
 
12 12
     protected static function check_minlength(string $param, $value)
13 13
     {
14
-        if(self::toNext($param,$value)){    
14
+        if (self::toNext($param, $value)) {    
15 15
             
16 16
             $realval = (is_array(json_decode(self::$data['data'])->$param)) ? json_decode(self::$data['data'])->$param : [json_decode(self::$data['data'])->$param];
17 17
 
18
-            foreach($realval as $val){
19
-                if($value > strlen($val)) {
18
+            foreach ($realval as $val) {
19
+                if ($value>strlen($val)) {
20 20
                     self::$errors[] = "{$param} não atingiu o mínimo de caracteres esperado.";
21 21
                 }
22 22
             }
@@ -25,20 +25,20 @@  discard block
 block discarded – undo
25 25
 
26 26
     protected static function check_requireds()
27 27
     {
28
-        if(count(self::$required) > 0){
29
-            self::$errors[] = 'As seguintes informações não poderam ser validadas: '.implode(', ',array_keys(self::$required)).'.';
28
+        if (count(self::$required)>0) {
29
+            self::$errors[] = 'As seguintes informações não poderam ser validadas: '.implode(', ', array_keys(self::$required)).'.';
30 30
         }
31 31
     }
32 32
 
33 33
     protected static function check_regex(string $param, $value)
34 34
     {
35
-        if(self::toNext($param,$value)){
35
+        if (self::toNext($param, $value)) {
36 36
 
37 37
             $realval = (is_array(json_decode(self::$data['data'])->$param)) ? json_decode(self::$data['data'])->$param : [json_decode(self::$data['data'])->$param];
38 38
 
39
-            foreach($realval as $val){
39
+            foreach ($realval as $val) {
40 40
 
41
-                if(!preg_match(self::$validators[self::$model]->getRules(self::$data['role'])[$param]['regex'], $val)){
41
+                if (!preg_match(self::$validators[self::$model]->getRules(self::$data['role'])[$param]['regex'], $val)) {
42 42
                     self::$errors[] = "{$param} inválido(a).";
43 43
                 }  
44 44
 
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 
49 49
     protected static function check_mincount(string $param, $value)
50 50
     {
51
-        if(self::toNext($param,$value)){
51
+        if (self::toNext($param, $value)) {
52 52
             $array = self::testArray($param, json_decode(self::$data['data'])->$param);
53
-            if(count($array) < $value){
53
+            if (count($array)<$value) {
54 54
                 self::$errors[] = "{$param} não atingiu o mínimo esperado.";
55 55
             }
56 56
         }
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
 
59 59
     protected static function check_maxcount(string $param, $value)
60 60
     {
61
-        if(self::toNext($param,$value)){
61
+        if (self::toNext($param, $value)) {
62 62
             $array = self::testArray($param, json_decode(self::$data['data'])->$param);
63
-            if(count($array) > $value){
63
+            if (count($array)>$value) {
64 64
                 self::$errors[] = "{$param} ultrapassou o esperado.";
65 65
             }
66 66
         }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
     protected static function testArray(string $param, $value): ?array
70 70
     {
71
-        if(!is_array($value)){
71
+        if (!is_array($value)) {
72 72
             self::$errors[] = "Era esperado um informação em array para {$param}.";
73 73
         }
74 74
         return $value;
@@ -76,13 +76,13 @@  discard block
 block discarded – undo
76 76
 
77 77
     protected static function check_equals(string $param, $value)
78 78
     {
79
-        if(self::toNext($param,$value)){
79
+        if (self::toNext($param, $value)) {
80 80
 
81
-            if(!array_key_exists($param,json_decode(self::$data['data'],true))){
81
+            if (!array_key_exists($param, json_decode(self::$data['data'], true))) {
82 82
                 self::$errors[] = "O servidor não encontrou a informação '{$value}' para ser comparada a '{$param}'.";
83 83
             }
84 84
             
85
-            if(json_decode(self::$data['data'])->$param != json_decode(self::$data['data'],true)[$value]){
85
+            if (json_decode(self::$data['data'])->$param!=json_decode(self::$data['data'], true)[$value]) {
86 86
                 self::$errors[] = ucfirst($param).' está diferente de '.ucfirst($value);
87 87
             }
88 88
 
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
 
92 92
     protected static function check_maxlength(string $param, $value)
93 93
     {
94
-        if(self::toNext($param,$value)){
94
+        if (self::toNext($param, $value)) {
95 95
 
96 96
             $realval = (is_array(json_decode(self::$data['data'])->$param)) ? json_decode(self::$data['data'])->$param : [json_decode(self::$data['data'])->$param];
97 97
 
98
-            foreach($realval as $val){
98
+            foreach ($realval as $val) {
99 99
 
100
-                if($value < strlen($val)) {
100
+                if ($value<strlen($val)) {
101 101
                     self::$errors[] = "{$param} ultrapassou o máximo de caracteres esperado.";
102 102
                 }
103 103
         
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 
108 108
     protected static function check_type(string $param, $value)
109 109
     {
110
-        if(self::toNext($param,$value)){
110
+        if (self::toNext($param, $value)) {
111 111
 
112 112
             switch ($value) {
113 113
                 case 'date':
114
-                    if(!self::validateDate(json_decode(self::$data['data'])->$param , 'd/m/Y')){
114
+                    if (!self::validateDate(json_decode(self::$data['data'])->$param, 'd/m/Y')) {
115 115
                         self::$errors[] = "{$param} não é uma data válida.";
116 116
                     }
117 117
                     break;
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
 
122 122
     protected static function check_filter(string $param, $value)
123 123
     {
124
-        if(self::toNext($param,$value)){
124
+        if (self::toNext($param, $value)) {
125 125
 
126
-            if(!filter_var(json_decode(self::$data['data'])->$param, $value)){
126
+            if (!filter_var(json_decode(self::$data['data'])->$param, $value)) {
127 127
                 self::$errors[] = "{$param} não passou pela filtragem de dados.";
128 128
             }
129 129
 
@@ -133,17 +133,17 @@  discard block
 block discarded – undo
133 133
     public static function validateDate($date, $format = 'Y-m-d H:i:s')
134 134
     {
135 135
         $d = \DateTime::createFromFormat($format, $date);
136
-        return $d && $d->format($format) == $date;
136
+        return $d && $d->format($format)==$date;
137 137
     }
138 138
 
139 139
     protected static function check_required(string $param): bool
140 140
     {
141
-        return (array_key_exists('required',self::$validators[self::$model]->getRules(self::$data['role'])[$param]) && self::$validators[self::$model]->getRules(self::$data['role'])[$param]['required']);
141
+        return (array_key_exists('required', self::$validators[self::$model]->getRules(self::$data['role'])[$param]) && self::$validators[self::$model]->getRules(self::$data['role'])[$param]['required']);
142 142
     }
143 143
 
144 144
     protected static function toNext(string $param, $value)
145 145
     {
146
-        return (self::check_required($param) || strlen($value > 0));
146
+        return (self::check_required($param) || strlen($value>0));
147 147
     }
148 148
 
149 149
 }
150 150
\ No newline at end of file
Please login to merge, or discard this patch.