Passed
Pull Request — master (#360)
by Valentin
04:12
created
src/Validation/src/AbstractValidator.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -112,30 +112,30 @@
 block discarded – undo
112 112
      */
113 113
     final protected function validate(): void
114 114
     {
115
-        if ($this->errors !== []) {
115
+        if ($this->errors !== []){
116 116
             // already validated
117 117
             return;
118 118
         }
119 119
 
120 120
         $this->errors = [];
121 121
 
122
-        foreach ($this->rules as $field => $rules) {
122
+        foreach ($this->rules as $field => $rules){
123 123
             $hasValue = $this->hasValue($field);
124 124
             $value = $this->getValue($field);
125 125
 
126
-            foreach ($this->provider->getRules($rules) as $rule) {
127
-                if (!$hasValue && $rule->ignoreEmpty($value) && !$rule->hasConditions()) {
126
+            foreach ($this->provider->getRules($rules) as $rule){
127
+                if (!$hasValue && $rule->ignoreEmpty($value) && !$rule->hasConditions()){
128 128
                     continue;
129 129
                 }
130 130
 
131
-                foreach ($rule->getConditions() as $condition) {
132
-                    if (!$condition->isMet($this, $field, $value)) {
131
+                foreach ($rule->getConditions() as $condition){
132
+                    if (!$condition->isMet($this, $field, $value)){
133 133
                         // condition is not met, skipping validation
134 134
                         continue 2;
135 135
                     }
136 136
                 }
137 137
 
138
-                if (!$rule->validate($this, $field, $value)) {
138
+                if (!$rule->validate($this, $field, $value)){
139 139
                     // got error, jump to next field
140 140
                     $this->errors[$field] = $rule->getMessage($field, $value);
141 141
                     break;
Please login to merge, or discard this patch.
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -112,30 +112,37 @@
 block discarded – undo
112 112
      */
113 113
     final protected function validate(): void
114 114
     {
115
-        if ($this->errors !== []) {
115
+        if ($this->errors !== [])
116
+        {
116 117
             // already validated
117 118
             return;
118 119
         }
119 120
 
120 121
         $this->errors = [];
121 122
 
122
-        foreach ($this->rules as $field => $rules) {
123
+        foreach ($this->rules as $field => $rules)
124
+        {
123 125
             $hasValue = $this->hasValue($field);
124 126
             $value = $this->getValue($field);
125 127
 
126
-            foreach ($this->provider->getRules($rules) as $rule) {
127
-                if (!$hasValue && $rule->ignoreEmpty($value) && !$rule->hasConditions()) {
128
+            foreach ($this->provider->getRules($rules) as $rule)
129
+            {
130
+                if (!$hasValue && $rule->ignoreEmpty($value) && !$rule->hasConditions())
131
+                {
128 132
                     continue;
129 133
                 }
130 134
 
131
-                foreach ($rule->getConditions() as $condition) {
132
-                    if (!$condition->isMet($this, $field, $value)) {
135
+                foreach ($rule->getConditions() as $condition)
136
+                {
137
+                    if (!$condition->isMet($this, $field, $value))
138
+                    {
133 139
                         // condition is not met, skipping validation
134 140
                         continue 2;
135 141
                     }
136 142
                 }
137 143
 
138
-                if (!$rule->validate($this, $field, $value)) {
144
+                if (!$rule->validate($this, $field, $value))
145
+                {
139 146
                     // got error, jump to next field
140 147
                     $this->errors[$field] = $rule->getMessage($field, $value);
141 148
                     break;
Please login to merge, or discard this patch.
src/Validation/src/Validator.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     {
56 56
         $value = $this->data[$field] ?? $default;
57 57
 
58
-        if (is_object($value) && method_exists($value, 'getValue')) {
58
+        if (is_object($value) && method_exists($value, 'getValue')){
59 59
             return $value->getValue();
60 60
         }
61 61
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public function hasValue(string $field): bool
69 69
     {
70
-        if (is_array($this->data)) {
70
+        if (is_array($this->data)){
71 71
             return array_key_exists($field, $this->data);
72 72
         }
73 73
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,7 +55,8 @@  discard block
 block discarded – undo
55 55
     {
56 56
         $value = $this->data[$field] ?? $default;
57 57
 
58
-        if (is_object($value) && method_exists($value, 'getValue')) {
58
+        if (is_object($value) && method_exists($value, 'getValue'))
59
+        {
59 60
             return $value->getValue();
60 61
         }
61 62
 
@@ -67,7 +68,8 @@  discard block
 block discarded – undo
67 68
      */
68 69
     public function hasValue(string $field): bool
69 70
     {
70
-        if (is_array($this->data)) {
71
+        if (is_array($this->data))
72
+        {
71 73
             return array_key_exists($field, $this->data);
72 74
         }
73 75
 
Please login to merge, or discard this patch.