Passed
Branch master (edc088)
by refat
03:44
created
Core/System/Validation/Validator.php 1 patch
Braces   +93 added lines, -31 removed lines patch added patch discarded remove patch
@@ -75,7 +75,9 @@  discard block
 block discarded – undo
75 75
    */
76 76
   public function require($call = true, $msg = null)
77 77
   {
78
-    if ($call === false) return $this;
78
+    if ($call === false) {
79
+      return $this;
80
+    }
79 81
 
80 82
     $value = $this->value();
81 83
 
@@ -107,11 +109,15 @@  discard block
 block discarded – undo
107 109
    */
108 110
   public function email($call = true, $msg = null)
109 111
   {
110
-    if ($call === false) return $this;
112
+    if ($call === false) {
113
+      return $this;
114
+    }
111 115
 
112 116
     $value = $this->value();
113 117
 
114
-    if (!$value && $value != '0') return $this;
118
+    if (!$value && $value != '0') {
119
+      return $this;
120
+    }
115 121
 
116 122
     if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
117 123
       $msg = $msg ?: 'e-mail is not valid';
@@ -130,11 +136,15 @@  discard block
 block discarded – undo
130 136
    */
131 137
   public function image($call = true, $msg = null)
132 138
   {
133
-    if ($call === false) return $this;
139
+    if ($call === false) {
140
+      return $this;
141
+    }
134 142
 
135 143
     $file = $this->app->request->file($this->input);
136 144
 
137
-    if (!$file->exists()) return $this;
145
+    if (!$file->exists()) {
146
+      return $this;
147
+    }
138 148
 
139 149
     if (!$file->isImage()) {
140 150
       $msg = $msg ?: 'image is not valid';
@@ -153,11 +163,15 @@  discard block
 block discarded – undo
153 163
    */
154 164
   public function number($call = true, $msg = null)
155 165
   {
156
-    if ($call === false) return $this;
166
+    if ($call === false) {
167
+      return $this;
168
+    }
157 169
 
158 170
     $value = $this->value();
159 171
 
160
-    if (!$value && $value != '0') return $this;
172
+    if (!$value && $value != '0') {
173
+      return $this;
174
+    }
161 175
 
162 176
     if (!is_numeric($value)) {
163 177
       $msg = $msg ?: 'this field must be a number';
@@ -176,11 +190,15 @@  discard block
 block discarded – undo
176 190
    */
177 191
   public function float($call = true, $msg = null)
178 192
   {
179
-    if ($call === false) return $this;
193
+    if ($call === false) {
194
+      return $this;
195
+    }
180 196
 
181 197
     $value = $this->value();
182 198
 
183
-    if (!$value && $value != '0') return $this;
199
+    if (!$value && $value != '0') {
200
+      return $this;
201
+    }
184 202
 
185 203
     if (!is_float($value)) {
186 204
       $msg = $msg ?: "this field must be a float number";
@@ -201,11 +219,15 @@  discard block
 block discarded – undo
201 219
    */
202 220
   public function date($options = [], $msg = null)
203 221
   {
204
-    if ($options === false) return $this;
222
+    if ($options === false) {
223
+      return $this;
224
+    }
205 225
 
206 226
     $value = $this->value();
207 227
 
208
-    if (!$value && $value != '0') return $this;
228
+    if (!$value && $value != '0') {
229
+      return $this;
230
+    }
209 231
 
210 232
     $options = json_encode($options);
211 233
     $options = json_decode($options);
@@ -246,11 +268,15 @@  discard block
 block discarded – undo
246 268
    */
247 269
   public function text($call = true, $msg = null)
248 270
   {
249
-    if ($call === false) return $this;
271
+    if ($call === false) {
272
+      return $this;
273
+    }
250 274
 
251 275
     $value = $this->value();
252 276
 
253
-    if (!$value && $value != '0') return $this;
277
+    if (!$value && $value != '0') {
278
+      return $this;
279
+    }
254 280
 
255 281
     if (!is_string($value)) {
256 282
       $msg = $msg ?: 'the field must be a text';
@@ -269,11 +295,15 @@  discard block
 block discarded – undo
269 295
    */
270 296
   public function noNumbers($call = true, $msg = null)
271 297
   {
272
-    if ($call === false) return $this;
298
+    if ($call === false) {
299
+      return $this;
300
+    }
273 301
 
274 302
     $value = $this->value();
275 303
 
276
-    if (!$value && $value != '0') return $this;
304
+    if (!$value && $value != '0') {
305
+      return $this;
306
+    }
277 307
 
278 308
     if (preg_match('~[0-9]~', $value)) {
279 309
       $msg = $msg ?: 'numbers are not allow';
@@ -293,11 +323,15 @@  discard block
 block discarded – undo
293 323
    */
294 324
   public function characters($excepts, $msg = null)
295 325
   {
296
-    if ($excepts === false) return $this;
326
+    if ($excepts === false) {
327
+      return $this;
328
+    }
297 329
 
298 330
     $value = $this->value();
299 331
 
300
-    if (!$value && $value != '0') return $this;
332
+    if (!$value && $value != '0') {
333
+      return $this;
334
+    }
301 335
 
302 336
     extract($this->charactersvariables($excepts, $value));
303 337
 
@@ -461,11 +495,15 @@  discard block
 block discarded – undo
461 495
    */
462 496
   public function noSpaces($call = true, $msg = null)
463 497
   {
464
-    if ($call === false) return $this;
498
+    if ($call === false) {
499
+      return $this;
500
+    }
465 501
 
466 502
     $value = $this->value();
467 503
 
468
-    if (!$value && $value != '0') return $this;
504
+    if (!$value && $value != '0') {
505
+      return $this;
506
+    }
469 507
 
470 508
     if (preg_match('/\s/', $value)) {
471 509
       $msg = $msg ?: 'spaces are not allow';
@@ -484,11 +522,15 @@  discard block
 block discarded – undo
484 522
    */
485 523
   public function containJust($characters = [], $msg = null)
486 524
   {
487
-    if ($characters === false) return $this;
525
+    if ($characters === false) {
526
+      return $this;
527
+    }
488 528
 
489 529
     $value = $this->value();
490 530
 
491
-    if (!$value && $value != '0') return $this;
531
+    if (!$value && $value != '0') {
532
+      return $this;
533
+    }
492 534
 
493 535
     $allowedCharacters = new AllowedCharacters($this->app, $characters);
494 536
     $characters = $allowedCharacters->getCharacters();
@@ -509,11 +551,15 @@  discard block
 block discarded – undo
509 551
    */
510 552
   public function length($length = null, $msg = null)
511 553
   {
512
-    if ($length === false) return $this;
554
+    if ($length === false) {
555
+      return $this;
556
+    }
513 557
 
514 558
     $value = $this->value();
515 559
 
516
-    if (!$value && $value != '0') return $this;
560
+    if (!$value && $value != '0') {
561
+      return $this;
562
+    }
517 563
 
518 564
     if (strlen($value) !== $length) {
519 565
       $msg = $msg ?: `this field can be just ${length} charachter`;
@@ -532,11 +578,15 @@  discard block
 block discarded – undo
532 578
    */
533 579
   public function maxLen($length = null, $msg = null)
534 580
   {
535
-    if ($length === false) return $this;
581
+    if ($length === false) {
582
+      return $this;
583
+    }
536 584
 
537 585
     $value = $this->value();
538 586
 
539
-    if (!$value && $value != '0') return $this;
587
+    if (!$value && $value != '0') {
588
+      return $this;
589
+    }
540 590
 
541 591
     if (strlen($value) > $length) {
542 592
       $msg = $msg ?: "this field can be maximum $length charachter";
@@ -555,11 +605,15 @@  discard block
 block discarded – undo
555 605
    */
556 606
   public function minLen($length = null, $msg = null)
557 607
   {
558
-    if ($length === false) return $this;
608
+    if ($length === false) {
609
+      return $this;
610
+    }
559 611
 
560 612
     $value = $this->value();
561 613
 
562
-    if (!$value && $value != '0') return $this;
614
+    if (!$value && $value != '0') {
615
+      return $this;
616
+    }
563 617
 
564 618
     if (strlen($value) < $length) {
565 619
       $msg = $msg ?: "this field can be minimum $length charachter";
@@ -578,7 +632,9 @@  discard block
 block discarded – undo
578 632
    */
579 633
   public function match($input, $msg = null)
580 634
   {
581
-    if ($input === false) return $this;
635
+    if ($input === false) {
636
+      return $this;
637
+    }
582 638
 
583 639
     $value = $this->value();
584 640
 
@@ -603,11 +659,15 @@  discard block
 block discarded – undo
603 659
    */
604 660
   public function unique($data = [], $msg = null)
605 661
   {
606
-    if ($data === false) return $this;
662
+    if ($data === false) {
663
+      return $this;
664
+    }
607 665
 
608 666
     $value = $this->value();
609 667
 
610
-    if (!$data) return $this;
668
+    if (!$data) {
669
+      return $this;
670
+    }
611 671
 
612 672
     if (is_array($data)) {
613 673
       list($table, $column) = $data;
@@ -665,7 +725,9 @@  discard block
 block discarded – undo
665 725
    */
666 726
   public function addError($input, $msg)
667 727
   {
668
-    if (!$this->hasError($input)) $this->errors[$input] = $msg;
728
+    if (!$this->hasError($input)) {
729
+      $this->errors[$input] = $msg;
730
+    }
669 731
   }
670 732
 
671 733
   /**
Please login to merge, or discard this patch.