Passed
Push — master ( 42c6c4...6eb781 )
by Henri
06:37
created
src/Validator.php 3 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
             self::getInstance()->errors[] = $er->getMessage();
89 89
         }
90 90
         
91
-		return self::errors();
91
+        return self::errors();
92 92
     }
93 93
 
94 94
     public static function errors(): bool
@@ -100,22 +100,22 @@  discard block
 block discarded – undo
100 100
     {
101 101
         foreach ( (self::getInstance()->validator(self::getInstance()->model)->getRules(self::getInstance()->data['_ROLE'])) as $key => $value) {
102 102
 
103
-			foreach (self::getInstance()->data as $keyy => $valuee) {
103
+            foreach (self::getInstance()->data as $keyy => $valuee) {
104 104
 
105
-				self::getInstance()->checkExpected($keyy);
105
+                self::getInstance()->checkExpected($keyy);
106 106
 
107
-				if($keyy===$key){
107
+                if($keyy===$key){
108 108
 
109 109
                     unset(self::getInstance()->required[$key]);
110 110
 
111
-					foreach ($value as $subkey => $subvalue) {
111
+                    foreach ($value as $subkey => $subvalue) {
112 112
 
113 113
                         $function = strtolower($subkey);
114 114
 
115 115
                         self::getInstance()->hasMethod($function)->$function($keyy, $subvalue);
116
-					}
117
-				}
118
-			}
116
+                    }
117
+                }
118
+            }
119 119
         }
120 120
     }
121 121
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 
156 156
         self::getInstance()->existRole(self::getInstance()->model());
157 157
 
158
-		foreach ( self::getInstance()->validator(self::getInstance()->model())->getRules($request['_ROLE'])  as $field => $r) {
158
+        foreach ( self::getInstance()->validator(self::getInstance()->model())->getRules($request['_ROLE'])  as $field => $r) {
159 159
             $r = self::getInstance()->replaceRegex($r);
160 160
             $response .= ("'$field':".json_encode(array_reverse($r))).',';
161 161
         }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
     public function __construct()
16 16
     {
17
-        require __DIR__.DIRECTORY_SEPARATOR.'languages'. DIRECTORY_SEPARATOR . self::$lang .'.php';
17
+        require __DIR__.DIRECTORY_SEPARATOR.'languages'.DIRECTORY_SEPARATOR.self::$lang.'.php';
18 18
         self::$err = $VALIDATOR_LANG;
19 19
     }
20 20
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
     private static function getClass(string $class)
40 40
     {
41
-        if(!class_exists($class)){
41
+        if (!class_exists($class)) {
42 42
             throw new \RuntimeException("Form ID {$class} inválido");
43 43
         }
44 44
 
@@ -49,21 +49,21 @@  discard block
 block discarded – undo
49 49
 
50 50
     private function existRole($getRules)
51 51
     {
52
-        if(empty(self::getInstance()->validator($getRules)->getRules(self::getInstance()->data['_ROLE']))){
52
+        if (empty(self::getInstance()->validator($getRules)->getRules(self::getInstance()->data['_ROLE']))) {
53 53
             throw new \RuntimeException('Não existe regras para validar este formulário');
54 54
         }
55 55
     }
56 56
 
57 57
     public function checkDatas(array $data): void
58 58
     {
59
-        if(!isset($data['_PROVIDER']) || !isset($data['_ROLE'])){
59
+        if (!isset($data['_PROVIDER']) || !isset($data['_ROLE'])) {
60 60
             throw new \RuntimeException('The server did not receive the information needed to retrieve the requested validator');
61 61
         }
62 62
     }
63 63
 
64 64
     public static function execute(array $data): bool
65 65
     {
66
-        try{
66
+        try {
67 67
             self::getInstance()->checkDatas($data);
68 68
 
69 69
             self::getInstance()->data = $data;
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 
75 75
             self::getInstance()->existRole(self::getInstance()->model);
76 76
                 
77
-            foreach ( (self::getInstance()->validator(self::getInstance()->model)->getRules($data['_ROLE'])) as $key => $value) {
78
-                if(@$value['required'] === true){
77
+            foreach ((self::getInstance()->validator(self::getInstance()->model)->getRules($data['_ROLE'])) as $key => $value) {
78
+                if (@$value['required']===true) {
79 79
                     self::getInstance()->required[$key] = $value;
80 80
                 }
81 81
             }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
         
85 85
             self::getInstance()->validate();
86 86
             self::getInstance()->requireds();
87
-        }catch(\Exception $er){
87
+        }catch (\Exception $er) {
88 88
             self::getInstance()->errors[] = $er->getMessage();
89 89
         }
90 90
         
@@ -93,18 +93,18 @@  discard block
 block discarded – undo
93 93
 
94 94
     public static function errors(): bool
95 95
     {
96
-        return (count(self::getInstance()->errors) === 0);
96
+        return (count(self::getInstance()->errors)===0);
97 97
     }
98 98
     
99 99
     public function validate(): void
100 100
     {
101
-        foreach ( (self::getInstance()->validator(self::getInstance()->model)->getRules(self::getInstance()->data['_ROLE'])) as $key => $value) {
101
+        foreach ((self::getInstance()->validator(self::getInstance()->model)->getRules(self::getInstance()->data['_ROLE'])) as $key => $value) {
102 102
 
103 103
 			foreach (self::getInstance()->data as $keyy => $valuee) {
104 104
 
105 105
 				self::getInstance()->checkExpected($keyy);
106 106
 
107
-				if($keyy===$key){
107
+				if ($keyy===$key) {
108 108
 
109 109
                     unset(self::getInstance()->required[$key]);
110 110
 
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
 
122 122
     private function checkExpected(string $keyy): void
123 123
     {
124
-        if(!array_key_exists($keyy, (self::getInstance()->validator(self::getInstance()->model)->getRules(self::getInstance()->data['_ROLE'])) ) && !in_array($keyy, self::getInstance()->defaultData)){
125
-            throw new \RuntimeException($keyy . self::$err['nExpected']);
124
+        if (!array_key_exists($keyy, (self::getInstance()->validator(self::getInstance()->model)->getRules(self::getInstance()->data['_ROLE']))) && !in_array($keyy, self::getInstance()->defaultData)) {
125
+            throw new \RuntimeException($keyy.self::$err['nExpected']);
126 126
         }
127 127
     }
128 128
 
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 
134 134
     public function hasMethod($method): Validator
135 135
     {
136
-        if(!method_exists(static::class, $method)){
137
-            throw new \RuntimeException($method . self::$err['nMethod']);
136
+        if (!method_exists(static::class, $method)) {
137
+            throw new \RuntimeException($method.self::$err['nMethod']);
138 138
         }
139 139
         
140 140
         return $this;
@@ -155,17 +155,17 @@  discard block
 block discarded – undo
155 155
 
156 156
         self::getInstance()->existRole(self::getInstance()->model());
157 157
 
158
-		foreach ( self::getInstance()->validator(self::getInstance()->model())->getRules($request['_ROLE'])  as $field => $r) {
158
+		foreach (self::getInstance()->validator(self::getInstance()->model())->getRules($request['_ROLE'])  as $field => $r) {
159 159
             $r = self::getInstance()->replaceRegex($r);
160 160
             $response .= ("'$field':".json_encode(array_reverse($r))).',';
161 161
         }
162 162
 
163
-        return '{'.substr($response,0,-1).'}';
163
+        return '{'.substr($response, 0, -1).'}';
164 164
     }
165 165
     
166 166
     private function replaceRegex(array $getRules): array
167 167
     {
168
-        if(array_key_exists('regex', $getRules)){ 
168
+        if (array_key_exists('regex', $getRules)) { 
169 169
             $getRules['regex'] = substr($getRules['regex'], 1, -2);
170 170
         }
171 171
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
         
85 85
             self::getInstance()->validate();
86 86
             self::getInstance()->requireds();
87
-        }catch(\Exception $er){
87
+        } catch(\Exception $er){
88 88
             self::getInstance()->errors[] = $er->getMessage();
89 89
         }
90 90
         
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.
src/Rules.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,29 +12,29 @@
 block discarded – undo
12 12
 
13 13
     public function __construct(object $model)
14 14
     {
15
-	    $this->form['model'] = ucfirst(get_class($model));
16
-	}
15
+        $this->form['model'] = ucfirst(get_class($model));
16
+    }
17 17
 
18 18
     public function action(string $action): Rules
19 19
     {
20
-	    $this->action = $action;
21
-	    return $this;
22
-	}
20
+        $this->action = $action;
21
+        return $this;
22
+    }
23 23
 
24 24
     public function field(string $field, array $test, ?string $placeholder = null): Rules
25 25
     {
26
-	    if(empty($this->action)){
26
+        if(empty($this->action)){
27 27
             self::$errors[] = self::$err['nFoundForm'];
28 28
             return $this;
29 29
         }
30 30
 
31 31
         $this->form[$this->action][$field] = $test;
32 32
         $this->form[$this->action][$field]['placeholder'] = (null !== $placeholder) ? $placeholder : $test;
33
-	    return $this;
34
-  	}
33
+        return $this;
34
+        }
35 35
 
36 36
     public function getRules(string $action): Array
37 37
     {
38
-		return (array_key_exists($action, $this->form)) ? $this->form[$action] : [];
39
-	}
38
+        return (array_key_exists($action, $this->form)) ? $this->form[$action] : [];
39
+    }
40 40
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,13 +23,13 @@
 block discarded – undo
23 23
 
24 24
     public function field(string $field, array $test, ?string $placeholder = null): Rules
25 25
     {
26
-	    if(empty($this->action)){
26
+	    if (empty($this->action)) {
27 27
             self::$errors[] = self::$err['nFoundForm'];
28 28
             return $this;
29 29
         }
30 30
 
31 31
         $this->form[$this->action][$field] = $test;
32
-        $this->form[$this->action][$field]['placeholder'] = (null !== $placeholder) ? $placeholder : $test;
32
+        $this->form[$this->action][$field]['placeholder'] = (null!==$placeholder) ? $placeholder : $test;
33 33
 	    return $this;
34 34
   	}
35 35
 
Please login to merge, or discard this patch.
src/Helper.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -16,12 +16,12 @@  discard block
 block discarded – undo
16 16
 
17 17
     protected static function array($value): Array
18 18
     {
19
-        return (is_array($value)) ? $value : [ $value ];
19
+        return (is_array($value)) ? $value : [$value];
20 20
     }
21 21
 
22 22
     protected static function getInstance(?string $lang = null): Validator
23 23
     {
24
-        self::$lang = (null !== $lang) ? $lang : 'en';
24
+        self::$lang = (null!==$lang) ? $lang : 'en';
25 25
         self::$instance = (isset(self::$instance)) ? self::$instance : new Validator();
26 26
         return self::$instance;
27 27
     }
@@ -33,10 +33,10 @@  discard block
 block discarded – undo
33 33
 
34 34
     protected function data($field = null, ?array $values = null)
35 35
     {
36
-        if(null !== $values){
36
+        if (null!==$values) {
37 37
             $this->data[$field] = $values;
38 38
         }
39
-        if(null !== $field){
39
+        if (null!==$field) {
40 40
             return $this->data[$field];
41 41
         }
42 42
         return $this->data;
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 
45 45
     protected function validator(string $model, ?object $callback = null)
46 46
     {
47
-        if(null !== $callback){
47
+        if (null!==$callback) {
48 48
             $this->validators[$model] = $callback;
49 49
         }
50 50
         return $this->validators[$model];
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
     protected function model(?string $model = null): string
54 54
     {
55
-        if(null !== $model){
55
+        if (null!==$model) {
56 56
             $this->model = $model;
57 57
         }
58 58
         return $this->model;
Please login to merge, or discard this patch.
src/Check.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -9,19 +9,19 @@  discard block
 block discarded – undo
9 9
 
10 10
     protected function minlength(string $param, int $value): void
11 11
     {
12
-        if(!self::getInstance()->valid($param, self::getInstance()->data($param))){ 
12
+        if (!self::getInstance()->valid($param, self::getInstance()->data($param))) { 
13 13
             return;
14 14
         }
15 15
 
16
-        foreach( self::array(self::getInstance()->data($param)) as $val ){
16
+        foreach (self::array(self::getInstance()->data($param)) as $val) {
17 17
 
18
-            if(strlen($val) === 0) {
19
-                self::getInstance()->error([ $param => self::$err['required'] ]);
18
+            if (strlen($val)===0) {
19
+                self::getInstance()->error([$param => self::$err['required']]);
20 20
                 continue;
21 21
             }
22 22
 
23
-            if($value > strlen($val)){
24
-                self::getInstance()->error([ $param => self::$err['minlength'] ]);
23
+            if ($value>strlen($val)) {
24
+                self::getInstance()->error([$param => self::$err['minlength']]);
25 25
             }
26 26
 
27 27
         }
@@ -30,76 +30,76 @@  discard block
 block discarded – undo
30 30
 
31 31
     protected function regex(string $param, string $value): void
32 32
     {
33
-        if(!self::getInstance()->valid($param, self::getInstance()->data($param))){
33
+        if (!self::getInstance()->valid($param, self::getInstance()->data($param))) {
34 34
             return;
35 35
         }
36 36
 
37
-        foreach(self::array(self::getInstance()->data($param)) as $val){
38
-            if(!preg_match($value, $val)){
39
-                self::getInstance()->error([ $param => self::$err['regex'] ]);
37
+        foreach (self::array(self::getInstance()->data($param)) as $val) {
38
+            if (!preg_match($value, $val)) {
39
+                self::getInstance()->error([$param => self::$err['regex']]);
40 40
             }  
41 41
         }  
42 42
     }
43 43
 
44 44
     protected function mincount(string $param, string $value): void
45 45
     {
46
-        if(!self::getInstance()->valid($param, self::getInstance()->data($param))){
46
+        if (!self::getInstance()->valid($param, self::getInstance()->data($param))) {
47 47
             return;
48 48
         }
49 49
 
50
-        if(count(self::array(self::getInstance()->data($param))) < intval($value)){
51
-            self::getInstance()->error([ $param => self::$err['mincount'] ]);
50
+        if (count(self::array(self::getInstance()->data($param)))<intval($value)) {
51
+            self::getInstance()->error([$param => self::$err['mincount']]);
52 52
         }
53 53
         
54 54
     }
55 55
 
56 56
     protected function maxcount(string $param, string $value): void
57 57
     {
58
-        if(!self::getInstance()->valid($param, self::getInstance()->data($param))){
58
+        if (!self::getInstance()->valid($param, self::getInstance()->data($param))) {
59 59
             return;
60 60
         }
61 61
         
62
-        if(count(self::array(self::getInstance()->data($param))) > intval($value)){
63
-            self::getInstance()->error([ $param => self::$err['maxcount'] ]);
62
+        if (count(self::array(self::getInstance()->data($param)))>intval($value)) {
63
+            self::getInstance()->error([$param => self::$err['maxcount']]);
64 64
         }
65 65
         
66 66
     }
67 67
 
68 68
     protected function equals(string $param, string $value): void
69 69
     {
70
-        if(!array_key_exists($param, self::getInstance()->data())){
71
-            self::getInstance()->error([ $param => $value . self::$err['nFoundEquals'] ]);
70
+        if (!array_key_exists($param, self::getInstance()->data())) {
71
+            self::getInstance()->error([$param => $value.self::$err['nFoundEquals']]);
72 72
             return;
73 73
         }
74 74
             
75
-        if(self::getInstance()->data($param) != self::getInstance()->data($value)){
76
-            self::getInstance()->error([ $param => self::$err['equals'] . ucfirst($value) ]);
75
+        if (self::getInstance()->data($param)!=self::getInstance()->data($value)) {
76
+            self::getInstance()->error([$param => self::$err['equals'].ucfirst($value)]);
77 77
         } 
78 78
     }
79 79
 
80 80
     protected function maxlength(string $param, string $value): void
81 81
     {
82
-        if(!self::getInstance()->valid($param, self::getInstance()->data($param))){
82
+        if (!self::getInstance()->valid($param, self::getInstance()->data($param))) {
83 83
             return;
84 84
         }
85 85
 
86
-        foreach( self::array(self::getInstance()->data($param)) as $val ){
87
-            if(intval($value) < strlen($val)) {
88
-                self::getInstance()->error([ $param => self::$err['maxlength'] ]);
86
+        foreach (self::array(self::getInstance()->data($param)) as $val) {
87
+            if (intval($value)<strlen($val)) {
88
+                self::getInstance()->error([$param => self::$err['maxlength']]);
89 89
             }
90 90
         }
91 91
     }
92 92
 
93 93
     protected function type(string $param, string $value): void
94 94
     {
95
-        if(!self::getInstance()->valid($param, self::getInstance()->data($param))){
95
+        if (!self::getInstance()->valid($param, self::getInstance()->data($param))) {
96 96
             return;
97 97
         }
98 98
 
99 99
         switch ($value) {
100 100
             case 'date':
101
-                if(!self::getInstance()->validateDate(self::getInstance()->data($param) , 'd/m/Y')){
102
-                    self::getInstance()->error([ $param => self::$err['type'] ]);
101
+                if (!self::getInstance()->validateDate(self::getInstance()->data($param), 'd/m/Y')) {
102
+                    self::getInstance()->error([$param => self::$err['type']]);
103 103
                 }
104 104
             break;
105 105
         }
@@ -108,12 +108,12 @@  discard block
 block discarded – undo
108 108
 
109 109
     protected function filter(string $param, string $value): void
110 110
     {
111
-        if(!self::getInstance()->valid($param, self::getInstance()->data($param))){
111
+        if (!self::getInstance()->valid($param, self::getInstance()->data($param))) {
112 112
             return;
113 113
         }
114 114
             
115
-        if(!filter_var(self::getInstance()->data($param), $value)){
116
-            self::getInstance()->error([ $param => self::$err['filter'] ]);
115
+        if (!filter_var(self::getInstance()->data($param), $value)) {
116
+            self::getInstance()->error([$param => self::$err['filter']]);
117 117
         }
118 118
         
119 119
     }
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
     'password' => '123456',
7 7
     'password2' => '1234567777777777777777777777777777777777777777777',
8 8
     'phones' => [
9
-        '949164770','949164771','949164772'
9
+        '949164770', '949164771', '949164772'
10 10
     ],
11 11
     'birth' => '28/09/1996',
12 12
     '_PROVIDER' => 'user',
Please login to merge, or discard this patch.
examples/DefaultUseExample.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -4,18 +4,18 @@  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::namespace('HnrAzevedo\\Validator\\Example\\Rules')->lang('pt_br')->execute($data);
11 11
     
12 12
     $errors = [];
13 13
 
14
-    if(!$valid){
15
-        foreach(Validator::getErrors() as $err => $message){
14
+    if (!$valid) {
15
+        foreach (Validator::getErrors() as $err => $message) {
16 16
             
17 17
             $errors[] = [
18
-                'input' => $err,                 // Return name input error
18
+                'input' => $err, // Return name input error
19 19
                 'message' => $message            // Return message error
20 20
             ];
21 21
         }
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
     /* Transforms validation to Json format to be validated on the client if desired */
27 27
     $json = Validator::namespace('HnrAzevedo\\Validator\\Example\\Rules')->toJson($data);
28 28
 
29
-}catch(Exception $er){
29
+}catch (Exception $er) {
30 30
 
31 31
     die("Code Error: {$er->getCode()}<br> Line: {$er->getLine()}<br> File: {$er->getFile()}<br> Message: {$er->getMessage()}");
32 32
 
Please login to merge, or discard this patch.
examples/Rules/User.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -11,19 +11,19 @@
 block discarded – undo
11 11
     {
12 12
         Validator::add($this, function(Rules $rules){
13 13
             $rules->action('login')
14
-                  ->field('email',[
15
-                      'minlength' => 1,
16
-                      'filter' => FILTER_VALIDATE_EMAIL,
17
-                      'regex' => '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/',
18
-                      'required' => true
19
-                  ], 'Email address')
20
-                  ->field('password',['minlength'=>6,'maxlength'=>20,'required'=>true])
21
-                  ->field('password2',['minlength'=>6,'maxlength'=>20,'equals'=>'password','required'=>true])
22
-                  ->field('remember',['minlength'=>2,'maxlength'=>2,'required'=>false])
23
-                  ->field('birth',['type'=>'date','required'=>true])
24
-                  ->field('phones',['mincount'=>2,'maxcount'=>3,'required'=>true,'minlength'=>8,'maxlength'=>9]);
14
+                    ->field('email',[
15
+                        'minlength' => 1,
16
+                        'filter' => FILTER_VALIDATE_EMAIL,
17
+                        'regex' => '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/',
18
+                        'required' => true
19
+                    ], 'Email address')
20
+                    ->field('password',['minlength'=>6,'maxlength'=>20,'required'=>true])
21
+                    ->field('password2',['minlength'=>6,'maxlength'=>20,'equals'=>'password','required'=>true])
22
+                    ->field('remember',['minlength'=>2,'maxlength'=>2,'required'=>false])
23
+                    ->field('birth',['type'=>'date','required'=>true])
24
+                    ->field('phones',['mincount'=>2,'maxcount'=>3,'required'=>true,'minlength'=>8,'maxlength'=>9]);
25 25
 
26
-			return $rules;
26
+            return $rules;
27 27
         });
28 28
 
29 29
         return $this;
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -5,23 +5,23 @@
 block discarded – undo
5 5
 use HnrAzevedo\Validator\Validator;
6 6
 use HnrAzevedo\Validator\Rules;
7 7
 
8
-Class User{
8
+Class User {
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
-                  ->field('email',[
14
+                  ->field('email', [
15 15
                       'minlength' => 1,
16 16
                       'filter' => FILTER_VALIDATE_EMAIL,
17 17
                       'regex' => '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/',
18 18
                       'required' => true
19 19
                   ], 'Email address')
20
-                  ->field('password',['minlength'=>6,'maxlength'=>20,'required'=>true])
21
-                  ->field('password2',['minlength'=>6,'maxlength'=>20,'equals'=>'password','required'=>true])
22
-                  ->field('remember',['minlength'=>2,'maxlength'=>2,'required'=>false])
23
-                  ->field('birth',['type'=>'date','required'=>true])
24
-                  ->field('phones',['mincount'=>2,'maxcount'=>3,'required'=>true,'minlength'=>8,'maxlength'=>9]);
20
+                  ->field('password', ['minlength'=>6, 'maxlength'=>20, 'required'=>true])
21
+                  ->field('password2', ['minlength'=>6, 'maxlength'=>20, 'equals'=>'password', 'required'=>true])
22
+                  ->field('remember', ['minlength'=>2, 'maxlength'=>2, 'required'=>false])
23
+                  ->field('birth', ['type'=>'date', 'required'=>true])
24
+                  ->field('phones', ['mincount'=>2, 'maxcount'=>3, 'required'=>true, 'minlength'=>8, 'maxlength'=>9]);
25 25
 
26 26
 			return $rules;
27 27
         });
Please login to merge, or discard this patch.