Completed
Pull Request — master (#5)
by
unknown
01:38
created
src/Assert.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
     }
298 298
 
299 299
     /**
300
-     * @param $exceptionClass
300
+     * @param string $exceptionClass
301 301
      * @return Assert
302 302
      */
303 303
     public function setExceptionClass($exceptionClass)
@@ -1353,7 +1353,7 @@  discard block
 block discarded – undo
1353 1353
     /**
1354 1354
      * Alias of {@see choice()}
1355 1355
      *
1356
-     * @param array       $choices
1356
+     * @param integer[]       $choices
1357 1357
      * @param string|null $message
1358 1358
      * @param string|null $fieldName
1359 1359
      * @return Assert
@@ -2593,7 +2593,7 @@  discard block
 block discarded – undo
2593 2593
     }
2594 2594
 
2595 2595
     /**
2596
-     * @param $func
2596
+     * @param string $func
2597 2597
      * @param $args
2598 2598
      * @return bool
2599 2599
      * @throws AssertionFailedException
Please login to merge, or discard this patch.
Spacing   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare(strict_types=1);
1
+<?php declare(strict_types = 1);
2 2
 
3 3
 namespace Terah\Assert;
4 4
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
      *
135 135
      * @var string
136 136
      */
137
-    protected $exceptionClass           = 'Terah\Assert\AssertionFailedException';
137
+    protected $exceptionClass = 'Terah\Assert\AssertionFailedException';
138 138
 
139 139
     /**
140 140
      * @param mixed $value
@@ -151,16 +151,16 @@  discard block
 block discarded – undo
151 151
      */
152 152
     public static function runValidators(array $validators) : array
153 153
     {
154
-        $errors = [];
155
-        foreach ( $validators as $fieldName => $validator )
154
+        $errors = [ ];
155
+        foreach ($validators as $fieldName => $validator)
156 156
         {
157 157
             try
158 158
             {
159 159
                 $validator->__invoke();
160 160
             }
161
-            catch ( AssertionFailedException $e )
161
+            catch (AssertionFailedException $e)
162 162
             {
163
-                $errors[$fieldName]     = $e->getMessage();
163
+                $errors[ $fieldName ] = $e->getMessage();
164 164
             }
165 165
         }
166 166
 
@@ -173,16 +173,16 @@  discard block
 block discarded – undo
173 173
      */
174 174
     public static function runValidators(array $validators) : array
175 175
     {
176
-        $errors = [];
177
-        foreach ( $validators as $fieldName => $validator )
176
+        $errors = [ ];
177
+        foreach ($validators as $fieldName => $validator)
178 178
         {
179 179
             try
180 180
             {
181 181
                 $validator->__invoke();
182 182
             }
183
-            catch ( AssertionFailedException $e )
183
+            catch (AssertionFailedException $e)
184 184
             {
185
-                $errors[$fieldName]     = $e->getMessage();
185
+                $errors[ $fieldName ] = $e->getMessage();
186 186
             }
187 187
         }
188 188
 
@@ -197,22 +197,22 @@  discard block
 block discarded – undo
197 197
      * @param string $level
198 198
      * @return Assert
199 199
      */
200
-    public static function that($value, $fieldName='', $code=0, $error='', $level=Assert::WARNING)
200
+    public static function that($value, $fieldName = '', $code = 0, $error = '', $level = Assert::WARNING)
201 201
     {
202 202
         $assert = new static($value);
203
-        if ( $fieldName )
203
+        if ($fieldName)
204 204
         {
205 205
             $assert->fieldName($fieldName);
206 206
         }
207
-        if ( $code )
207
+        if ($code)
208 208
         {
209 209
             $assert->code($code);
210 210
         }
211
-        if ( $error )
211
+        if ($error)
212 212
         {
213 213
             $assert->error($error);
214 214
         }
215
-        if ( $level )
215
+        if ($level)
216 216
         {
217 217
             $assert->level($level);
218 218
         }
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
      * @param string $level
288 288
      * @return AssertionFailedException
289 289
      */
290
-    protected function createException($message, $code, $fieldName, array $constraints = [], $level=null)
290
+    protected function createException($message, $code, $fieldName, array $constraints = [ ], $level = null)
291 291
     {
292 292
         $exceptionClass = $this->exceptionClass;
293 293
         $fieldName      = is_null($fieldName) ? $this->fieldName : $fieldName;
@@ -373,11 +373,11 @@  discard block
 block discarded – undo
373 373
      */
374 374
     public function eq($value2, $message = null, $fieldName = null)
375 375
     {
376
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
376
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
377 377
         {
378 378
             return $this;
379 379
         }
380
-        if ( $this->value != $value2 )
380
+        if ($this->value != $value2)
381 381
         {
382 382
             $message = $message ?: $this->overrideError;
383 383
             $message = sprintf(
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
                 $this->stringify($this->value),
386 386
                 $this->stringify($value2)
387 387
             );
388
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $fieldName, ['expected' => $value2]);
388
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $fieldName, [ 'expected' => $value2 ]);
389 389
         }
390 390
         return $this;
391 391
     }
@@ -401,11 +401,11 @@  discard block
 block discarded – undo
401 401
      */
402 402
     public function greaterThan($value2, $message = null, $fieldName = null)
403 403
     {
404
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
404
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
405 405
         {
406 406
             return $this;
407 407
         }
408
-        if ( ! ( $this->value > $value2 ) )
408
+        if ( ! ($this->value > $value2))
409 409
         {
410 410
             $message = $message ?: $this->overrideError;
411 411
             $message = sprintf(
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
                 $this->stringify($this->value),
414 414
                 $this->stringify($value2)
415 415
             );
416
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $fieldName, ['expected' => $value2]);
416
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $fieldName, [ 'expected' => $value2 ]);
417 417
         }
418 418
         return $this;
419 419
     }
@@ -429,11 +429,11 @@  discard block
 block discarded – undo
429 429
      */
430 430
     public function greaterThanOrEq($value2, $message = null, $fieldName = null)
431 431
     {
432
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
432
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
433 433
         {
434 434
             return $this;
435 435
         }
436
-        if ( ! ( $this->value >= $value2 ) )
436
+        if ( ! ($this->value >= $value2))
437 437
         {
438 438
             $message = $message ?: $this->overrideError;
439 439
             $message = sprintf(
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
                 $this->stringify($this->value),
442 442
                 $this->stringify($value2)
443 443
             );
444
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $fieldName, ['expected' => $value2]);
444
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $fieldName, [ 'expected' => $value2 ]);
445 445
         }
446 446
         return $this;
447 447
     }
@@ -457,11 +457,11 @@  discard block
 block discarded – undo
457 457
      */
458 458
     public function lessThan($value2, $message = null, $fieldName = null)
459 459
     {
460
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
460
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
461 461
         {
462 462
             return $this;
463 463
         }
464
-        if ( ! ( $this->value < $value2 ) )
464
+        if ( ! ($this->value < $value2))
465 465
         {
466 466
             $message = $message ?: $this->overrideError;
467 467
             $message = sprintf(
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
                 $this->stringify($this->value),
470 470
                 $this->stringify($value2)
471 471
             );
472
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_LESS_THAN, $fieldName, ['expected' => $value2]);
472
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_LESS_THAN, $fieldName, [ 'expected' => $value2 ]);
473 473
         }
474 474
         return $this;
475 475
     }
@@ -485,11 +485,11 @@  discard block
 block discarded – undo
485 485
      */
486 486
     public function lessThanOrEq($value2, $message = null, $fieldName = null)
487 487
     {
488
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
488
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
489 489
         {
490 490
             return $this;
491 491
         }
492
-        if ( ! ( $this->value <= $value2 ) )
492
+        if ( ! ($this->value <= $value2))
493 493
         {
494 494
             $message = $message ?: $this->overrideError;
495 495
             $message = sprintf(
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
                 $this->stringify($this->value),
498 498
                 $this->stringify($value2)
499 499
             );
500
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_LESS_THAN_OR_EQ, $fieldName, ['expected' => $value2]);
500
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_LESS_THAN_OR_EQ, $fieldName, [ 'expected' => $value2 ]);
501 501
         }
502 502
         return $this;
503 503
     }
@@ -513,11 +513,11 @@  discard block
 block discarded – undo
513 513
      */
514 514
     public function same($value2, $message = null, $fieldName = null)
515 515
     {
516
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
516
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
517 517
         {
518 518
             return $this;
519 519
         }
520
-        if ( $this->value !== $value2 )
520
+        if ($this->value !== $value2)
521 521
         {
522 522
             $message = $message ?: $this->overrideError;
523 523
             $message = sprintf(
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
                 $this->stringify($this->value),
526 526
                 $this->stringify($value2)
527 527
             );
528
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_SAME, $fieldName, ['expected' => $value2]);
528
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_SAME, $fieldName, [ 'expected' => $value2 ]);
529 529
         }
530 530
         return $this;
531 531
     }
@@ -541,11 +541,11 @@  discard block
 block discarded – undo
541 541
      */
542 542
     public function notEq($value2, $message = null, $fieldName = null)
543 543
     {
544
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
544
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
545 545
         {
546 546
             return $this;
547 547
         }
548
-        if ( $this->value == $value2 )
548
+        if ($this->value == $value2)
549 549
         {
550 550
             $message = $message ?: $this->overrideError;
551 551
             $message = sprintf(
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
                 $this->stringify($this->value),
554 554
                 $this->stringify($value2)
555 555
             );
556
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_EQ, $fieldName, ['expected' => $value2]);
556
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_EQ, $fieldName, [ 'expected' => $value2 ]);
557 557
         }
558 558
         return $this;
559 559
     }
@@ -568,11 +568,11 @@  discard block
 block discarded – undo
568 568
      */
569 569
     public function isCallable($message = null, $fieldName = null)
570 570
     {
571
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
571
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
572 572
         {
573 573
             return $this;
574 574
         }
575
-        if ( !is_callable($this->value) )
575
+        if ( ! is_callable($this->value))
576 576
         {
577 577
             $message = $message ?: $this->overrideError;
578 578
             $message = sprintf(
@@ -595,11 +595,11 @@  discard block
 block discarded – undo
595 595
      */
596 596
     public function notSame($value2, $message = null, $fieldName = null)
597 597
     {
598
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
598
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
599 599
         {
600 600
             return $this;
601 601
         }
602
-        if ( $this->value === $value2 )
602
+        if ($this->value === $value2)
603 603
         {
604 604
             $message = $message ?: $this->overrideError;
605 605
             $message = sprintf(
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
                 $this->stringify($this->value),
608 608
                 $this->stringify($value2)
609 609
             );
610
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_SAME, $fieldName, ['expected' => $value2]);
610
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_SAME, $fieldName, [ 'expected' => $value2 ]);
611 611
         }
612 612
         return $this;
613 613
     }
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
      * @return Assert
635 635
      * @throws AssertionFailedException
636 636
      */
637
-    public function unsignedInt($message=null, $fieldName=null)
637
+    public function unsignedInt($message = null, $fieldName = null)
638 638
     {
639 639
         $message = $message ?: $this->overrideError;
640 640
         $message = $message ?: 'Value "%s" is not an integer id.';
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
     {
670 670
         $message = $message ?: $this->overrideError;
671 671
         $message = $message ?: 'Value "%s" is not a valid status.';
672
-        return $this->integer($message, $fieldName)->inArray([-1, 0, 1]);
672
+        return $this->integer($message, $fieldName)->inArray([-1, 0, 1 ]);
673 673
     }
674 674
 
675 675
     /**
@@ -721,11 +721,11 @@  discard block
 block discarded – undo
721 721
      */
722 722
     public function integer($message = null, $fieldName = null)
723 723
     {
724
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
724
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
725 725
         {
726 726
             return $this;
727 727
         }
728
-        if ( !is_int($this->value) )
728
+        if ( ! is_int($this->value))
729 729
         {
730 730
             $message = $message ?: $this->overrideError;
731 731
             $message = sprintf(
@@ -747,11 +747,11 @@  discard block
 block discarded – undo
747 747
      */
748 748
     public function float($message = null, $fieldName = null)
749 749
     {
750
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
750
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
751 751
         {
752 752
             return $this;
753 753
         }
754
-        if ( ! is_float($this->value) )
754
+        if ( ! is_float($this->value))
755 755
         {
756 756
             $message = $message ?: $this->overrideError;
757 757
             $message = sprintf(
@@ -773,11 +773,11 @@  discard block
 block discarded – undo
773 773
      */
774 774
     public function digit($message = null, $fieldName = null)
775 775
     {
776
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
776
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
777 777
         {
778 778
             return $this;
779 779
         }
780
-        if ( ! ctype_digit((string)$this->value) )
780
+        if ( ! ctype_digit((string)$this->value))
781 781
         {
782 782
             $message = $message ?: $this->overrideError;
783 783
             $message = sprintf(
@@ -799,12 +799,12 @@  discard block
 block discarded – undo
799 799
      */
800 800
     public function date($message = null, $fieldName = null)
801 801
     {
802
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
802
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
803 803
         {
804 804
             return $this;
805 805
         }
806 806
         $this->notEmpty($message, $fieldName);
807
-        if ( strtotime($this->value) === false )
807
+        if (strtotime($this->value) === false)
808 808
         {
809 809
             $message = $message ?: $this->overrideError;
810 810
             $message = sprintf(
@@ -826,11 +826,11 @@  discard block
 block discarded – undo
826 826
      */
827 827
     public function integerish($message = null, $fieldName = null)
828 828
     {
829
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
829
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
830 830
         {
831 831
             return $this;
832 832
         }
833
-        if ( is_object($this->value) || strval(intval($this->value)) != $this->value || is_bool($this->value) || is_null($this->value) )
833
+        if (is_object($this->value) || strval(intval($this->value)) != $this->value || is_bool($this->value) || is_null($this->value))
834 834
         {
835 835
             $message = $message ?: $this->overrideError;
836 836
             $message = sprintf(
@@ -852,11 +852,11 @@  discard block
 block discarded – undo
852 852
      */
853 853
     public function boolean($message = null, $fieldName = null)
854 854
     {
855
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
855
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
856 856
         {
857 857
             return $this;
858 858
         }
859
-        if ( ! is_bool($this->value) )
859
+        if ( ! is_bool($this->value))
860 860
         {
861 861
             $message = $message ?: $this->overrideError;
862 862
             $message = sprintf(
@@ -878,11 +878,11 @@  discard block
 block discarded – undo
878 878
      */
879 879
     public function scalar($message = null, $fieldName = null)
880 880
     {
881
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
881
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
882 882
         {
883 883
             return $this;
884 884
         }
885
-        if ( ! is_scalar($this->value) )
885
+        if ( ! is_scalar($this->value))
886 886
         {
887 887
             $message = $message ?: $this->overrideError;
888 888
             $message = sprintf(
@@ -904,11 +904,11 @@  discard block
 block discarded – undo
904 904
      */
905 905
     public function notEmpty($message = null, $fieldName = null)
906 906
     {
907
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
907
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
908 908
         {
909 909
             return $this;
910 910
         }
911
-        if ( ( is_object($this->value) && empty((array)$this->value) ) || empty($this->value) )
911
+        if ((is_object($this->value) && empty((array)$this->value)) || empty($this->value))
912 912
         {
913 913
             $message = $message ?: $this->overrideError;
914 914
             $message = sprintf(
@@ -930,11 +930,11 @@  discard block
 block discarded – undo
930 930
      */
931 931
     public function noContent($message = null, $fieldName = null)
932 932
     {
933
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
933
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
934 934
         {
935 935
             return $this;
936 936
         }
937
-        if ( !empty( $this->value ) )
937
+        if ( ! empty($this->value))
938 938
         {
939 939
             $message = $message ?: $this->overrideError;
940 940
             $message = sprintf(
@@ -956,11 +956,11 @@  discard block
 block discarded – undo
956 956
      */
957 957
     public function notNull($message = null, $fieldName = null)
958 958
     {
959
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
959
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
960 960
         {
961 961
             return $this;
962 962
         }
963
-        if ( $this->value === null )
963
+        if ($this->value === null)
964 964
         {
965 965
             $message = $message ?: $this->overrideError;
966 966
             $message = sprintf(
@@ -982,11 +982,11 @@  discard block
 block discarded – undo
982 982
      */
983 983
     public function string($message = null, $fieldName = null)
984 984
     {
985
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
985
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
986 986
         {
987 987
             return $this;
988 988
         }
989
-        if ( !is_string($this->value) )
989
+        if ( ! is_string($this->value))
990 990
         {
991 991
             $message = $message ?: $this->overrideError;
992 992
             $message = sprintf(
@@ -1008,21 +1008,21 @@  discard block
 block discarded – undo
1008 1008
      * @return Assert
1009 1009
      * @throws AssertionFailedException
1010 1010
      */
1011
-    public function regex($pattern, $message=null, $fieldName=null)
1011
+    public function regex($pattern, $message = null, $fieldName = null)
1012 1012
     {
1013
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1013
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1014 1014
         {
1015 1015
             return $this;
1016 1016
         }
1017 1017
         $this->string($message, $fieldName);
1018
-        if ( ! preg_match($pattern, $this->value) )
1018
+        if ( ! preg_match($pattern, $this->value))
1019 1019
         {
1020 1020
             $message = $message ?: $this->overrideError;
1021 1021
             $message = sprintf(
1022 1022
                 $message ?: 'Value "%s" does not match expression.',
1023 1023
                 $this->stringify($this->value)
1024 1024
             );
1025
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_REGEX, $fieldName, ['pattern' => $pattern]);
1025
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_REGEX, $fieldName, [ 'pattern' => $pattern ]);
1026 1026
         }
1027 1027
         return $this;
1028 1028
     }
@@ -1037,13 +1037,13 @@  discard block
 block discarded – undo
1037 1037
      */
1038 1038
     public function ipAddress($message = null, $fieldName = null)
1039 1039
     {
1040
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1040
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1041 1041
         {
1042 1042
             return $this;
1043 1043
         }
1044 1044
         $this->string($message, $fieldName);
1045
-        $pattern   = '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/';
1046
-        if ( ! preg_match($pattern, $this->value) )
1045
+        $pattern = '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/';
1046
+        if ( ! preg_match($pattern, $this->value))
1047 1047
         {
1048 1048
             $message = $message ?: $this->overrideError;
1049 1049
             $message = sprintf(
@@ -1066,19 +1066,19 @@  discard block
 block discarded – undo
1066 1066
      */
1067 1067
     public function notRegex($pattern, $message = null, $fieldName = null)
1068 1068
     {
1069
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1069
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1070 1070
         {
1071 1071
             return $this;
1072 1072
         }
1073 1073
         $this->string($message, $fieldName);
1074
-        if ( preg_match($pattern, $this->value) )
1074
+        if (preg_match($pattern, $this->value))
1075 1075
         {
1076 1076
             $message = $message ?: $this->overrideError;
1077 1077
             $message = sprintf(
1078 1078
                 $message ?: 'Value "%s" does not match expression.',
1079 1079
                 $this->stringify($this->value)
1080 1080
             );
1081
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_REGEX, $fieldName, ['pattern' => $pattern]);
1081
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_REGEX, $fieldName, [ 'pattern' => $pattern ]);
1082 1082
         }
1083 1083
         return $this;
1084 1084
     }
@@ -1095,12 +1095,12 @@  discard block
 block discarded – undo
1095 1095
      */
1096 1096
     public function length($length, $message = null, $fieldName = null, $encoding = 'utf8')
1097 1097
     {
1098
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1098
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1099 1099
         {
1100 1100
             return $this;
1101 1101
         }
1102 1102
         $this->string($message, $fieldName);
1103
-        if ( mb_strlen($this->value, $encoding) !== $length )
1103
+        if (mb_strlen($this->value, $encoding) !== $length)
1104 1104
         {
1105 1105
             $message    = $message ?: $this->overrideError;
1106 1106
             $message    = sprintf(
@@ -1109,7 +1109,7 @@  discard block
 block discarded – undo
1109 1109
                 $length,
1110 1110
                 mb_strlen($this->value, $encoding)
1111 1111
             );
1112
-            $constraints = ['length' => $length, 'encoding' => $encoding];
1112
+            $constraints = [ 'length' => $length, 'encoding' => $encoding ];
1113 1113
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_LENGTH, $fieldName, $constraints);
1114 1114
         }
1115 1115
         return $this;
@@ -1128,22 +1128,22 @@  discard block
 block discarded – undo
1128 1128
      */
1129 1129
     public function minLength($minLength, $message = null, $fieldName = null, $encoding = 'utf8')
1130 1130
     {
1131
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1131
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1132 1132
         {
1133 1133
             return $this;
1134 1134
         }
1135 1135
         $this->string($message, $fieldName);
1136
-        if ( mb_strlen($this->value, $encoding) < $minLength )
1136
+        if (mb_strlen($this->value, $encoding) < $minLength)
1137 1137
         {
1138 1138
             $message = $message ?: $this->overrideError;
1139
-            $message     = sprintf(
1139
+            $message = sprintf(
1140 1140
                 $message
1141 1141
                     ?: 'Value "%s" is too short, it should have more than %d characters, but only has %d characters.',
1142 1142
                 $this->stringify($this->value),
1143 1143
                 $minLength,
1144 1144
                 mb_strlen($this->value, $encoding)
1145 1145
             );
1146
-            $constraints = ['min_length' => $minLength, 'encoding' => $encoding];
1146
+            $constraints = [ 'min_length' => $minLength, 'encoding' => $encoding ];
1147 1147
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_MIN_LENGTH, $fieldName, $constraints);
1148 1148
         }
1149 1149
         return $this;
@@ -1162,21 +1162,21 @@  discard block
 block discarded – undo
1162 1162
      */
1163 1163
     public function maxLength($maxLength, $message = null, $fieldName = null, $encoding = 'utf8')
1164 1164
     {
1165
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1165
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1166 1166
         {
1167 1167
             return $this;
1168 1168
         }
1169 1169
         $this->string($message, $fieldName);
1170
-        if ( mb_strlen($this->value, $encoding) > $maxLength )
1170
+        if (mb_strlen($this->value, $encoding) > $maxLength)
1171 1171
         {
1172 1172
             $message = $message ?: $this->overrideError;
1173
-            $message     = sprintf(
1173
+            $message = sprintf(
1174 1174
                 $message ?: 'Value "%s" is too long, it should have no more than %d characters, but has %d characters.',
1175 1175
                 $this->stringify($this->value),
1176 1176
                 $maxLength,
1177 1177
                 mb_strlen($this->value, $encoding)
1178 1178
             );
1179
-            $constraints = ['max_length' => $maxLength, 'encoding' => $encoding];
1179
+            $constraints = [ 'max_length' => $maxLength, 'encoding' => $encoding ];
1180 1180
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_MAX_LENGTH, $fieldName, $constraints);
1181 1181
         }
1182 1182
         return $this;
@@ -1195,34 +1195,34 @@  discard block
 block discarded – undo
1195 1195
      */
1196 1196
     public function betweenLength($minLength, $maxLength, $message = null, $fieldName = null, $encoding = 'utf8')
1197 1197
     {
1198
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1198
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1199 1199
         {
1200 1200
             return $this;
1201 1201
         }
1202 1202
         $this->string($message, $fieldName);
1203
-        if ( mb_strlen($this->value, $encoding) < $minLength )
1203
+        if (mb_strlen($this->value, $encoding) < $minLength)
1204 1204
         {
1205 1205
             $message = $message ?: $this->overrideError;
1206
-            $message     = sprintf(
1206
+            $message = sprintf(
1207 1207
                 $message
1208 1208
                     ?: 'Value "%s" is too short, it should have more than %d characters, but only has %d characters.',
1209 1209
                 $this->stringify($this->value),
1210 1210
                 $minLength,
1211 1211
                 mb_strlen($this->value, $encoding)
1212 1212
             );
1213
-            $constraints = ['min_length' => $minLength, 'encoding' => $encoding];
1213
+            $constraints = [ 'min_length' => $minLength, 'encoding' => $encoding ];
1214 1214
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_MIN_LENGTH, $fieldName, $constraints);
1215 1215
         }
1216
-        if ( mb_strlen($this->value, $encoding) > $maxLength )
1216
+        if (mb_strlen($this->value, $encoding) > $maxLength)
1217 1217
         {
1218 1218
             $message = $message ?: $this->overrideError;
1219
-            $message     = sprintf(
1219
+            $message = sprintf(
1220 1220
                 $message ?: 'Value "%s" is too long, it should have no more than %d characters, but has %d characters.',
1221 1221
                 $this->stringify($this->value),
1222 1222
                 $maxLength,
1223 1223
                 mb_strlen($this->value, $encoding)
1224 1224
             );
1225
-            $constraints = ['max_length' => $maxLength, 'encoding' => $encoding];
1225
+            $constraints = [ 'max_length' => $maxLength, 'encoding' => $encoding ];
1226 1226
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_MAX_LENGTH, $fieldName, $constraints);
1227 1227
         }
1228 1228
         return $this;
@@ -1240,20 +1240,20 @@  discard block
 block discarded – undo
1240 1240
      */
1241 1241
     public function startsWith($needle, $message = null, $fieldName = null, $encoding = 'utf8')
1242 1242
     {
1243
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1243
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1244 1244
         {
1245 1245
             return $this;
1246 1246
         }
1247 1247
         $this->string($message, $fieldName);
1248
-        if ( mb_strpos($this->value, $needle, null, $encoding) !== 0 )
1248
+        if (mb_strpos($this->value, $needle, null, $encoding) !== 0)
1249 1249
         {
1250 1250
             $message = $message ?: $this->overrideError;
1251
-            $message     = sprintf(
1251
+            $message = sprintf(
1252 1252
                 $message ?: 'Value "%s" does not start with "%s".',
1253 1253
                 $this->stringify($this->value),
1254 1254
                 $this->stringify($needle)
1255 1255
             );
1256
-            $constraints = ['needle' => $needle, 'encoding' => $encoding];
1256
+            $constraints = [ 'needle' => $needle, 'encoding' => $encoding ];
1257 1257
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_STRING_START, $fieldName, $constraints);
1258 1258
         }
1259 1259
         return $this;
@@ -1271,21 +1271,21 @@  discard block
 block discarded – undo
1271 1271
      */
1272 1272
     public function endsWith($needle, $message = null, $fieldName = null, $encoding = 'utf8')
1273 1273
     {
1274
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1274
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1275 1275
         {
1276 1276
             return $this;
1277 1277
         }
1278 1278
         $this->string($message, $fieldName);
1279 1279
         $stringPosition = mb_strlen($this->value, $encoding) - mb_strlen($needle, $encoding);
1280
-        if ( mb_strripos($this->value, $needle, null, $encoding) !== $stringPosition )
1280
+        if (mb_strripos($this->value, $needle, null, $encoding) !== $stringPosition)
1281 1281
         {
1282 1282
             $message = $message ?: $this->overrideError;
1283
-            $message     = sprintf(
1283
+            $message = sprintf(
1284 1284
                 $message ?: 'Value "%s" does not end with "%s".',
1285 1285
                 $this->stringify($this->value),
1286 1286
                 $this->stringify($needle)
1287 1287
             );
1288
-            $constraints = ['needle' => $needle, 'encoding' => $encoding];
1288
+            $constraints = [ 'needle' => $needle, 'encoding' => $encoding ];
1289 1289
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_STRING_END, $fieldName, $constraints);
1290 1290
         }
1291 1291
         return $this;
@@ -1303,20 +1303,20 @@  discard block
 block discarded – undo
1303 1303
      */
1304 1304
     public function contains($needle, $message = null, $fieldName = null, $encoding = 'utf8')
1305 1305
     {
1306
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1306
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1307 1307
         {
1308 1308
             return $this;
1309 1309
         }
1310 1310
         $this->string($message, $fieldName);
1311
-        if ( mb_strpos($this->value, $needle, null, $encoding) === false )
1311
+        if (mb_strpos($this->value, $needle, null, $encoding) === false)
1312 1312
         {
1313 1313
             $message = $message ?: $this->overrideError;
1314
-            $message     = sprintf(
1314
+            $message = sprintf(
1315 1315
                 $message ?: 'Value "%s" does not contain "%s".',
1316 1316
                 $this->stringify($this->value),
1317 1317
                 $this->stringify($needle)
1318 1318
             );
1319
-            $constraints = ['needle' => $needle, 'encoding' => $encoding];
1319
+            $constraints = [ 'needle' => $needle, 'encoding' => $encoding ];
1320 1320
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_STRING_CONTAINS, $fieldName, $constraints);
1321 1321
         }
1322 1322
         return $this;
@@ -1333,11 +1333,11 @@  discard block
 block discarded – undo
1333 1333
      */
1334 1334
     public function choice(array $choices, $message = null, $fieldName = null)
1335 1335
     {
1336
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1336
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1337 1337
         {
1338 1338
             return $this;
1339 1339
         }
1340
-        if ( !in_array($this->value, $choices, true) )
1340
+        if ( ! in_array($this->value, $choices, true))
1341 1341
         {
1342 1342
             $message = $message ?: $this->overrideError;
1343 1343
             $message = sprintf(
@@ -1345,7 +1345,7 @@  discard block
 block discarded – undo
1345 1345
                 $this->stringify($this->value),
1346 1346
                 implode(", ", array_map('Terah\Assert\Assert::stringify', $choices))
1347 1347
             );
1348
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_CHOICE, $fieldName, ['choices' => $choices]);
1348
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_CHOICE, $fieldName, [ 'choices' => $choices ]);
1349 1349
         }
1350 1350
         return $this;
1351 1351
     }
@@ -1361,7 +1361,7 @@  discard block
 block discarded – undo
1361 1361
      */
1362 1362
     public function inArray(array $choices, $message = null, $fieldName = null)
1363 1363
     {
1364
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1364
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1365 1365
         {
1366 1366
             return $this;
1367 1367
         }
@@ -1379,11 +1379,11 @@  discard block
 block discarded – undo
1379 1379
      */
1380 1380
     public function numeric($message = null, $fieldName = null)
1381 1381
     {
1382
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1382
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1383 1383
         {
1384 1384
             return $this;
1385 1385
         }
1386
-        if ( ! is_numeric($this->value) )
1386
+        if ( ! is_numeric($this->value))
1387 1387
         {
1388 1388
             $message = $message ?: $this->overrideError;
1389 1389
             $message = sprintf(
@@ -1447,11 +1447,11 @@  discard block
 block discarded – undo
1447 1447
      */
1448 1448
     public function isArray($message = null, $fieldName = null)
1449 1449
     {
1450
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1450
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1451 1451
         {
1452 1452
             return $this;
1453 1453
         }
1454
-        if ( !is_array($this->value) )
1454
+        if ( ! is_array($this->value))
1455 1455
         {
1456 1456
             $message = $message ?: $this->overrideError;
1457 1457
             $message = sprintf(
@@ -1473,11 +1473,11 @@  discard block
 block discarded – undo
1473 1473
      */
1474 1474
     public function isTraversable($message = null, $fieldName = null)
1475 1475
     {
1476
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1476
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1477 1477
         {
1478 1478
             return $this;
1479 1479
         }
1480
-        if ( !is_array($this->value) && !$this->value instanceof \Traversable )
1480
+        if ( ! is_array($this->value) && ! $this->value instanceof \Traversable)
1481 1481
         {
1482 1482
             $message = $message ?: $this->overrideError;
1483 1483
             $message = sprintf(
@@ -1499,11 +1499,11 @@  discard block
 block discarded – undo
1499 1499
      */
1500 1500
     public function isArrayAccessible($message = null, $fieldName = null)
1501 1501
     {
1502
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1502
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1503 1503
         {
1504 1504
             return $this;
1505 1505
         }
1506
-        if ( !is_array($this->value) && !$this->value instanceof \ArrayAccess )
1506
+        if ( ! is_array($this->value) && ! $this->value instanceof \ArrayAccess)
1507 1507
         {
1508 1508
             $message = $message ?: $this->overrideError;
1509 1509
             $message = sprintf(
@@ -1526,19 +1526,19 @@  discard block
 block discarded – undo
1526 1526
      */
1527 1527
     public function keyExists($key, $message = null, $fieldName = null)
1528 1528
     {
1529
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1529
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1530 1530
         {
1531 1531
             return $this;
1532 1532
         }
1533 1533
         $this->isArray($message, $fieldName);
1534
-        if ( !array_key_exists($key, $this->value) )
1534
+        if ( ! array_key_exists($key, $this->value))
1535 1535
         {
1536 1536
             $message = $message ?: $this->overrideError;
1537 1537
             $message = sprintf(
1538 1538
                 $message ?: 'Array does not contain an element with key "%s"',
1539 1539
                 $this->stringify($key)
1540 1540
             );
1541
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEY_EXISTS, $fieldName, ['key' => $key]);
1541
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEY_EXISTS, $fieldName, [ 'key' => $key ]);
1542 1542
         }
1543 1543
         return $this;
1544 1544
     }
@@ -1554,21 +1554,21 @@  discard block
 block discarded – undo
1554 1554
      */
1555 1555
     public function keysExist($keys, $message = null, $fieldName = null)
1556 1556
     {
1557
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1557
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1558 1558
         {
1559 1559
             return $this;
1560 1560
         }
1561 1561
         $this->isArray($message, $fieldName);
1562
-        foreach ( $keys as $key )
1562
+        foreach ($keys as $key)
1563 1563
         {
1564
-            if ( !array_key_exists($key, $this->value) )
1564
+            if ( ! array_key_exists($key, $this->value))
1565 1565
             {
1566 1566
                 $message = $message
1567 1567
                     ?: sprintf(
1568 1568
                         'Array does not contain an element with key "%s"',
1569 1569
                         $this->stringify($key)
1570 1570
                     );
1571
-                throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEYS_EXIST, $fieldName, ['key' => $key]);
1571
+                throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEYS_EXIST, $fieldName, [ 'key' => $key ]);
1572 1572
             }
1573 1573
         }
1574 1574
         return $this;
@@ -1585,19 +1585,19 @@  discard block
 block discarded – undo
1585 1585
      */
1586 1586
     public function propertyExists($key, $message = null, $fieldName = null)
1587 1587
     {
1588
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1588
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1589 1589
         {
1590 1590
             return $this;
1591 1591
         }
1592 1592
         $this->isObject($message, $fieldName);
1593
-        if ( !property_exists($this->value, $key) && !isset( $this->value->{$key} ) )
1593
+        if ( ! property_exists($this->value, $key) && ! isset($this->value->{$key} ))
1594 1594
         {
1595 1595
             $message = $message
1596 1596
                 ?: sprintf(
1597 1597
                     'Object does not contain a property with key "%s"',
1598 1598
                     $this->stringify($key)
1599 1599
                 );
1600
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_PROPERTY_EXISTS, $fieldName, ['key' => $key]);
1600
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_PROPERTY_EXISTS, $fieldName, [ 'key' => $key ]);
1601 1601
         }
1602 1602
         return $this;
1603 1603
     }
@@ -1613,22 +1613,22 @@  discard block
 block discarded – undo
1613 1613
      */
1614 1614
     public function propertiesExist(array $keys, $message = null, $fieldName = null)
1615 1615
     {
1616
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1616
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1617 1617
         {
1618 1618
             return $this;
1619 1619
         }
1620 1620
         $this->isObject($message, $fieldName);
1621
-        foreach ( $keys as $key )
1621
+        foreach ($keys as $key)
1622 1622
         {
1623 1623
             // Using isset to allow resolution of magically defined properties
1624
-            if ( !property_exists($this->value, $key) && !isset( $this->value->{$key} ) )
1624
+            if ( ! property_exists($this->value, $key) && ! isset($this->value->{$key} ))
1625 1625
             {
1626 1626
                 $message = $message
1627 1627
                     ?: sprintf(
1628 1628
                         'Object does not contain a property with key "%s"',
1629 1629
                         $this->stringify($key)
1630 1630
                     );
1631
-                throw $this->createException($message, $this->overrideCode ?: self::INVALID_PROPERTIES_EXIST, $fieldName, ['key' => $key]);
1631
+                throw $this->createException($message, $this->overrideCode ?: self::INVALID_PROPERTIES_EXIST, $fieldName, [ 'key' => $key ]);
1632 1632
             }
1633 1633
         }
1634 1634
         return $this;
@@ -1644,12 +1644,12 @@  discard block
 block discarded – undo
1644 1644
      */
1645 1645
     public function utf8($message = null, $fieldName = null)
1646 1646
     {
1647
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1647
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1648 1648
         {
1649 1649
             return $this;
1650 1650
         }
1651 1651
         $this->string($message, $fieldName);
1652
-        if ( mb_detect_encoding($this->value, 'UTF-8', true) !== 'UTF-8' )
1652
+        if (mb_detect_encoding($this->value, 'UTF-8', true) !== 'UTF-8')
1653 1653
         {
1654 1654
             $message = $message
1655 1655
                 ?: sprintf(
@@ -1672,12 +1672,12 @@  discard block
 block discarded – undo
1672 1672
      */
1673 1673
     public function ascii($message = null, $fieldName = null)
1674 1674
     {
1675
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1675
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1676 1676
         {
1677 1677
             return $this;
1678 1678
         }
1679 1679
         $this->string($message, $fieldName);
1680
-        if ( ! preg_match('/^[ -~]+$/', $this->value) )
1680
+        if ( ! preg_match('/^[ -~]+$/', $this->value))
1681 1681
         {
1682 1682
             $message = $message
1683 1683
                 ?: sprintf(
@@ -1701,19 +1701,19 @@  discard block
 block discarded – undo
1701 1701
      */
1702 1702
     public function keyIsset($key, $message = null, $fieldName = null)
1703 1703
     {
1704
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1704
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1705 1705
         {
1706 1706
             return $this;
1707 1707
         }
1708 1708
         $this->isArrayAccessible($message, $fieldName);
1709
-        if ( !isset( $this->value[$key] ) )
1709
+        if ( ! isset($this->value[ $key ]))
1710 1710
         {
1711 1711
             $message = $message ?: $this->overrideError;
1712 1712
             $message = sprintf(
1713 1713
                 $message ?: 'The element with key "%s" was not found',
1714 1714
                 $this->stringify($key)
1715 1715
             );
1716
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEY_ISSET, $fieldName, ['key' => $key]);
1716
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEY_ISSET, $fieldName, [ 'key' => $key ]);
1717 1717
         }
1718 1718
         return $this;
1719 1719
     }
@@ -1730,12 +1730,12 @@  discard block
 block discarded – undo
1730 1730
      */
1731 1731
     public function notEmptyKey($key, $message = null, $fieldName = null)
1732 1732
     {
1733
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1733
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1734 1734
         {
1735 1735
             return $this;
1736 1736
         }
1737 1737
         $this->keyIsset($key, $message, $fieldName);
1738
-        (new Assert($this->value[$key]))->setExceptionClass($this->exceptionClass)->notEmpty($message, $fieldName);
1738
+        (new Assert($this->value[ $key ]))->setExceptionClass($this->exceptionClass)->notEmpty($message, $fieldName);
1739 1739
         return $this;
1740 1740
     }
1741 1741
 
@@ -1749,11 +1749,11 @@  discard block
 block discarded – undo
1749 1749
      */
1750 1750
     public function notBlank($message = null, $fieldName = null)
1751 1751
     {
1752
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1752
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1753 1753
         {
1754 1754
             return $this;
1755 1755
         }
1756
-        if ( false === $this->value || ( empty( $this->value ) && '0' != $this->value ) )
1756
+        if (false === $this->value || (empty($this->value) && '0' != $this->value))
1757 1757
         {
1758 1758
             $message = $message ?: $this->overrideError;
1759 1759
             $message = sprintf(
@@ -1776,11 +1776,11 @@  discard block
 block discarded – undo
1776 1776
      */
1777 1777
     public function isInstanceOf($className, $message = null, $fieldName = null)
1778 1778
     {
1779
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1779
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1780 1780
         {
1781 1781
             return $this;
1782 1782
         }
1783
-        if ( !( $this->value instanceof $className ) )
1783
+        if ( ! ($this->value instanceof $className))
1784 1784
         {
1785 1785
             $message = $message ?: $this->overrideError;
1786 1786
             $message = sprintf(
@@ -1788,7 +1788,7 @@  discard block
 block discarded – undo
1788 1788
                 $this->stringify($this->value),
1789 1789
                 $className
1790 1790
             );
1791
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_INSTANCE_OF, $fieldName, ['class' => $className]);
1791
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_INSTANCE_OF, $fieldName, [ 'class' => $className ]);
1792 1792
         }
1793 1793
         return $this;
1794 1794
     }
@@ -1804,11 +1804,11 @@  discard block
 block discarded – undo
1804 1804
      */
1805 1805
     public function notIsInstanceOf($className, $message = null, $fieldName = null)
1806 1806
     {
1807
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1807
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1808 1808
         {
1809 1809
             return $this;
1810 1810
         }
1811
-        if ( $this->value instanceof $className )
1811
+        if ($this->value instanceof $className)
1812 1812
         {
1813 1813
             $message = $message ?: $this->overrideError;
1814 1814
             $message = sprintf(
@@ -1816,7 +1816,7 @@  discard block
 block discarded – undo
1816 1816
                 $this->stringify($this->value),
1817 1817
                 $className
1818 1818
             );
1819
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_INSTANCE_OF, $fieldName, ['class' => $className]);
1819
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_INSTANCE_OF, $fieldName, [ 'class' => $className ]);
1820 1820
         }
1821 1821
         return $this;
1822 1822
     }
@@ -1832,11 +1832,11 @@  discard block
 block discarded – undo
1832 1832
      */
1833 1833
     public function subclassOf($className, $message = null, $fieldName = null)
1834 1834
     {
1835
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1835
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1836 1836
         {
1837 1837
             return $this;
1838 1838
         }
1839
-        if ( !is_subclass_of($this->value, $className) )
1839
+        if ( ! is_subclass_of($this->value, $className))
1840 1840
         {
1841 1841
             $message = $message ?: $this->overrideError;
1842 1842
             $message = sprintf(
@@ -1844,7 +1844,7 @@  discard block
 block discarded – undo
1844 1844
                 $this->stringify($this->value),
1845 1845
                 $className
1846 1846
             );
1847
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_SUBCLASS_OF, $fieldName, ['class' => $className]);
1847
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_SUBCLASS_OF, $fieldName, [ 'class' => $className ]);
1848 1848
         }
1849 1849
         return $this;
1850 1850
     }
@@ -1861,12 +1861,12 @@  discard block
 block discarded – undo
1861 1861
      */
1862 1862
     public function range($minValue, $maxValue, $message = null, $fieldName = null)
1863 1863
     {
1864
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1864
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1865 1865
         {
1866 1866
             return $this;
1867 1867
         }
1868 1868
         $this->numeric($message, $fieldName);
1869
-        if ( $this->value < $minValue || $this->value > $maxValue )
1869
+        if ($this->value < $minValue || $this->value > $maxValue)
1870 1870
         {
1871 1871
             $message = $message ?: $this->overrideError;
1872 1872
             $message = sprintf(
@@ -1894,12 +1894,12 @@  discard block
 block discarded – undo
1894 1894
      */
1895 1895
     public function min($minValue, $message = null, $fieldName = null)
1896 1896
     {
1897
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1897
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1898 1898
         {
1899 1899
             return $this;
1900 1900
         }
1901 1901
         $this->numeric($message, $fieldName);
1902
-        if ( $this->value < $minValue )
1902
+        if ($this->value < $minValue)
1903 1903
         {
1904 1904
             $message = $message ?: $this->overrideError;
1905 1905
             $message = sprintf(
@@ -1907,7 +1907,7 @@  discard block
 block discarded – undo
1907 1907
                 $this->stringify($this->value),
1908 1908
                 $this->stringify($minValue)
1909 1909
             );
1910
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_MIN, $fieldName, ['min' => $minValue]);
1910
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_MIN, $fieldName, [ 'min' => $minValue ]);
1911 1911
         }
1912 1912
         return $this;
1913 1913
     }
@@ -1923,12 +1923,12 @@  discard block
 block discarded – undo
1923 1923
      */
1924 1924
     public function max($maxValue, $message = null, $fieldName = null)
1925 1925
     {
1926
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1926
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1927 1927
         {
1928 1928
             return $this;
1929 1929
         }
1930 1930
         $this->numeric($message, $fieldName);
1931
-        if ( $this->value > $maxValue )
1931
+        if ($this->value > $maxValue)
1932 1932
         {
1933 1933
             $message = $message ?: $this->overrideError;
1934 1934
             $message = sprintf(
@@ -1936,7 +1936,7 @@  discard block
 block discarded – undo
1936 1936
                 $this->stringify($this->value),
1937 1937
                 $this->stringify($maxValue)
1938 1938
             );
1939
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_MAX, $fieldName, ['max' => $maxValue]);
1939
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_MAX, $fieldName, [ 'max' => $maxValue ]);
1940 1940
         }
1941 1941
         return $this;
1942 1942
     }
@@ -1951,13 +1951,13 @@  discard block
 block discarded – undo
1951 1951
      */
1952 1952
     public function file($message = null, $fieldName = null)
1953 1953
     {
1954
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1954
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1955 1955
         {
1956 1956
             return $this;
1957 1957
         }
1958 1958
         $this->string($message, $fieldName);
1959 1959
         $this->notEmpty($message, $fieldName);
1960
-        if ( !is_file($this->value) )
1960
+        if ( ! is_file($this->value))
1961 1961
         {
1962 1962
             $message = $message ?: $this->overrideError;
1963 1963
             $message = sprintf(
@@ -1979,13 +1979,13 @@  discard block
 block discarded – undo
1979 1979
      */
1980 1980
     public function fileOrDirectoryExists($message = null, $fieldName = null)
1981 1981
     {
1982
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1982
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1983 1983
         {
1984 1984
             return $this;
1985 1985
         }
1986 1986
         $this->string($message, $fieldName);
1987 1987
         $this->notEmpty($message, $fieldName);
1988
-        if ( ! file_exists($this->value) )
1988
+        if ( ! file_exists($this->value))
1989 1989
         {
1990 1990
             $message = $message ?: $this->overrideError;
1991 1991
             $message = sprintf(
@@ -2007,12 +2007,12 @@  discard block
 block discarded – undo
2007 2007
      */
2008 2008
     public function directory($message = null, $fieldName = null)
2009 2009
     {
2010
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2010
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2011 2011
         {
2012 2012
             return $this;
2013 2013
         }
2014 2014
         $this->string($message, $fieldName);
2015
-        if ( !is_dir($this->value) )
2015
+        if ( ! is_dir($this->value))
2016 2016
         {
2017 2017
             $message = $message ?: $this->overrideError;
2018 2018
             $message = sprintf(
@@ -2034,12 +2034,12 @@  discard block
 block discarded – undo
2034 2034
      */
2035 2035
     public function readable($message = null, $fieldName = null)
2036 2036
     {
2037
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2037
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2038 2038
         {
2039 2039
             return $this;
2040 2040
         }
2041 2041
         $this->string($message, $fieldName);
2042
-        if ( !is_readable($this->value) )
2042
+        if ( ! is_readable($this->value))
2043 2043
         {
2044 2044
             $message = $message ?: $this->overrideError;
2045 2045
             $message = sprintf(
@@ -2061,12 +2061,12 @@  discard block
 block discarded – undo
2061 2061
      */
2062 2062
     public function writeable($message = null, $fieldName = null)
2063 2063
     {
2064
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2064
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2065 2065
         {
2066 2066
             return $this;
2067 2067
         }
2068 2068
         $this->string($message, $fieldName);
2069
-        if ( !is_writeable($this->value) )
2069
+        if ( ! is_writeable($this->value))
2070 2070
         {
2071 2071
             $message = $message ?: $this->overrideError;
2072 2072
             $message = sprintf(
@@ -2088,12 +2088,12 @@  discard block
 block discarded – undo
2088 2088
      */
2089 2089
     public function email($message = null, $fieldName = null)
2090 2090
     {
2091
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2091
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2092 2092
         {
2093 2093
             return $this;
2094 2094
         }
2095 2095
         $this->string($message, $fieldName);
2096
-        if ( ! filter_var($this->value, FILTER_VALIDATE_EMAIL) )
2096
+        if ( ! filter_var($this->value, FILTER_VALIDATE_EMAIL))
2097 2097
         {
2098 2098
             $message = $message ?: $this->overrideError;
2099 2099
             $message = sprintf(
@@ -2106,7 +2106,7 @@  discard block
 block discarded – undo
2106 2106
         {
2107 2107
             $host = substr($this->value, strpos($this->value, '@') + 1);
2108 2108
             // Likely not a FQDN, bug in PHP FILTER_VALIDATE_EMAIL prior to PHP 5.3.3
2109
-            if ( version_compare(PHP_VERSION, '5.3.3', '<') && strpos($host, '.') === false )
2109
+            if (version_compare(PHP_VERSION, '5.3.3', '<') && strpos($host, '.') === false)
2110 2110
             {
2111 2111
                 $message = $message ?: $this->overrideError;
2112 2112
                 $message = sprintf(
@@ -2129,7 +2129,7 @@  discard block
 block discarded – undo
2129 2129
      */
2130 2130
     public function emailPrefix($message = null, $fieldName = null)
2131 2131
     {
2132
-        $this->value($this->value . '@example.com');
2132
+        $this->value($this->value.'@example.com');
2133 2133
         return $this->email($message, $fieldName);
2134 2134
     }
2135 2135
 
@@ -2149,12 +2149,12 @@  discard block
 block discarded – undo
2149 2149
      */
2150 2150
     public function url($message = null, $fieldName = null)
2151 2151
     {
2152
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2152
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2153 2153
         {
2154 2154
             return $this;
2155 2155
         }
2156 2156
         $this->string($message, $fieldName);
2157
-        $protocols = ['http', 'https'];
2157
+        $protocols = [ 'http', 'https' ];
2158 2158
         $pattern   = '~^
2159 2159
             (%s)://                                 # protocol
2160 2160
             (
@@ -2169,8 +2169,8 @@  discard block
 block discarded – undo
2169 2169
             (:[0-9]+)?                              # a port (optional)
2170 2170
             (/?|/\S+)                               # a /, nothing or a / with something
2171 2171
         $~ixu';
2172
-        $pattern   = sprintf($pattern, implode('|', $protocols));
2173
-        if ( !preg_match($pattern, $this->value) )
2172
+        $pattern = sprintf($pattern, implode('|', $protocols));
2173
+        if ( ! preg_match($pattern, $this->value))
2174 2174
         {
2175 2175
             $message = $message ?: $this->overrideError;
2176 2176
             $message = sprintf(
@@ -2195,13 +2195,13 @@  discard block
 block discarded – undo
2195 2195
      */
2196 2196
     public function domainName($message = null, $fieldName = null)
2197 2197
     {
2198
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2198
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2199 2199
         {
2200 2200
             return $this;
2201 2201
         }
2202 2202
         $this->string($message, $fieldName);
2203
-        $pattern   = '/^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}$/';
2204
-        if ( ! preg_match($pattern, $this->value) )
2203
+        $pattern = '/^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}$/';
2204
+        if ( ! preg_match($pattern, $this->value))
2205 2205
         {
2206 2206
             $message = $message ?: $this->overrideError;
2207 2207
             $message = sprintf(
@@ -2223,7 +2223,7 @@  discard block
 block discarded – undo
2223 2223
      */
2224 2224
     public function ausMobile($message = null, $fieldName = null)
2225 2225
     {
2226
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2226
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2227 2227
         {
2228 2228
             return $this;
2229 2229
         }
@@ -2231,7 +2231,7 @@  discard block
 block discarded – undo
2231 2231
         {
2232 2232
             $this->regex('/^04[0-9]{8})$/', $message, $fieldName);
2233 2233
         }
2234
-        catch ( AssertionFailedException $e )
2234
+        catch (AssertionFailedException $e)
2235 2235
         {
2236 2236
             $message = $message ?: $this->overrideError;
2237 2237
             $message = sprintf(
@@ -2254,7 +2254,7 @@  discard block
 block discarded – undo
2254 2254
      */
2255 2255
     public function alnum($message = null, $fieldName = null)
2256 2256
     {
2257
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2257
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2258 2258
         {
2259 2259
             return $this;
2260 2260
         }
@@ -2285,11 +2285,11 @@  discard block
 block discarded – undo
2285 2285
      */
2286 2286
     public function true($message = null, $fieldName = null)
2287 2287
     {
2288
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2288
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2289 2289
         {
2290 2290
             return $this;
2291 2291
         }
2292
-        if ( $this->value !== true )
2292
+        if ($this->value !== true)
2293 2293
         {
2294 2294
             $message = $message ?: $this->overrideError;
2295 2295
             $message = sprintf(
@@ -2312,11 +2312,11 @@  discard block
 block discarded – undo
2312 2312
      */
2313 2313
     public function truthy($message = null, $fieldName = null)
2314 2314
     {
2315
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2315
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2316 2316
         {
2317 2317
             return $this;
2318 2318
         }
2319
-        if ( ! $this->value )
2319
+        if ( ! $this->value)
2320 2320
         {
2321 2321
             $message = $message ?: $this->overrideError;
2322 2322
             $message = sprintf(
@@ -2338,11 +2338,11 @@  discard block
 block discarded – undo
2338 2338
      */
2339 2339
     public function false($message = null, $fieldName = null)
2340 2340
     {
2341
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2341
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2342 2342
         {
2343 2343
             return $this;
2344 2344
         }
2345
-        if ( $this->value !== false )
2345
+        if ($this->value !== false)
2346 2346
         {
2347 2347
             $message = $message ?: $this->overrideError;
2348 2348
             $message = sprintf(
@@ -2364,11 +2364,11 @@  discard block
 block discarded – undo
2364 2364
      */
2365 2365
     public function notFalse($message = null, $fieldName = null)
2366 2366
     {
2367
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2367
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2368 2368
         {
2369 2369
             return $this;
2370 2370
         }
2371
-        if ( $this->value === false )
2371
+        if ($this->value === false)
2372 2372
         {
2373 2373
             $message = $message ?: $this->overrideError;
2374 2374
             $message = sprintf(
@@ -2390,11 +2390,11 @@  discard block
 block discarded – undo
2390 2390
      */
2391 2391
     public function classExists($message = null, $fieldName = null)
2392 2392
     {
2393
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2393
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2394 2394
         {
2395 2395
             return $this;
2396 2396
         }
2397
-        if ( !class_exists($this->value) )
2397
+        if ( ! class_exists($this->value))
2398 2398
         {
2399 2399
             $message = $message ?: $this->overrideError;
2400 2400
             $message = sprintf(
@@ -2417,12 +2417,12 @@  discard block
 block discarded – undo
2417 2417
      */
2418 2418
     public function implementsInterface($interfaceName, $message = null, $fieldName = null)
2419 2419
     {
2420
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2420
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2421 2421
         {
2422 2422
             return $this;
2423 2423
         }
2424 2424
         $reflection = new \ReflectionClass($this->value);
2425
-        if ( !$reflection->implementsInterface($interfaceName) )
2425
+        if ( ! $reflection->implementsInterface($interfaceName))
2426 2426
         {
2427 2427
             $message = $message ?: $this->overrideError;
2428 2428
             $message = sprintf(
@@ -2430,7 +2430,7 @@  discard block
 block discarded – undo
2430 2430
                 $this->stringify($this->value),
2431 2431
                 $this->stringify($interfaceName)
2432 2432
             );
2433
-            throw $this->createException($message, self::INTERFACE_NOT_IMPLEMENTED, $fieldName, ['interface' => $interfaceName]);
2433
+            throw $this->createException($message, self::INTERFACE_NOT_IMPLEMENTED, $fieldName, [ 'interface' => $interfaceName ]);
2434 2434
         }
2435 2435
         return $this;
2436 2436
     }
@@ -2451,11 +2451,11 @@  discard block
 block discarded – undo
2451 2451
      */
2452 2452
     public function isJsonString($message = null, $fieldName = null)
2453 2453
     {
2454
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2454
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2455 2455
         {
2456 2456
             return $this;
2457 2457
         }
2458
-        if ( null === json_decode($this->value) && JSON_ERROR_NONE !== json_last_error() )
2458
+        if (null === json_decode($this->value) && JSON_ERROR_NONE !== json_last_error())
2459 2459
         {
2460 2460
             $message = $message ?: $this->overrideError;
2461 2461
             $message = sprintf(
@@ -2479,16 +2479,16 @@  discard block
 block discarded – undo
2479 2479
      */
2480 2480
     public function uuid($message = null, $fieldName = null)
2481 2481
     {
2482
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2482
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2483 2483
         {
2484 2484
             return $this;
2485 2485
         }
2486
-        $this->value = str_replace(['urn:', 'uuid:', '{', '}'], '', $this->value);
2487
-        if ( $this->value === '00000000-0000-0000-0000-000000000000' )
2486
+        $this->value = str_replace([ 'urn:', 'uuid:', '{', '}' ], '', $this->value);
2487
+        if ($this->value === '00000000-0000-0000-0000-000000000000')
2488 2488
         {
2489 2489
             return $this;
2490 2490
         }
2491
-        if ( !preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $this->value) )
2491
+        if ( ! preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $this->value))
2492 2492
         {
2493 2493
             $message = $message ?: $this->overrideError;
2494 2494
             $message = sprintf(
@@ -2517,11 +2517,11 @@  discard block
 block discarded – undo
2517 2517
      */
2518 2518
     public function samAccountName($message = null, $fieldName = null)
2519 2519
     {
2520
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2520
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2521 2521
         {
2522 2522
             return $this;
2523 2523
         }
2524
-        if ( !preg_match('/^([a-z0-9]{4,20})$/', $this->value) )
2524
+        if ( ! preg_match('/^([a-z0-9]{4,20})$/', $this->value))
2525 2525
         {
2526 2526
             $message = $message ?: $this->overrideError;
2527 2527
             $message = sprintf(
@@ -2543,7 +2543,7 @@  discard block
 block discarded – undo
2543 2543
      */
2544 2544
     public function userPrincipalName($message = null, $fieldName = null)
2545 2545
     {
2546
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2546
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2547 2547
         {
2548 2548
             return $this;
2549 2549
         }
@@ -2575,11 +2575,11 @@  discard block
 block discarded – undo
2575 2575
      */
2576 2576
     public function count($count, $message = null, $fieldName = null)
2577 2577
     {
2578
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2578
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2579 2579
         {
2580 2580
             return $this;
2581 2581
         }
2582
-        if ( $count !== count($this->value) )
2582
+        if ($count !== count($this->value))
2583 2583
         {
2584 2584
             $message = $message ?: $this->overrideError;
2585 2585
             $message = sprintf(
@@ -2587,7 +2587,7 @@  discard block
 block discarded – undo
2587 2587
                 $this->stringify($this->value),
2588 2588
                 $this->stringify($count)
2589 2589
             );
2590
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_COUNT, $fieldName, ['count' => $count]);
2590
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_COUNT, $fieldName, [ 'count' => $count ]);
2591 2591
         }
2592 2592
         return $this;
2593 2593
     }
@@ -2600,24 +2600,24 @@  discard block
 block discarded – undo
2600 2600
      */
2601 2601
     protected function doAllOrNullOr($func, $args)
2602 2602
     {
2603
-        if ( $this->nullOr && is_null($this->value) )
2603
+        if ($this->nullOr && is_null($this->value))
2604 2604
         {
2605 2605
             return true;
2606 2606
         }
2607
-        if ( $this->emptyOr && empty($this->value) )
2607
+        if ($this->emptyOr && empty($this->value))
2608 2608
         {
2609 2609
             return true;
2610 2610
         }
2611
-        if ( $this->all && (new Assert($this->value))->setExceptionClass($this->exceptionClass)->isTraversable() )
2611
+        if ($this->all && (new Assert($this->value))->setExceptionClass($this->exceptionClass)->isTraversable())
2612 2612
         {
2613
-            foreach ( $this->value as $idx => $value )
2613
+            foreach ($this->value as $idx => $value)
2614 2614
             {
2615 2615
                 $object = (new Assert($value))->setExceptionClass($this->exceptionClass);
2616
-                call_user_func_array([$object, $func], $args);
2616
+                call_user_func_array([ $object, $func ], $args);
2617 2617
             }
2618 2618
             return true;
2619 2619
         }
2620
-        return ( $this->nullOr && is_null($this->value) ) || ( $this->emptyOr && empty($this->value) ) ? true : false;
2620
+        return ($this->nullOr && is_null($this->value)) || ($this->emptyOr && empty($this->value)) ? true : false;
2621 2621
     }
2622 2622
 
2623 2623
     /**
@@ -2631,12 +2631,12 @@  discard block
 block discarded – undo
2631 2631
      */
2632 2632
     public function choicesNotEmpty(array $choices, $message = null, $fieldName = null)
2633 2633
     {
2634
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2634
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2635 2635
         {
2636 2636
             return $this;
2637 2637
         }
2638 2638
         $this->notEmpty($message, $fieldName);
2639
-        foreach ( $choices as $choice )
2639
+        foreach ($choices as $choice)
2640 2640
         {
2641 2641
             $this->notEmptyKey($choice, $message, $fieldName);
2642 2642
         }
@@ -2654,12 +2654,12 @@  discard block
 block discarded – undo
2654 2654
      */
2655 2655
     public function methodExists($object, $message = null, $fieldName = null)
2656 2656
     {
2657
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2657
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2658 2658
         {
2659 2659
             return $this;
2660 2660
         }
2661 2661
         (new Assert($object))->setExceptionClass($this->exceptionClass)->isObject($message, $fieldName);
2662
-        if ( !method_exists($object, $this->value) )
2662
+        if ( ! method_exists($object, $this->value))
2663 2663
         {
2664 2664
             $message = $message ?: $this->overrideError;
2665 2665
             $message = sprintf(
@@ -2681,11 +2681,11 @@  discard block
 block discarded – undo
2681 2681
      */
2682 2682
     public function isObject($message = null, $fieldName = null)
2683 2683
     {
2684
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2684
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2685 2685
         {
2686 2686
             return $this;
2687 2687
         }
2688
-        if ( !is_object($this->value) )
2688
+        if ( ! is_object($this->value))
2689 2689
         {
2690 2690
             $message = $message ?: $this->overrideError;
2691 2691
             $message = sprintf(
@@ -2705,32 +2705,32 @@  discard block
 block discarded – undo
2705 2705
      */
2706 2706
     private function stringify($value)
2707 2707
     {
2708
-        if ( is_bool($value) )
2708
+        if (is_bool($value))
2709 2709
         {
2710 2710
             return $value ? '<TRUE>' : '<FALSE>';
2711 2711
         }
2712
-        if ( is_scalar($value) )
2712
+        if (is_scalar($value))
2713 2713
         {
2714 2714
             $val = (string)$value;
2715
-            if ( strlen($val) > 100 )
2715
+            if (strlen($val) > 100)
2716 2716
             {
2717
-                $val = substr($val, 0, 97) . '...';
2717
+                $val = substr($val, 0, 97).'...';
2718 2718
             }
2719 2719
             return $val;
2720 2720
         }
2721
-        if ( is_array($value) )
2721
+        if (is_array($value))
2722 2722
         {
2723 2723
             return '<ARRAY>';
2724 2724
         }
2725
-        if ( is_object($value) )
2725
+        if (is_object($value))
2726 2726
         {
2727 2727
             return get_class($value);
2728 2728
         }
2729
-        if ( is_resource($value) )
2729
+        if (is_resource($value))
2730 2730
         {
2731 2731
             return '<RESOURCE>';
2732 2732
         }
2733
-        if ( $value === null )
2733
+        if ($value === null)
2734 2734
         {
2735 2735
             return '<NULL>';
2736 2736
         }
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -157,8 +157,7 @@  discard block
 block discarded – undo
157 157
             try
158 158
             {
159 159
                 $validator->__invoke();
160
-            }
161
-            catch ( AssertionFailedException $e )
160
+            } catch ( AssertionFailedException $e )
162 161
             {
163 162
                 $errors[$fieldName]     = $e->getMessage();
164 163
             }
@@ -179,8 +178,7 @@  discard block
 block discarded – undo
179 178
             try
180 179
             {
181 180
                 $validator->__invoke();
182
-            }
183
-            catch ( AssertionFailedException $e )
181
+            } catch ( AssertionFailedException $e )
184 182
             {
185 183
                 $errors[$fieldName]     = $e->getMessage();
186 184
             }
@@ -2101,8 +2099,7 @@  discard block
 block discarded – undo
2101 2099
                 $this->stringify($this->value)
2102 2100
             );
2103 2101
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_EMAIL, $fieldName);
2104
-        }
2105
-        else
2102
+        } else
2106 2103
         {
2107 2104
             $host = substr($this->value, strpos($this->value, '@') + 1);
2108 2105
             // Likely not a FQDN, bug in PHP FILTER_VALIDATE_EMAIL prior to PHP 5.3.3
@@ -2230,8 +2227,7 @@  discard block
 block discarded – undo
2230 2227
         try
2231 2228
         {
2232 2229
             $this->regex('/^04[0-9]{8})$/', $message, $fieldName);
2233
-        }
2234
-        catch ( AssertionFailedException $e )
2230
+        } catch ( AssertionFailedException $e )
2235 2231
         {
2236 2232
             $message = $message ?: $this->overrideError;
2237 2233
             $message = sprintf(
@@ -2261,8 +2257,7 @@  discard block
 block discarded – undo
2261 2257
         try
2262 2258
         {
2263 2259
             $this->regex('(^([a-zA-Z]{1}[a-zA-Z0-9]*)$)', $message, $fieldName);
2264
-        }
2265
-        catch (AssertionFailedException $e)
2260
+        } catch (AssertionFailedException $e)
2266 2261
         {
2267 2262
             $message = $message ?: $this->overrideError;
2268 2263
             $message = sprintf(
@@ -2550,8 +2545,7 @@  discard block
 block discarded – undo
2550 2545
         try
2551 2546
         {
2552 2547
             $this->email($message, $fieldName);
2553
-        }
2554
-        catch (AssertionFailedException $e)
2548
+        } catch (AssertionFailedException $e)
2555 2549
         {
2556 2550
             $message = $message ?: $this->overrideError;
2557 2551
             $message = sprintf(
Please login to merge, or discard this patch.
src/functions.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare(strict_types=1);
1
+<?php declare(strict_types = 1);
2 2
 
3 3
 namespace Terah\Assert;
4 4
 
@@ -31,22 +31,22 @@  discard block
 block discarded – undo
31 31
  * @param string $level
32 32
  * @return Assert
33 33
  */
34
-function Assert($value, $fieldName='', $code=0, $error='', $level=Assert::WARNING)
34
+function Assert($value, $fieldName = '', $code = 0, $error = '', $level = Assert::WARNING)
35 35
 {
36 36
     $assert = new Assert($value);
37
-    if ( $fieldName )
37
+    if ($fieldName)
38 38
     {
39 39
         $assert->fieldName($fieldName);
40 40
     }
41
-    if ( $code )
41
+    if ($code)
42 42
     {
43 43
         $assert->code($code);
44 44
     }
45
-    if ( $error )
45
+    if ($error)
46 46
     {
47 47
         $assert->error($error);
48 48
     }
49
-    if ( $level )
49
+    if ($level)
50 50
     {
51 51
         $assert->level($level);
52 52
     }
@@ -64,22 +64,22 @@  discard block
 block discarded – undo
64 64
  * @param string $level
65 65
  * @return Assert
66 66
  */
67
-function Validate($value, $fieldName='', $code=0, $error='', $level=Assert::WARNING)
67
+function Validate($value, $fieldName = '', $code = 0, $error = '', $level = Assert::WARNING)
68 68
 {
69 69
     $assert = new Assert($value);
70
-    if ( $fieldName )
70
+    if ($fieldName)
71 71
     {
72 72
         $assert->fieldName($fieldName);
73 73
     }
74
-    if ( $code )
74
+    if ($code)
75 75
     {
76 76
         $assert->code($code);
77 77
     }
78
-    if ( $error )
78
+    if ($error)
79 79
     {
80 80
         $assert->error($error);
81 81
     }
82
-    if ( $level )
82
+    if ($level)
83 83
     {
84 84
         $assert->level($level);
85 85
     }
Please login to merge, or discard this patch.
src/AssertionFailedException.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare(strict_types=1);
1
+<?php declare(strict_types = 1);
2 2
 
3 3
 namespace Terah\Assert;
4 4
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      * @param array $constraints
41 41
      * @param string $level
42 42
      */
43
-    public function __construct(string $message, int $code, string $fieldName = null, $value, array $constraints=[], string $level='critical', string $propertyPath = null)
43
+    public function __construct(string $message, int $code, string $fieldName = null, $value, array $constraints = [ ], string $level = 'critical', string $propertyPath = null)
44 44
     {
45 45
         parent::__construct($message, $code);
46 46
         $this->fieldName        = $fieldName;
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
         $this->constraints      = $constraints;
49 49
         $this->level            = $level;
50 50
         $this->propertyPath     = $propertyPath;
51
-        foreach ( $this->getTrace() as $point )
51
+        foreach ($this->getTrace() as $point)
52 52
         {
53
-            if ( $this->location )
53
+            if ($this->location)
54 54
             {
55 55
                 continue;
56 56
             }
57
-            $class = $point['class'] ?: '';
58
-            if ( $class !== 'Terah\\Assert\\Assert' )
57
+            $class = $point[ 'class' ] ?: '';
58
+            if ($class !== 'Terah\\Assert\\Assert')
59 59
             {
60 60
                 $this->location = (object)$point;
61 61
             }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public function getPropertyPathAndCallingLocation() : string
125 125
     {
126
-        return $this->getPropertyPath() . ' in ' . $this->getCallingFileAndLine();
126
+        return $this->getPropertyPath().' in '.$this->getCallingFileAndLine();
127 127
     }
128 128
 
129 129
     /**
@@ -134,15 +134,15 @@  discard block
 block discarded – undo
134 134
      */
135 135
     protected function getCallingFileAndLine() : string
136 136
     {
137
-        foreach ( $this->getTrace() as $trace )
137
+        foreach ($this->getTrace() as $trace)
138 138
         {
139 139
             $trace = (object)$trace;
140
-            if ( empty($trace->file) )
140
+            if (empty($trace->file))
141 141
             {
142 142
                 continue;
143 143
             }
144 144
             $file = static::beforeLast('.php', static::afterLast('/', $trace->file));
145
-            if ( in_array($file, ['AssertionChain', 'Assertion']) )
145
+            if (in_array($file, [ 'AssertionChain', 'Assertion' ]))
146 146
             {
147 147
                 continue;
148 148
             }
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
      * @param bool $return_original
170 170
      * @return string
171 171
      */
172
-    public static function afterLast(string $needle, string $haystack, bool $return_original=false) : string
172
+    public static function afterLast(string $needle, string $haystack, bool $return_original = false) : string
173 173
     {
174
-        if ( static::strrevpos($haystack, $needle) !== -1 )
174
+        if (static::strrevpos($haystack, $needle) !== -1)
175 175
         {
176 176
             return mb_substr($haystack, static::strrevpos($haystack, $needle) + mb_strlen($needle));
177 177
         }
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
      */
199 199
     public static function beforeLast(string $needle, string $haystack) : string
200 200
     {
201
-        $position   = static::strrevpos($haystack, $needle);
201
+        $position = static::strrevpos($haystack, $needle);
202 202
 
203 203
         return $position === -1 ? '' : mb_substr($haystack, 0, static::strrevpos($haystack, $needle));
204 204
     }
Please login to merge, or discard this patch.
src/ValidationFailedException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php declare(strict_types=1);
1
+<?php declare(strict_types = 1);
2 2
 
3 3
 namespace Terah\Assert;
4 4
 
Please login to merge, or discard this patch.