Passed
Push — master ( 3d96d8...b2d9fe )
by Henri
01:28
created
src/Rules.php 1 patch
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.
examples/Rules/User.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -11,15 +11,15 @@
 block discarded – undo
11 11
     {
12 12
         Validator::add($this, function(Rules $rules){
13 13
             $rules->setAction('login')
14
-                  //->addField('email',['minlength'=>1,'regex'=>'/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/','required'=>true])
15
-                  ->addField('email',['minlength'=>1,'filter'=>FILTER_VALIDATE_EMAIL,'required'=>true])
16
-                  ->addField('password',['minlength'=>6,'maxlength'=>20,'required'=>true])
17
-                  ->addField('password2',['equals'=>'password','required'=>true])
18
-                  ->addField('remember',['minlength'=>2,'maxlength'=>2,'required'=>false])
19
-                  ->addField('birth',['type'=>'date','required'=>true])
20
-                  ->addField('phones',['mincount'=>2,'maxcount'=>3,'required'=>true,'minlength'=>8,'maxlength'=>9]);
14
+                    //->addField('email',['minlength'=>1,'regex'=>'/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/','required'=>true])
15
+                    ->addField('email',['minlength'=>1,'filter'=>FILTER_VALIDATE_EMAIL,'required'=>true])
16
+                    ->addField('password',['minlength'=>6,'maxlength'=>20,'required'=>true])
17
+                    ->addField('password2',['equals'=>'password','required'=>true])
18
+                    ->addField('remember',['minlength'=>2,'maxlength'=>2,'required'=>false])
19
+                    ->addField('birth',['type'=>'date','required'=>true])
20
+                    ->addField('phones',['mincount'=>2,'maxcount'=>3,'required'=>true,'minlength'=>8,'maxlength'=>9]);
21 21
 
22
-			return $rules;
22
+            return $rules;
23 23
         });
24 24
 
25 25
         return $this;
Please login to merge, or discard this patch.
src/Validator.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
             self::getInstance()->errors[] = $er->getMessage();
78 78
         }
79 79
         
80
-		return self::checkErrors();
80
+        return self::checkErrors();
81 81
     }
82 82
 
83 83
     public static function checkErrors(): bool
@@ -89,21 +89,21 @@  discard block
 block discarded – undo
89 89
     {
90 90
         foreach ( (self::getInstance()->validator(self::getInstance()->model)->getRules(self::getInstance()->data['ROLE'])) as $key => $value) {
91 91
 
92
-			foreach (self::getInstance()->data as $keyy => $valuee) {
92
+            foreach (self::getInstance()->data as $keyy => $valuee) {
93 93
 
94
-				self::getInstance()->checkExpected($keyy);
94
+                self::getInstance()->checkExpected($keyy);
95 95
 
96
-				if($keyy===$key){
96
+                if($keyy===$key){
97 97
 
98 98
                     unset(self::getInstance()->required[$key]);
99 99
 
100
-					foreach ($value as $subkey => $subvalue) {
100
+                    foreach ($value as $subkey => $subvalue) {
101 101
                         $function = "check".ucfirst($subkey);
102 102
                         self::getInstance()->testMethod($function);
103 103
                         self::getInstance()->$function($keyy, $subvalue);
104
-					}
105
-				}
106
-			}
104
+                    }
105
+                }
106
+            }
107 107
         }
108 108
     }
109 109
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 
142 142
         self::getInstance()->existRole(self::getInstance()->model());
143 143
 
144
-		foreach ( self::getInstance()->validator(self::getInstance()->model())->getRules($request['ROLE'])  as $field => $r) {
144
+        foreach ( self::getInstance()->validator(self::getInstance()->model())->getRules($request['ROLE'])  as $field => $r) {
145 145
             $r = self::getInstance()->replaceRegex($r);
146 146
             $response .= ("{$field}:".json_encode(array_reverse($r))).',';
147 147
         }
Please login to merge, or discard this patch.