Completed
Push — master ( f283ed...875b97 )
by Neomerx
05:05
created
src/Rules/Generic/Enum.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -76,8 +76,7 @@
 block discarded – undo
76 76
         $isOk   = in_array($value, $values);
77 77
 
78 78
         return $isOk === true ?
79
-            BlockReplies::createSuccessReply($value) :
80
-            BlockReplies::createErrorReply($context, $value, ErrorCodes::INVALID_VALUE);
79
+            BlockReplies::createSuccessReply($value) : BlockReplies::createErrorReply($context, $value, ErrorCodes::INVALID_VALUE);
81 80
     }
82 81
 
83 82
     /**
Please login to merge, or discard this patch.
src/Contracts/Errors/ErrorInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,5 +39,5 @@
 block discarded – undo
39 39
     /**
40 40
      * @return array|null
41 41
      */
42
-    public function getMessageContext(): ?array;
42
+    public function getMessageContext(): ? array;
43 43
 }
Please login to merge, or discard this patch.
src/Rules/Generic/Filter.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -105,8 +105,7 @@
 block discarded – undo
105 105
         $output = filter_var($value, $filterId, $filterOptions);
106 106
 
107 107
         return $output !== false ?
108
-            BlockReplies::createSuccessReply($output) :
109
-            BlockReplies::createErrorReply($context, $value, $errorCode, [$filterId, $filterOptions]);
108
+            BlockReplies::createSuccessReply($output) : BlockReplies::createErrorReply($context, $value, $errorCode, [$filterId, $filterOptions]);
110 109
     }
111 110
 
112 111
     /**
Please login to merge, or discard this patch.
src/Validator/Comparisons.php 1 patch
Spacing   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -105,8 +105,7 @@  discard block
 block discarded – undo
105 105
     protected static function lessThan($value, RuleInterface $next = null): RuleInterface
106 106
     {
107 107
         return $next === null ?
108
-            $value instanceof DateTimeInterface ? new DateTimeLessThan($value) : new NumericLessThan($value) :
109
-            new AndOperator(static::lessThan($value), $next);
108
+            $value instanceof DateTimeInterface ? new DateTimeLessThan($value) : new NumericLessThan($value) : new AndOperator(static::lessThan($value), $next);
110 109
     }
111 110
 
112 111
     /**
@@ -118,8 +117,7 @@  discard block
 block discarded – undo
118 117
     protected static function lessOrEquals($value, RuleInterface $next = null): RuleInterface
119 118
     {
120 119
         return $next === null ?
121
-            $value instanceof DateTimeInterface ? new DateTimeLessOrEquals($value) : new NumericLessOrEquals($value) :
122
-            new AndOperator(static::lessOrEquals($value), $next);
120
+            $value instanceof DateTimeInterface ? new DateTimeLessOrEquals($value) : new NumericLessOrEquals($value) : new AndOperator(static::lessOrEquals($value), $next);
123 121
     }
124 122
 
125 123
     /**
@@ -131,8 +129,7 @@  discard block
 block discarded – undo
131 129
     protected static function moreThan($value, RuleInterface $next = null): RuleInterface
132 130
     {
133 131
         return $next === null ?
134
-            $value instanceof DateTimeInterface ? new DateTimeMoreThan($value) : new NumericMoreThan($value) :
135
-            new AndOperator(static::moreThan($value), $next);
132
+            $value instanceof DateTimeInterface ? new DateTimeMoreThan($value) : new NumericMoreThan($value) : new AndOperator(static::moreThan($value), $next);
136 133
     }
137 134
 
138 135
     /**
@@ -145,8 +142,7 @@  discard block
 block discarded – undo
145 142
     {
146 143
         return $next === null ?
147 144
             ($value instanceof DateTimeInterface ?
148
-                new DateTimeMoreOrEquals($value) : new NumericMoreOrEqualsThan($value)) :
149
-            new AndOperator(static::moreOrEquals($value), $next);
145
+                new DateTimeMoreOrEquals($value) : new NumericMoreOrEqualsThan($value)) : new AndOperator(static::moreOrEquals($value), $next);
150 146
     }
151 147
 
152 148
     /**
@@ -162,8 +158,7 @@  discard block
 block discarded – undo
162 158
 
163 159
         return $next === null ?
164 160
             ($areLimitsDates ?
165
-                new DateTimeBetween($lowerLimit, $upperLimit) : new NumericBetween($lowerLimit, $upperLimit)) :
166
-            new AndOperator(static::between($lowerLimit, $upperLimit), $next);
161
+                new DateTimeBetween($lowerLimit, $upperLimit) : new NumericBetween($lowerLimit, $upperLimit)) : new AndOperator(static::between($lowerLimit, $upperLimit), $next);
167 162
     }
168 163
 
169 164
     /**
@@ -176,8 +171,7 @@  discard block
 block discarded – undo
176 171
     protected static function stringLengthBetween(int $min, int $max, RuleInterface $next = null): RuleInterface
177 172
     {
178 173
         return $next === null ?
179
-            new StringLengthBetween($min, $max) :
180
-            new AndOperator(static::stringLengthBetween($min, $max), $next);
174
+            new StringLengthBetween($min, $max) : new AndOperator(static::stringLengthBetween($min, $max), $next);
181 175
     }
182 176
 
183 177
     /**
@@ -189,8 +183,7 @@  discard block
 block discarded – undo
189 183
     protected static function stringLengthMin(int $min, RuleInterface $next = null): RuleInterface
190 184
     {
191 185
         return $next === null ?
192
-            new StringLengthMin($min) :
193
-            new AndOperator(static::stringLengthMin($min), $next);
186
+            new StringLengthMin($min) : new AndOperator(static::stringLengthMin($min), $next);
194 187
     }
195 188
 
196 189
     /**
@@ -202,8 +195,7 @@  discard block
 block discarded – undo
202 195
     protected static function stringLengthMax(int $max, RuleInterface $next = null): RuleInterface
203 196
     {
204 197
         return $next === null ?
205
-            new StringLengthMax($max) :
206
-            new AndOperator(static::stringLengthMax($max), $next);
198
+            new StringLengthMax($max) : new AndOperator(static::stringLengthMax($max), $next);
207 199
     }
208 200
 
209 201
     /**
@@ -215,8 +207,7 @@  discard block
 block discarded – undo
215 207
     protected static function regexp(string $pattern, RuleInterface $next = null): RuleInterface
216 208
     {
217 209
         return $next === null ?
218
-            new StringRegExp($pattern) :
219
-            new AndOperator(static::regexp($pattern), $next);
210
+            new StringRegExp($pattern) : new AndOperator(static::regexp($pattern), $next);
220 211
     }
221 212
 
222 213
     /**
Please login to merge, or discard this patch.
sample/Application.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
      */
61 61
     private function showSingleValueValidation(): void
62 62
     {
63
-        $this->console('Basic usage sample.' . PHP_EOL);
64
-        $this->console('===================' . PHP_EOL);
63
+        $this->console('Basic usage sample.'.PHP_EOL);
64
+        $this->console('==================='.PHP_EOL);
65 65
 
66 66
         // Let's build a rule that validates an input to be either `null` or a string from 5 to 10 characters.
67 67
         $validator = v::validator(
@@ -71,21 +71,21 @@  discard block
 block discarded – undo
71 71
         // let's try validation with valid input
72 72
         $input = null;
73 73
         if ($validator->validate($input) === true) {
74
-            $this->console("Validation OK for `null`." . PHP_EOL);
74
+            $this->console("Validation OK for `null`.".PHP_EOL);
75 75
         } else {
76 76
             assert(false, 'We should not be here.');
77 77
         }
78 78
         // another one
79 79
         $input = 'Hello';
80 80
         if ($validator->validate($input) === true) {
81
-            $this->console("Validation OK for `$input`." . PHP_EOL);
81
+            $this->console("Validation OK for `$input`.".PHP_EOL);
82 82
         } else {
83 83
             assert(false, 'We should not be here.');
84 84
         }
85 85
         // this one should not pass the validation
86 86
         $input = 'This string is too long.';
87 87
         if ($validator->validate($input) === false) {
88
-            $this->console("Input `$input` has not passed validation." . PHP_EOL);
88
+            $this->console("Input `$input` has not passed validation.".PHP_EOL);
89 89
             $this->printErrors($validator->getErrors());
90 90
         } else {
91 91
             assert(false, 'We should not be here.');
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
             r::isString(r::stringToDateTime(DATE_ATOM, r::between($fromDate, $toDate)))
102 102
                 ->setName('my_date')->enableCapture()
103 103
         );
104
-        $input     = '2001-03-04T05:06:07+08:00';
104
+        $input = '2001-03-04T05:06:07+08:00';
105 105
         if ($validator->validate($input) === true) {
106
-            $this->console("Validation OK for `$input`." . PHP_EOL);
106
+            $this->console("Validation OK for `$input`.".PHP_EOL);
107 107
             $myDate = $validator->getCaptures()->get()['my_date'];
108 108
             // note that captured date is already DateTime
109 109
             assert($myDate instanceof DateTimeInterface);
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
             assert(false, 'We should not be here.');
112 112
         }
113 113
 
114
-        $this->console(PHP_EOL . PHP_EOL . PHP_EOL);
114
+        $this->console(PHP_EOL.PHP_EOL.PHP_EOL);
115 115
 
116 116
         // The output would be
117 117
         // -------------------------------------------------------------------------------------------------------
@@ -130,8 +130,8 @@  discard block
 block discarded – undo
130 130
      */
131 131
     private function showArrayValuesValidation(): void
132 132
     {
133
-        $this->console('Advanced usage sample.' . PHP_EOL);
134
-        $this->console('===================' . PHP_EOL);
133
+        $this->console('Advanced usage sample.'.PHP_EOL);
134
+        $this->console('==================='.PHP_EOL);
135 135
 
136 136
         // Validation rules for input are
137 137
         // - `email` must be a string and a valid email value (as FILTER_VALIDATE_EMAIL describes)
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
             'last_name'    => '',
153 153
             'payment_plan' => '123',
154 154
         ];
155
-        $this->console('Invalid data (errors)' . PHP_EOL);
155
+        $this->console('Invalid data (errors)'.PHP_EOL);
156 156
         $validator->validate($invalidInput);
157 157
         $this->printErrors($validator->getErrors());
158
-        $this->console('Invalid data (captures)' . PHP_EOL);
158
+        $this->console('Invalid data (captures)'.PHP_EOL);
159 159
         $this->printCaptures($validator->getCaptures());
160 160
 
161 161
         // Check with valid data
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
             'last_name'    => null,
166 166
             'payment_plan' => '2',
167 167
         ];
168
-        $this->console(PHP_EOL . 'Valid data (errors)' . PHP_EOL);
168
+        $this->console(PHP_EOL.'Valid data (errors)'.PHP_EOL);
169 169
         $validator->validate($validInput);
170 170
         $this->printErrors($validator->getErrors());
171
-        $this->console('Valid data (captures)' . PHP_EOL);
171
+        $this->console('Valid data (captures)'.PHP_EOL);
172 172
         $this->printCaptures($validator->getCaptures());
173 173
 
174 174
         // The output would be
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
         }
209 209
 
210 210
         if ($hasErrors === false) {
211
-            $this->console('No errors' . PHP_EOL);
211
+            $this->console('No errors'.PHP_EOL);
212 212
         }
213 213
     }
214 214
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
         $context    = $error->getMessageContext();
227 227
         $errorMsg   = MessageFormatter::formatMessage('en', $errorMsg, $context !== null ? $context : []);
228 228
 
229
-        $this->console("$entry failed for `$paramValue` with: $errorMsg" . PHP_EOL);
229
+        $this->console("$entry failed for `$paramValue` with: $errorMsg".PHP_EOL);
230 230
     }
231 231
 
232 232
     /**
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
         foreach ($captures->get() as $name => $value) {
242 242
             $hasCaptures = true;
243 243
             $type        = gettype($value);
244
-            $this->console("`$name` = `$value` ($type)" . PHP_EOL);
244
+            $this->console("`$name` = `$value` ($type)".PHP_EOL);
245 245
         }
246 246
 
247 247
         if ($hasCaptures === false) {
248
-            $this->console('No captures' . PHP_EOL);
248
+            $this->console('No captures'.PHP_EOL);
249 249
         }
250 250
     }
251 251
 
Please login to merge, or discard this patch.