Completed
Push — master ( 5a3cd6...c0879b )
by Terry
02:54
created
src/Assert.php 1 patch
Spacing   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
     const INVALID_LESS_THAN_OR_EQ = 312;
92 92
 
93 93
     /** @var bool */
94
-    protected $nullOr       = false;
94
+    protected $nullOr = false;
95 95
 
96 96
     /** @var bool */
97
-    protected $emptyOr     = false;
97
+    protected $emptyOr = false;
98 98
 
99 99
     /** @var mixed */
100 100
     protected $value        = null;
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
      * @param array  $constraints
189 189
      * @return AssertionFailedException
190 190
      */
191
-    protected function createException($message, $code, $propertyPath, array $constraints = [])
191
+    protected function createException($message, $code, $propertyPath, array $constraints = [ ])
192 192
     {
193 193
         $exceptionClass = $this->exceptionClass;
194 194
         $propertyPath = is_null($propertyPath) ? $this->propertyPath : $propertyPath;
@@ -226,18 +226,18 @@  discard block
 block discarded – undo
226 226
      */
227 227
     public function eq($value2, $message = null, $propertyPath = null)
228 228
     {
229
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
229
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
230 230
         {
231 231
             return $this;
232 232
         }
233
-        if ( $this->value != $value2 )
233
+        if ($this->value != $value2)
234 234
         {
235 235
             $message = sprintf(
236 236
                 $message ?: 'Value "%s" does not equal expected value "%s".',
237 237
                 $this->stringify($this->value),
238 238
                 $this->stringify($value2)
239 239
             );
240
-            throw $this->createException($message, self::INVALID_EQ, $propertyPath, ['expected' => $value2]);
240
+            throw $this->createException($message, self::INVALID_EQ, $propertyPath, [ 'expected' => $value2 ]);
241 241
         }
242 242
         return $this;
243 243
     }
@@ -252,18 +252,18 @@  discard block
 block discarded – undo
252 252
      */
253 253
     public function greaterThan($value2, $message = null, $propertyPath = null)
254 254
     {
255
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
255
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
256 256
         {
257 257
             return $this;
258 258
         }
259
-        if ( ! ( $this->value > $value2 ) )
259
+        if ( ! ($this->value > $value2))
260 260
         {
261 261
             $message = sprintf(
262 262
                 $message ?: 'Value "%s" does not greater then expected value "%s".',
263 263
                 $this->stringify($this->value),
264 264
                 $this->stringify($value2)
265 265
             );
266
-            throw $this->createException($message, self::INVALID_EQ, $propertyPath, ['expected' => $value2]);
266
+            throw $this->createException($message, self::INVALID_EQ, $propertyPath, [ 'expected' => $value2 ]);
267 267
         }
268 268
         return $this;
269 269
     }
@@ -278,18 +278,18 @@  discard block
 block discarded – undo
278 278
      */
279 279
     public function greaterThanOrEq($value2, $message = null, $propertyPath = null)
280 280
     {
281
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
281
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
282 282
         {
283 283
             return $this;
284 284
         }
285
-        if ( ! ( $this->value >= $value2 ) )
285
+        if ( ! ($this->value >= $value2))
286 286
         {
287 287
             $message = sprintf(
288 288
                 $message ?: 'Value "%s" does not greater than or equal to expected value "%s".',
289 289
                 $this->stringify($this->value),
290 290
                 $this->stringify($value2)
291 291
             );
292
-            throw $this->createException($message, self::INVALID_EQ, $propertyPath, ['expected' => $value2]);
292
+            throw $this->createException($message, self::INVALID_EQ, $propertyPath, [ 'expected' => $value2 ]);
293 293
         }
294 294
         return $this;
295 295
     }
@@ -304,18 +304,18 @@  discard block
 block discarded – undo
304 304
      */
305 305
     public function lessThan($value2, $message = null, $propertyPath = null)
306 306
     {
307
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
307
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
308 308
         {
309 309
             return $this;
310 310
         }
311
-        if ( ! ( $this->value < $value2 ) )
311
+        if ( ! ($this->value < $value2))
312 312
         {
313 313
             $message = sprintf(
314 314
                 $message ?: 'Value "%s" does not less then expected value "%s".',
315 315
                 $this->stringify($this->value),
316 316
                 $this->stringify($value2)
317 317
             );
318
-            throw $this->createException($message, self::INVALID_LESS_THAN, $propertyPath, ['expected' => $value2]);
318
+            throw $this->createException($message, self::INVALID_LESS_THAN, $propertyPath, [ 'expected' => $value2 ]);
319 319
         }
320 320
         return $this;
321 321
     }
@@ -330,18 +330,18 @@  discard block
 block discarded – undo
330 330
      */
331 331
     public function lessThanOrEq($value2, $message = null, $propertyPath = null)
332 332
     {
333
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
333
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
334 334
         {
335 335
             return $this;
336 336
         }
337
-        if ( ! ( $this->value <= $value2 ) )
337
+        if ( ! ($this->value <= $value2))
338 338
         {
339 339
             $message = sprintf(
340 340
                 $message ?: 'Value "%s" does not less than or equal to expected value "%s".',
341 341
                 $this->stringify($this->value),
342 342
                 $this->stringify($value2)
343 343
             );
344
-            throw $this->createException($message, self::INVALID_LESS_THAN_OR_EQ, $propertyPath, ['expected' => $value2]);
344
+            throw $this->createException($message, self::INVALID_LESS_THAN_OR_EQ, $propertyPath, [ 'expected' => $value2 ]);
345 345
         }
346 346
         return $this;
347 347
     }
@@ -357,18 +357,18 @@  discard block
 block discarded – undo
357 357
      */
358 358
     public function same($value2, $message = null, $propertyPath = null)
359 359
     {
360
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
360
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
361 361
         {
362 362
             return $this;
363 363
         }
364
-        if ( $this->value !== $value2 )
364
+        if ($this->value !== $value2)
365 365
         {
366 366
             $message = sprintf(
367 367
                 $message ?: 'Value "%s" is not the same as expected value "%s".',
368 368
                 $this->stringify($this->value),
369 369
                 $this->stringify($value2)
370 370
             );
371
-            throw $this->createException($message, self::INVALID_SAME, $propertyPath, ['expected' => $value2]);
371
+            throw $this->createException($message, self::INVALID_SAME, $propertyPath, [ 'expected' => $value2 ]);
372 372
         }
373 373
         return $this;
374 374
     }
@@ -384,18 +384,18 @@  discard block
 block discarded – undo
384 384
      */
385 385
     public function notEq($value2, $message = null, $propertyPath = null)
386 386
     {
387
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
387
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
388 388
         {
389 389
             return $this;
390 390
         }
391
-        if ( $this->value == $value2 )
391
+        if ($this->value == $value2)
392 392
         {
393 393
             $message = sprintf(
394 394
                 $message ?: 'Value "%s" is equal to expected value "%s".',
395 395
                 $this->stringify($this->value),
396 396
                 $this->stringify($value2)
397 397
             );
398
-            throw $this->createException($message, self::INVALID_NOT_EQ, $propertyPath, ['expected' => $value2]);
398
+            throw $this->createException($message, self::INVALID_NOT_EQ, $propertyPath, [ 'expected' => $value2 ]);
399 399
         }
400 400
         return $this;
401 401
     }
@@ -409,11 +409,11 @@  discard block
 block discarded – undo
409 409
      */
410 410
     public function isCallable($message = null, $propertyPath = null)
411 411
     {
412
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
412
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
413 413
         {
414 414
             return $this;
415 415
         }
416
-        if ( !is_callable($this->value) )
416
+        if ( ! is_callable($this->value))
417 417
         {
418 418
             $message = sprintf(
419 419
                 $message ?: 'Value "%s" is not callable.',
@@ -435,18 +435,18 @@  discard block
 block discarded – undo
435 435
      */
436 436
     public function notSame($value2, $message = null, $propertyPath = null)
437 437
     {
438
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
438
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
439 439
         {
440 440
             return $this;
441 441
         }
442
-        if ( $this->value === $value2 )
442
+        if ($this->value === $value2)
443 443
         {
444 444
             $message = sprintf(
445 445
                 $message ?: 'Value "%s" is the same as expected value "%s".',
446 446
                 $this->stringify($this->value),
447 447
                 $this->stringify($value2)
448 448
             );
449
-            throw $this->createException($message, self::INVALID_NOT_SAME, $propertyPath, ['expected' => $value2]);
449
+            throw $this->createException($message, self::INVALID_NOT_SAME, $propertyPath, [ 'expected' => $value2 ]);
450 450
         }
451 451
         return $this;
452 452
     }
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
     public function status($message = null, $propertyPath = null)
485 485
     {
486 486
         $message = $message ?: 'Value "%s" is not a valid status.';
487
-        return $this->integer($message, $propertyPath)->inArray([-1, 0, 1]);
487
+        return $this->integer($message, $propertyPath)->inArray([-1, 0, 1 ]);
488 488
     }
489 489
 
490 490
     /**
@@ -528,11 +528,11 @@  discard block
 block discarded – undo
528 528
      */
529 529
     public function integer($message = null, $propertyPath = null)
530 530
     {
531
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
531
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
532 532
         {
533 533
             return $this;
534 534
         }
535
-        if ( !is_int($this->value) )
535
+        if ( ! is_int($this->value))
536 536
         {
537 537
             $message = sprintf(
538 538
                 $message ?: 'Value "%s" is not an integer.',
@@ -553,11 +553,11 @@  discard block
 block discarded – undo
553 553
      */
554 554
     public function float($message = null, $propertyPath = null)
555 555
     {
556
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
556
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
557 557
         {
558 558
             return $this;
559 559
         }
560
-        if ( !is_float($this->value) )
560
+        if ( ! is_float($this->value))
561 561
         {
562 562
             $message = sprintf(
563 563
                 $message ?: 'Value "%s" is not a float.',
@@ -578,11 +578,11 @@  discard block
 block discarded – undo
578 578
      */
579 579
     public function digit($message = null, $propertyPath = null)
580 580
     {
581
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
581
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
582 582
         {
583 583
             return $this;
584 584
         }
585
-        if ( !ctype_digit((string)$this->value) )
585
+        if ( ! ctype_digit((string)$this->value))
586 586
         {
587 587
             $message = sprintf(
588 588
                 $message ?: 'Value "%s" is not a digit.',
@@ -603,12 +603,12 @@  discard block
 block discarded – undo
603 603
      */
604 604
     public function date($message = null, $propertyPath = null)
605 605
     {
606
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
606
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
607 607
         {
608 608
             return $this;
609 609
         }
610 610
         $this->notEmpty($message, $propertyPath);
611
-        if ( strtotime($this->value) === false )
611
+        if (strtotime($this->value) === false)
612 612
         {
613 613
             $message = sprintf(
614 614
                 $message ?: 'Value "%s" is not a date.',
@@ -629,11 +629,11 @@  discard block
 block discarded – undo
629 629
      */
630 630
     public function integerish($message = null, $propertyPath = null)
631 631
     {
632
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
632
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
633 633
         {
634 634
             return $this;
635 635
         }
636
-        if ( is_object($this->value) || strval(intval($this->value)) != $this->value || is_bool($this->value) || is_null($this->value) )
636
+        if (is_object($this->value) || strval(intval($this->value)) != $this->value || is_bool($this->value) || is_null($this->value))
637 637
         {
638 638
             $message = sprintf(
639 639
                 $message ?: 'Value "%s" is not an integer or a number castable to integer.',
@@ -654,11 +654,11 @@  discard block
 block discarded – undo
654 654
      */
655 655
     public function boolean($message = null, $propertyPath = null)
656 656
     {
657
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
657
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
658 658
         {
659 659
             return $this;
660 660
         }
661
-        if ( !is_bool($this->value) )
661
+        if ( ! is_bool($this->value))
662 662
         {
663 663
             $message = sprintf(
664 664
                 $message ?: 'Value "%s" is not a boolean.',
@@ -679,11 +679,11 @@  discard block
 block discarded – undo
679 679
      */
680 680
     public function scalar($message = null, $propertyPath = null)
681 681
     {
682
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
682
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
683 683
         {
684 684
             return $this;
685 685
         }
686
-        if ( !is_scalar($this->value) )
686
+        if ( ! is_scalar($this->value))
687 687
         {
688 688
             $message = sprintf(
689 689
                 $message ?: 'Value "%s" is not a scalar.',
@@ -704,11 +704,11 @@  discard block
 block discarded – undo
704 704
      */
705 705
     public function notEmpty($message = null, $propertyPath = null)
706 706
     {
707
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
707
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
708 708
         {
709 709
             return $this;
710 710
         }
711
-        if ( ( is_object($this->value) && empty((array)$this->value) ) || empty($this->value) )
711
+        if ((is_object($this->value) && empty((array)$this->value)) || empty($this->value))
712 712
         {
713 713
             $message = sprintf(
714 714
                 $message ?: 'Value "%s" is empty, but non empty value was expected.',
@@ -729,11 +729,11 @@  discard block
 block discarded – undo
729 729
      */
730 730
     public function noContent($message = null, $propertyPath = null)
731 731
     {
732
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
732
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
733 733
         {
734 734
             return $this;
735 735
         }
736
-        if ( !empty( $this->value ) )
736
+        if ( ! empty($this->value))
737 737
         {
738 738
             $message = sprintf(
739 739
                 $message ?: 'Value "%s" is not empty, but empty value was expected.',
@@ -754,11 +754,11 @@  discard block
 block discarded – undo
754 754
      */
755 755
     public function notNull($message = null, $propertyPath = null)
756 756
     {
757
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
757
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
758 758
         {
759 759
             return $this;
760 760
         }
761
-        if ( $this->value === null )
761
+        if ($this->value === null)
762 762
         {
763 763
             $message = sprintf(
764 764
                 $message ?: 'Value "%s" is null, but non null value was expected.',
@@ -779,11 +779,11 @@  discard block
 block discarded – undo
779 779
      */
780 780
     public function string($message = null, $propertyPath = null)
781 781
     {
782
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
782
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
783 783
         {
784 784
             return $this;
785 785
         }
786
-        if ( !is_string($this->value) )
786
+        if ( ! is_string($this->value))
787 787
         {
788 788
             $message = sprintf(
789 789
                 $message ?: 'Value "%s" expected to be string, type %s given.',
@@ -806,18 +806,18 @@  discard block
 block discarded – undo
806 806
      */
807 807
     public function regex($pattern, $message = null, $propertyPath = null)
808 808
     {
809
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
809
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
810 810
         {
811 811
             return $this;
812 812
         }
813 813
         $this->string($message, $propertyPath);
814
-        if ( !preg_match($pattern, $this->value) )
814
+        if ( ! preg_match($pattern, $this->value))
815 815
         {
816 816
             $message = sprintf(
817 817
                 $message ?: 'Value "%s" does not match expression.',
818 818
                 $this->stringify($this->value)
819 819
             );
820
-            throw $this->createException($message, self::INVALID_REGEX, $propertyPath, ['pattern' => $pattern]);
820
+            throw $this->createException($message, self::INVALID_REGEX, $propertyPath, [ 'pattern' => $pattern ]);
821 821
         }
822 822
         return $this;
823 823
     }
@@ -831,18 +831,18 @@  discard block
 block discarded – undo
831 831
      */
832 832
     public function notRegex($pattern, $message = null, $propertyPath = null)
833 833
     {
834
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
834
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
835 835
         {
836 836
             return $this;
837 837
         }
838 838
         $this->string($message, $propertyPath);
839
-        if ( preg_match($pattern, $this->value) )
839
+        if (preg_match($pattern, $this->value))
840 840
         {
841 841
             $message = sprintf(
842 842
                 $message ?: 'Value "%s" does not match expression.',
843 843
                 $this->stringify($this->value)
844 844
             );
845
-            throw $this->createException($message, self::INVALID_REGEX, $propertyPath, ['pattern' => $pattern]);
845
+            throw $this->createException($message, self::INVALID_REGEX, $propertyPath, [ 'pattern' => $pattern ]);
846 846
         }
847 847
         return $this;
848 848
     }
@@ -859,20 +859,20 @@  discard block
 block discarded – undo
859 859
      */
860 860
     public function length($length, $message = null, $propertyPath = null, $encoding = 'utf8')
861 861
     {
862
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
862
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
863 863
         {
864 864
             return $this;
865 865
         }
866 866
         $this->string($message, $propertyPath);
867
-        if ( mb_strlen($this->value, $encoding) !== $length )
867
+        if (mb_strlen($this->value, $encoding) !== $length)
868 868
         {
869
-            $message     = sprintf(
869
+            $message = sprintf(
870 870
                 $message ?: 'Value "%s" has to be %d exactly characters long, but length is %d.',
871 871
                 $this->stringify($this->value),
872 872
                 $length,
873 873
                 mb_strlen($this->value, $encoding)
874 874
             );
875
-            $constraints = ['length' => $length, 'encoding' => $encoding];
875
+            $constraints = [ 'length' => $length, 'encoding' => $encoding ];
876 876
             throw $this->createException($message, self::INVALID_LENGTH, $propertyPath, $constraints);
877 877
         }
878 878
         return $this;
@@ -890,21 +890,21 @@  discard block
 block discarded – undo
890 890
      */
891 891
     public function minLength($minLength, $message = null, $propertyPath = null, $encoding = 'utf8')
892 892
     {
893
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
893
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
894 894
         {
895 895
             return $this;
896 896
         }
897 897
         $this->string($message, $propertyPath);
898
-        if ( mb_strlen($this->value, $encoding) < $minLength )
898
+        if (mb_strlen($this->value, $encoding) < $minLength)
899 899
         {
900
-            $message     = sprintf(
900
+            $message = sprintf(
901 901
                 $message
902 902
                     ?: 'Value "%s" is too short, it should have more than %d characters, but only has %d characters.',
903 903
                 $this->stringify($this->value),
904 904
                 $minLength,
905 905
                 mb_strlen($this->value, $encoding)
906 906
             );
907
-            $constraints = ['min_length' => $minLength, 'encoding' => $encoding];
907
+            $constraints = [ 'min_length' => $minLength, 'encoding' => $encoding ];
908 908
             throw $this->createException($message, self::INVALID_MIN_LENGTH, $propertyPath, $constraints);
909 909
         }
910 910
         return $this;
@@ -922,20 +922,20 @@  discard block
 block discarded – undo
922 922
      */
923 923
     public function maxLength($maxLength, $message = null, $propertyPath = null, $encoding = 'utf8')
924 924
     {
925
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
925
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
926 926
         {
927 927
             return $this;
928 928
         }
929 929
         $this->string($message, $propertyPath);
930
-        if ( mb_strlen($this->value, $encoding) > $maxLength )
930
+        if (mb_strlen($this->value, $encoding) > $maxLength)
931 931
         {
932
-            $message     = sprintf(
932
+            $message = sprintf(
933 933
                 $message ?: 'Value "%s" is too long, it should have no more than %d characters, but has %d characters.',
934 934
                 $this->stringify($this->value),
935 935
                 $maxLength,
936 936
                 mb_strlen($this->value, $encoding)
937 937
             );
938
-            $constraints = ['max_length' => $maxLength, 'encoding' => $encoding];
938
+            $constraints = [ 'max_length' => $maxLength, 'encoding' => $encoding ];
939 939
             throw $this->createException($message, self::INVALID_MAX_LENGTH, $propertyPath, $constraints);
940 940
         }
941 941
         return $this;
@@ -954,32 +954,32 @@  discard block
 block discarded – undo
954 954
      */
955 955
     public function betweenLength($minLength, $maxLength, $message = null, $propertyPath = null, $encoding = 'utf8')
956 956
     {
957
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
957
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
958 958
         {
959 959
             return $this;
960 960
         }
961 961
         $this->string($message, $propertyPath);
962
-        if ( mb_strlen($this->value, $encoding) < $minLength )
962
+        if (mb_strlen($this->value, $encoding) < $minLength)
963 963
         {
964
-            $message     = sprintf(
964
+            $message = sprintf(
965 965
                 $message
966 966
                     ?: 'Value "%s" is too short, it should have more than %d characters, but only has %d characters.',
967 967
                 $this->stringify($this->value),
968 968
                 $minLength,
969 969
                 mb_strlen($this->value, $encoding)
970 970
             );
971
-            $constraints = ['min_length' => $minLength, 'encoding' => $encoding];
971
+            $constraints = [ 'min_length' => $minLength, 'encoding' => $encoding ];
972 972
             throw $this->createException($message, self::INVALID_MIN_LENGTH, $propertyPath, $constraints);
973 973
         }
974
-        if ( mb_strlen($this->value, $encoding) > $maxLength )
974
+        if (mb_strlen($this->value, $encoding) > $maxLength)
975 975
         {
976
-            $message     = sprintf(
976
+            $message = sprintf(
977 977
                 $message ?: 'Value "%s" is too long, it should have no more than %d characters, but has %d characters.',
978 978
                 $this->stringify($this->value),
979 979
                 $maxLength,
980 980
                 mb_strlen($this->value, $encoding)
981 981
             );
982
-            $constraints = ['max_length' => $maxLength, 'encoding' => $encoding];
982
+            $constraints = [ 'max_length' => $maxLength, 'encoding' => $encoding ];
983 983
             throw $this->createException($message, self::INVALID_MAX_LENGTH, $propertyPath, $constraints);
984 984
         }
985 985
         return $this;
@@ -997,19 +997,19 @@  discard block
 block discarded – undo
997 997
      */
998 998
     public function startsWith($needle, $message = null, $propertyPath = null, $encoding = 'utf8')
999 999
     {
1000
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1000
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1001 1001
         {
1002 1002
             return $this;
1003 1003
         }
1004 1004
         $this->string($message, $propertyPath);
1005
-        if ( mb_strpos($this->value, $needle, null, $encoding) !== 0 )
1005
+        if (mb_strpos($this->value, $needle, null, $encoding) !== 0)
1006 1006
         {
1007
-            $message     = sprintf(
1007
+            $message = sprintf(
1008 1008
                 $message ?: 'Value "%s" does not start with "%s".',
1009 1009
                 $this->stringify($this->value),
1010 1010
                 $this->stringify($needle)
1011 1011
             );
1012
-            $constraints = ['needle' => $needle, 'encoding' => $encoding];
1012
+            $constraints = [ 'needle' => $needle, 'encoding' => $encoding ];
1013 1013
             throw $this->createException($message, self::INVALID_STRING_START, $propertyPath, $constraints);
1014 1014
         }
1015 1015
         return $this;
@@ -1027,20 +1027,20 @@  discard block
 block discarded – undo
1027 1027
      */
1028 1028
     public function endsWith($needle, $message = null, $propertyPath = null, $encoding = 'utf8')
1029 1029
     {
1030
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1030
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1031 1031
         {
1032 1032
             return $this;
1033 1033
         }
1034 1034
         $this->string($message, $propertyPath);
1035 1035
         $stringPosition = mb_strlen($this->value, $encoding) - mb_strlen($needle, $encoding);
1036
-        if ( mb_strripos($this->value, $needle, null, $encoding) !== $stringPosition )
1036
+        if (mb_strripos($this->value, $needle, null, $encoding) !== $stringPosition)
1037 1037
         {
1038
-            $message     = sprintf(
1038
+            $message = sprintf(
1039 1039
                 $message ?: 'Value "%s" does not end with "%s".',
1040 1040
                 $this->stringify($this->value),
1041 1041
                 $this->stringify($needle)
1042 1042
             );
1043
-            $constraints = ['needle' => $needle, 'encoding' => $encoding];
1043
+            $constraints = [ 'needle' => $needle, 'encoding' => $encoding ];
1044 1044
             throw $this->createException($message, self::INVALID_STRING_END, $propertyPath, $constraints);
1045 1045
         }
1046 1046
         return $this;
@@ -1058,19 +1058,19 @@  discard block
 block discarded – undo
1058 1058
      */
1059 1059
     public function contains($needle, $message = null, $propertyPath = null, $encoding = 'utf8')
1060 1060
     {
1061
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1061
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1062 1062
         {
1063 1063
             return $this;
1064 1064
         }
1065 1065
         $this->string($message, $propertyPath);
1066
-        if ( mb_strpos($this->value, $needle, null, $encoding) === false )
1066
+        if (mb_strpos($this->value, $needle, null, $encoding) === false)
1067 1067
         {
1068
-            $message     = sprintf(
1068
+            $message = sprintf(
1069 1069
                 $message ?: 'Value "%s" does not contain "%s".',
1070 1070
                 $this->stringify($this->value),
1071 1071
                 $this->stringify($needle)
1072 1072
             );
1073
-            $constraints = ['needle' => $needle, 'encoding' => $encoding];
1073
+            $constraints = [ 'needle' => $needle, 'encoding' => $encoding ];
1074 1074
             throw $this->createException($message, self::INVALID_STRING_CONTAINS, $propertyPath, $constraints);
1075 1075
         }
1076 1076
         return $this;
@@ -1087,18 +1087,18 @@  discard block
 block discarded – undo
1087 1087
      */
1088 1088
     public function choice(array $choices, $message = null, $propertyPath = null)
1089 1089
     {
1090
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1090
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1091 1091
         {
1092 1092
             return $this;
1093 1093
         }
1094
-        if ( !in_array($this->value, $choices, true) )
1094
+        if ( ! in_array($this->value, $choices, true))
1095 1095
         {
1096 1096
             $message = sprintf(
1097 1097
                 $message ?: 'Value "%s" is not an element of the valid values: %s',
1098 1098
                 $this->stringify($this->value),
1099 1099
                 implode(", ", array_map('Terah\Assert\Assert::stringify', $choices))
1100 1100
             );
1101
-            throw $this->createException($message, self::INVALID_CHOICE, $propertyPath, ['choices' => $choices]);
1101
+            throw $this->createException($message, self::INVALID_CHOICE, $propertyPath, [ 'choices' => $choices ]);
1102 1102
         }
1103 1103
         return $this;
1104 1104
     }
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
      */
1116 1116
     public function inArray(array $choices, $message = null, $propertyPath = null)
1117 1117
     {
1118
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1118
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1119 1119
         {
1120 1120
             return $this;
1121 1121
         }
@@ -1133,11 +1133,11 @@  discard block
 block discarded – undo
1133 1133
      */
1134 1134
     public function numeric($message = null, $propertyPath = null)
1135 1135
     {
1136
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1136
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1137 1137
         {
1138 1138
             return $this;
1139 1139
         }
1140
-        if ( ! is_numeric($this->value) )
1140
+        if ( ! is_numeric($this->value))
1141 1141
         {
1142 1142
             $message = sprintf(
1143 1143
                 $message ?: 'Value "%s" is not numeric.',
@@ -1194,11 +1194,11 @@  discard block
 block discarded – undo
1194 1194
      */
1195 1195
     public function isArray($message = null, $propertyPath = null)
1196 1196
     {
1197
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1197
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1198 1198
         {
1199 1199
             return $this;
1200 1200
         }
1201
-        if ( !is_array($this->value) )
1201
+        if ( ! is_array($this->value))
1202 1202
         {
1203 1203
             $message = sprintf(
1204 1204
                 $message ?: 'Value "%s" is not an array.',
@@ -1219,11 +1219,11 @@  discard block
 block discarded – undo
1219 1219
      */
1220 1220
     public function isTraversable($message = null, $propertyPath = null)
1221 1221
     {
1222
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1222
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1223 1223
         {
1224 1224
             return $this;
1225 1225
         }
1226
-        if ( !is_array($this->value) && !$this->value instanceof \Traversable )
1226
+        if ( ! is_array($this->value) && ! $this->value instanceof \Traversable)
1227 1227
         {
1228 1228
             $message = sprintf(
1229 1229
                 $message ?: 'Value "%s" is not an array and does not implement Traversable.',
@@ -1244,11 +1244,11 @@  discard block
 block discarded – undo
1244 1244
      */
1245 1245
     public function isArrayAccessible($message = null, $propertyPath = null)
1246 1246
     {
1247
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1247
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1248 1248
         {
1249 1249
             return $this;
1250 1250
         }
1251
-        if ( !is_array($this->value) && !$this->value instanceof \ArrayAccess )
1251
+        if ( ! is_array($this->value) && ! $this->value instanceof \ArrayAccess)
1252 1252
         {
1253 1253
             $message = sprintf(
1254 1254
                 $message ?: 'Value "%s" is not an array and does not implement ArrayAccess.',
@@ -1270,18 +1270,18 @@  discard block
 block discarded – undo
1270 1270
      */
1271 1271
     public function keyExists($key, $message = null, $propertyPath = null)
1272 1272
     {
1273
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1273
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1274 1274
         {
1275 1275
             return $this;
1276 1276
         }
1277 1277
         $this->isArray($message, $propertyPath);
1278
-        if ( !array_key_exists($key, $this->value) )
1278
+        if ( ! array_key_exists($key, $this->value))
1279 1279
         {
1280 1280
             $message = sprintf(
1281 1281
                 $message ?: 'Array does not contain an element with key "%s"',
1282 1282
                 $this->stringify($key)
1283 1283
             );
1284
-            throw $this->createException($message, self::INVALID_KEY_EXISTS, $propertyPath, ['key' => $key]);
1284
+            throw $this->createException($message, self::INVALID_KEY_EXISTS, $propertyPath, [ 'key' => $key ]);
1285 1285
         }
1286 1286
         return $this;
1287 1287
     }
@@ -1297,21 +1297,21 @@  discard block
 block discarded – undo
1297 1297
      */
1298 1298
     public function keysExist($keys, $message = null, $propertyPath = null)
1299 1299
     {
1300
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1300
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1301 1301
         {
1302 1302
             return $this;
1303 1303
         }
1304 1304
         $this->isArray($message, $propertyPath);
1305
-        foreach ( $keys as $key )
1305
+        foreach ($keys as $key)
1306 1306
         {
1307
-            if ( !array_key_exists($key, $this->value) )
1307
+            if ( ! array_key_exists($key, $this->value))
1308 1308
             {
1309 1309
                 $message = $message
1310 1310
                     ?: sprintf(
1311 1311
                         'Array does not contain an element with key "%s"',
1312 1312
                         $this->stringify($key)
1313 1313
                     );
1314
-                throw $this->createException($message, self::INVALID_KEYS_EXIST, $propertyPath, ['key' => $key]);
1314
+                throw $this->createException($message, self::INVALID_KEYS_EXIST, $propertyPath, [ 'key' => $key ]);
1315 1315
             }
1316 1316
         }
1317 1317
         return $this;
@@ -1328,19 +1328,19 @@  discard block
 block discarded – undo
1328 1328
      */
1329 1329
     public function propertyExists($key, $message = null, $propertyPath = null)
1330 1330
     {
1331
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1331
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1332 1332
         {
1333 1333
             return $this;
1334 1334
         }
1335 1335
         $this->isObject($message, $propertyPath);
1336
-        if ( !property_exists($this->value, $key) && !isset( $this->value->{$key} ) )
1336
+        if ( ! property_exists($this->value, $key) && ! isset($this->value->{$key} ))
1337 1337
         {
1338 1338
             $message = $message
1339 1339
                 ?: sprintf(
1340 1340
                     'Object does not contain a property with key "%s"',
1341 1341
                     $this->stringify($key)
1342 1342
                 );
1343
-            throw $this->createException($message, self::INVALID_PROPERTY_EXISTS, $propertyPath, ['key' => $key]);
1343
+            throw $this->createException($message, self::INVALID_PROPERTY_EXISTS, $propertyPath, [ 'key' => $key ]);
1344 1344
         }
1345 1345
         return $this;
1346 1346
     }
@@ -1356,22 +1356,22 @@  discard block
 block discarded – undo
1356 1356
      */
1357 1357
     public function propertiesExist(array $keys, $message = null, $propertyPath = null)
1358 1358
     {
1359
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1359
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1360 1360
         {
1361 1361
             return $this;
1362 1362
         }
1363 1363
         $this->isObject($message, $propertyPath);
1364
-        foreach ( $keys as $key )
1364
+        foreach ($keys as $key)
1365 1365
         {
1366 1366
             // Using isset to allow resolution of magically defined properties
1367
-            if ( !property_exists($this->value, $key) && !isset( $this->value->{$key} ) )
1367
+            if ( ! property_exists($this->value, $key) && ! isset($this->value->{$key} ))
1368 1368
             {
1369 1369
                 $message = $message
1370 1370
                     ?: sprintf(
1371 1371
                         'Object does not contain a property with key "%s"',
1372 1372
                         $this->stringify($key)
1373 1373
                     );
1374
-                throw $this->createException($message, self::INVALID_PROPERTIES_EXIST, $propertyPath, ['key' => $key]);
1374
+                throw $this->createException($message, self::INVALID_PROPERTIES_EXIST, $propertyPath, [ 'key' => $key ]);
1375 1375
             }
1376 1376
         }
1377 1377
         return $this;
@@ -1387,12 +1387,12 @@  discard block
 block discarded – undo
1387 1387
      */
1388 1388
     public function utf8($message = null, $propertyPath = null)
1389 1389
     {
1390
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1390
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1391 1391
         {
1392 1392
             return $this;
1393 1393
         }
1394 1394
         $this->string($message, $propertyPath);
1395
-        if ( mb_detect_encoding($this->value, 'UTF-8', true) !== 'UTF-8' )
1395
+        if (mb_detect_encoding($this->value, 'UTF-8', true) !== 'UTF-8')
1396 1396
         {
1397 1397
             $message = $message
1398 1398
                 ?: sprintf(
@@ -1415,12 +1415,12 @@  discard block
 block discarded – undo
1415 1415
      */
1416 1416
     public function ascii($message = null, $propertyPath = null)
1417 1417
     {
1418
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1418
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1419 1419
         {
1420 1420
             return $this;
1421 1421
         }
1422 1422
         $this->string($message, $propertyPath);
1423
-        if ( ! preg_match('/^[ -~]+$/', $this->value) )
1423
+        if ( ! preg_match('/^[ -~]+$/', $this->value))
1424 1424
         {
1425 1425
             $message = $message
1426 1426
                 ?: sprintf(
@@ -1443,18 +1443,18 @@  discard block
 block discarded – undo
1443 1443
      */
1444 1444
     public function keyIsset($key, $message = null, $propertyPath = null)
1445 1445
     {
1446
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1446
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1447 1447
         {
1448 1448
             return $this;
1449 1449
         }
1450 1450
         $this->isArrayAccessible($message, $propertyPath);
1451
-        if ( !isset( $this->value[$key] ) )
1451
+        if ( ! isset($this->value[ $key ]))
1452 1452
         {
1453 1453
             $message = sprintf(
1454 1454
                 $message ?: 'The element with key "%s" was not found',
1455 1455
                 $this->stringify($key)
1456 1456
             );
1457
-            throw $this->createException($message, self::INVALID_KEY_ISSET, $propertyPath, ['key' => $key]);
1457
+            throw $this->createException($message, self::INVALID_KEY_ISSET, $propertyPath, [ 'key' => $key ]);
1458 1458
         }
1459 1459
         return $this;
1460 1460
     }
@@ -1470,12 +1470,12 @@  discard block
 block discarded – undo
1470 1470
      */
1471 1471
     public function notEmptyKey($key, $message = null, $propertyPath = null)
1472 1472
     {
1473
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1473
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1474 1474
         {
1475 1475
             return $this;
1476 1476
         }
1477 1477
         $this->keyIsset($key, $message, $propertyPath);
1478
-        (new Assert($this->value[$key]))->setExceptionClass($this->exceptionClass)->notEmpty($message, $propertyPath);
1478
+        (new Assert($this->value[ $key ]))->setExceptionClass($this->exceptionClass)->notEmpty($message, $propertyPath);
1479 1479
         return $this;
1480 1480
     }
1481 1481
 
@@ -1489,11 +1489,11 @@  discard block
 block discarded – undo
1489 1489
      */
1490 1490
     public function notBlank($message = null, $propertyPath = null)
1491 1491
     {
1492
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1492
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1493 1493
         {
1494 1494
             return $this;
1495 1495
         }
1496
-        if ( false === $this->value || ( empty( $this->value ) && '0' != $this->value ) )
1496
+        if (false === $this->value || (empty($this->value) && '0' != $this->value))
1497 1497
         {
1498 1498
             $message = sprintf(
1499 1499
                 $message ?: 'Value "%s" is blank, but was expected to contain a value.',
@@ -1515,18 +1515,18 @@  discard block
 block discarded – undo
1515 1515
      */
1516 1516
     public function isInstanceOf($className, $message = null, $propertyPath = null)
1517 1517
     {
1518
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1518
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1519 1519
         {
1520 1520
             return $this;
1521 1521
         }
1522
-        if ( !( $this->value instanceof $className ) )
1522
+        if ( ! ($this->value instanceof $className))
1523 1523
         {
1524 1524
             $message = sprintf(
1525 1525
                 $message ?: 'Class "%s" was expected to be instanceof of "%s" but is not.',
1526 1526
                 $this->stringify($this->value),
1527 1527
                 $className
1528 1528
             );
1529
-            throw $this->createException($message, self::INVALID_INSTANCE_OF, $propertyPath, ['class' => $className]);
1529
+            throw $this->createException($message, self::INVALID_INSTANCE_OF, $propertyPath, [ 'class' => $className ]);
1530 1530
         }
1531 1531
         return $this;
1532 1532
     }
@@ -1542,18 +1542,18 @@  discard block
 block discarded – undo
1542 1542
      */
1543 1543
     public function notIsInstanceOf($className, $message = null, $propertyPath = null)
1544 1544
     {
1545
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1545
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1546 1546
         {
1547 1547
             return $this;
1548 1548
         }
1549
-        if ( $this->value instanceof $className )
1549
+        if ($this->value instanceof $className)
1550 1550
         {
1551 1551
             $message = sprintf(
1552 1552
                 $message ?: 'Class "%s" was not expected to be instanceof of "%s".',
1553 1553
                 $this->stringify($this->value),
1554 1554
                 $className
1555 1555
             );
1556
-            throw $this->createException($message, self::INVALID_NOT_INSTANCE_OF, $propertyPath, ['class' => $className]);
1556
+            throw $this->createException($message, self::INVALID_NOT_INSTANCE_OF, $propertyPath, [ 'class' => $className ]);
1557 1557
         }
1558 1558
         return $this;
1559 1559
     }
@@ -1569,18 +1569,18 @@  discard block
 block discarded – undo
1569 1569
      */
1570 1570
     public function subclassOf($className, $message = null, $propertyPath = null)
1571 1571
     {
1572
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1572
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1573 1573
         {
1574 1574
             return $this;
1575 1575
         }
1576
-        if ( !is_subclass_of($this->value, $className) )
1576
+        if ( ! is_subclass_of($this->value, $className))
1577 1577
         {
1578 1578
             $message = sprintf(
1579 1579
                 $message ?: 'Class "%s" was expected to be subclass of "%s".',
1580 1580
                 $this->stringify($this->value),
1581 1581
                 $className
1582 1582
             );
1583
-            throw $this->createException($message, self::INVALID_SUBCLASS_OF, $propertyPath, ['class' => $className]);
1583
+            throw $this->createException($message, self::INVALID_SUBCLASS_OF, $propertyPath, [ 'class' => $className ]);
1584 1584
         }
1585 1585
         return $this;
1586 1586
     }
@@ -1597,12 +1597,12 @@  discard block
 block discarded – undo
1597 1597
      */
1598 1598
     public function range($minValue, $maxValue, $message = null, $propertyPath = null)
1599 1599
     {
1600
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1600
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1601 1601
         {
1602 1602
             return $this;
1603 1603
         }
1604 1604
         $this->numeric($message, $propertyPath);
1605
-        if ( $this->value < $minValue || $this->value > $maxValue )
1605
+        if ($this->value < $minValue || $this->value > $maxValue)
1606 1606
         {
1607 1607
             $message = sprintf(
1608 1608
                 $message ?: 'Number "%s" was expected to be at least "%d" and at most "%d".',
@@ -1629,19 +1629,19 @@  discard block
 block discarded – undo
1629 1629
      */
1630 1630
     public function min($minValue, $message = null, $propertyPath = null)
1631 1631
     {
1632
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1632
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1633 1633
         {
1634 1634
             return $this;
1635 1635
         }
1636 1636
         $this->numeric($message, $propertyPath);
1637
-        if ( $this->value < $minValue )
1637
+        if ($this->value < $minValue)
1638 1638
         {
1639 1639
             $message = sprintf(
1640 1640
                 $message ?: 'Number "%s" was expected to be at least "%d".',
1641 1641
                 $this->stringify($this->value),
1642 1642
                 $this->stringify($minValue)
1643 1643
             );
1644
-            throw $this->createException($message, self::INVALID_MIN, $propertyPath, ['min' => $minValue]);
1644
+            throw $this->createException($message, self::INVALID_MIN, $propertyPath, [ 'min' => $minValue ]);
1645 1645
         }
1646 1646
         return $this;
1647 1647
     }
@@ -1657,19 +1657,19 @@  discard block
 block discarded – undo
1657 1657
      */
1658 1658
     public function max($maxValue, $message = null, $propertyPath = null)
1659 1659
     {
1660
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1660
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1661 1661
         {
1662 1662
             return $this;
1663 1663
         }
1664 1664
         $this->numeric($message, $propertyPath);
1665
-        if ( $this->value > $maxValue )
1665
+        if ($this->value > $maxValue)
1666 1666
         {
1667 1667
             $message = sprintf(
1668 1668
                 $message ?: 'Number "%s" was expected to be at most "%d".',
1669 1669
                 $this->stringify($this->value),
1670 1670
                 $this->stringify($maxValue)
1671 1671
             );
1672
-            throw $this->createException($message, self::INVALID_MAX, $propertyPath, ['max' => $maxValue]);
1672
+            throw $this->createException($message, self::INVALID_MAX, $propertyPath, [ 'max' => $maxValue ]);
1673 1673
         }
1674 1674
         return $this;
1675 1675
     }
@@ -1684,13 +1684,13 @@  discard block
 block discarded – undo
1684 1684
      */
1685 1685
     public function file($message = null, $propertyPath = null)
1686 1686
     {
1687
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1687
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1688 1688
         {
1689 1689
             return $this;
1690 1690
         }
1691 1691
         $this->string($message, $propertyPath);
1692 1692
         $this->notEmpty($message, $propertyPath);
1693
-        if ( !is_file($this->value) )
1693
+        if ( ! is_file($this->value))
1694 1694
         {
1695 1695
             $message = sprintf(
1696 1696
                 $message ?: 'File "%s" was expected to exist.',
@@ -1709,13 +1709,13 @@  discard block
 block discarded – undo
1709 1709
      */
1710 1710
     public function fileExists($message = null, $propertyPath = null)
1711 1711
     {
1712
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1712
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1713 1713
         {
1714 1714
             return $this;
1715 1715
         }
1716 1716
         $this->string($message, $propertyPath);
1717 1717
         $this->notEmpty($message, $propertyPath);
1718
-        if ( ! file_exists($this->value) )
1718
+        if ( ! file_exists($this->value))
1719 1719
         {
1720 1720
             $message = sprintf(
1721 1721
                 $message ?: 'File or directory "%s" was expected to exist.',
@@ -1736,12 +1736,12 @@  discard block
 block discarded – undo
1736 1736
      */
1737 1737
     public function directory($message = null, $propertyPath = null)
1738 1738
     {
1739
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1739
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1740 1740
         {
1741 1741
             return $this;
1742 1742
         }
1743 1743
         $this->string($message, $propertyPath);
1744
-        if ( !is_dir($this->value) )
1744
+        if ( ! is_dir($this->value))
1745 1745
         {
1746 1746
             $message = sprintf(
1747 1747
                 $message ?: 'Path "%s" was expected to be a directory.',
@@ -1762,12 +1762,12 @@  discard block
 block discarded – undo
1762 1762
      */
1763 1763
     public function readable($message = null, $propertyPath = null)
1764 1764
     {
1765
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1765
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1766 1766
         {
1767 1767
             return $this;
1768 1768
         }
1769 1769
         $this->string($message, $propertyPath);
1770
-        if ( !is_readable($this->value) )
1770
+        if ( ! is_readable($this->value))
1771 1771
         {
1772 1772
             $message = sprintf(
1773 1773
                 $message ?: 'Path "%s" was expected to be readable.',
@@ -1788,12 +1788,12 @@  discard block
 block discarded – undo
1788 1788
      */
1789 1789
     public function writeable($message = null, $propertyPath = null)
1790 1790
     {
1791
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1791
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1792 1792
         {
1793 1793
             return $this;
1794 1794
         }
1795 1795
         $this->string($message, $propertyPath);
1796
-        if ( !is_writeable($this->value) )
1796
+        if ( ! is_writeable($this->value))
1797 1797
         {
1798 1798
             $message = sprintf(
1799 1799
                 $message ?: 'Path "%s" was expected to be writeable.',
@@ -1815,12 +1815,12 @@  discard block
 block discarded – undo
1815 1815
      */
1816 1816
     public function email($message = null, $propertyPath = null)
1817 1817
     {
1818
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1818
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1819 1819
         {
1820 1820
             return $this;
1821 1821
         }
1822 1822
         $this->string($message, $propertyPath);
1823
-        if ( ! filter_var($this->value, FILTER_VALIDATE_EMAIL) )
1823
+        if ( ! filter_var($this->value, FILTER_VALIDATE_EMAIL))
1824 1824
         {
1825 1825
             $message = sprintf(
1826 1826
                 $message ?: 'Value "%s" was expected to be a valid e-mail address.',
@@ -1832,7 +1832,7 @@  discard block
 block discarded – undo
1832 1832
         {
1833 1833
             $host = substr($this->value, strpos($this->value, '@') + 1);
1834 1834
             // Likely not a FQDN, bug in PHP FILTER_VALIDATE_EMAIL prior to PHP 5.3.3
1835
-            if ( version_compare(PHP_VERSION, '5.3.3', '<') && strpos($host, '.') === false )
1835
+            if (version_compare(PHP_VERSION, '5.3.3', '<') && strpos($host, '.') === false)
1836 1836
             {
1837 1837
                 $message = sprintf(
1838 1838
                     $message ?: 'Value "%s" was expected to be a valid e-mail address.',
@@ -1852,7 +1852,7 @@  discard block
 block discarded – undo
1852 1852
      */
1853 1853
     public function emailPrefix($message = null, $propertyPath = null)
1854 1854
     {
1855
-        $this->value($this->value . '@example.com');
1855
+        $this->value($this->value.'@example.com');
1856 1856
         return $this->email($message, $propertyPath);
1857 1857
     }
1858 1858
 
@@ -1872,12 +1872,12 @@  discard block
 block discarded – undo
1872 1872
      */
1873 1873
     public function url($message = null, $propertyPath = null)
1874 1874
     {
1875
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1875
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1876 1876
         {
1877 1877
             return $this;
1878 1878
         }
1879 1879
         $this->string($message, $propertyPath);
1880
-        $protocols = ['http', 'https'];
1880
+        $protocols = [ 'http', 'https' ];
1881 1881
         $pattern   = '~^
1882 1882
             (%s)://                                 # protocol
1883 1883
             (
@@ -1892,8 +1892,8 @@  discard block
 block discarded – undo
1892 1892
             (:[0-9]+)?                              # a port (optional)
1893 1893
             (/?|/\S+)                               # a /, nothing or a / with something
1894 1894
         $~ixu';
1895
-        $pattern   = sprintf($pattern, implode('|', $protocols));
1896
-        if ( !preg_match($pattern, $this->value) )
1895
+        $pattern = sprintf($pattern, implode('|', $protocols));
1896
+        if ( ! preg_match($pattern, $this->value))
1897 1897
         {
1898 1898
             $message = sprintf(
1899 1899
                 $message ?: 'Value "%s" was expected to be a valid URL starting with http or https',
@@ -1917,13 +1917,13 @@  discard block
 block discarded – undo
1917 1917
      */
1918 1918
     public function domainName($message = null, $propertyPath = null)
1919 1919
     {
1920
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1920
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1921 1921
         {
1922 1922
             return $this;
1923 1923
         }
1924 1924
         $this->string($message, $propertyPath);
1925
-        $pattern   = '/^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}$/';
1926
-        if ( ! preg_match($pattern, $this->value) )
1925
+        $pattern = '/^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}$/';
1926
+        if ( ! preg_match($pattern, $this->value))
1927 1927
         {
1928 1928
             $message = sprintf(
1929 1929
                 $message ?: 'Value "%s" was expected to be a valid domain name',
@@ -1944,7 +1944,7 @@  discard block
 block discarded – undo
1944 1944
      */
1945 1945
     public function alnum($message = null, $propertyPath = null)
1946 1946
     {
1947
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1947
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1948 1948
         {
1949 1949
             return $this;
1950 1950
         }
@@ -1974,11 +1974,11 @@  discard block
 block discarded – undo
1974 1974
      */
1975 1975
     public function true($message = null, $propertyPath = null)
1976 1976
     {
1977
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1977
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1978 1978
         {
1979 1979
             return $this;
1980 1980
         }
1981
-        if ( $this->value !== true )
1981
+        if ($this->value !== true)
1982 1982
         {
1983 1983
             $message = sprintf(
1984 1984
                 $message ?: 'Value "%s" is not TRUE.',
@@ -1999,11 +1999,11 @@  discard block
 block discarded – undo
1999 1999
      */
2000 2000
     public function truthy($message = null, $propertyPath = null)
2001 2001
     {
2002
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2002
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2003 2003
         {
2004 2004
             return $this;
2005 2005
         }
2006
-        if ( ! $this->value )
2006
+        if ( ! $this->value)
2007 2007
         {
2008 2008
             $message = sprintf(
2009 2009
                 $message ?: 'Value "%s" is not truthy.',
@@ -2024,11 +2024,11 @@  discard block
 block discarded – undo
2024 2024
      */
2025 2025
     public function false($message = null, $propertyPath = null)
2026 2026
     {
2027
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2027
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2028 2028
         {
2029 2029
             return $this;
2030 2030
         }
2031
-        if ( $this->value !== false )
2031
+        if ($this->value !== false)
2032 2032
         {
2033 2033
             $message = sprintf(
2034 2034
                 $message ?: 'Value "%s" is not FALSE.',
@@ -2049,11 +2049,11 @@  discard block
 block discarded – undo
2049 2049
      */
2050 2050
     public function notFalse($message = null, $propertyPath = null)
2051 2051
     {
2052
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2052
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2053 2053
         {
2054 2054
             return $this;
2055 2055
         }
2056
-        if ( $this->value === false )
2056
+        if ($this->value === false)
2057 2057
         {
2058 2058
             $message = sprintf(
2059 2059
                 $message ?: 'Value "%s" is not FALSE.',
@@ -2074,11 +2074,11 @@  discard block
 block discarded – undo
2074 2074
      */
2075 2075
     public function classExists($message = null, $propertyPath = null)
2076 2076
     {
2077
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2077
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2078 2078
         {
2079 2079
             return $this;
2080 2080
         }
2081
-        if ( !class_exists($this->value) )
2081
+        if ( ! class_exists($this->value))
2082 2082
         {
2083 2083
             $message = sprintf(
2084 2084
                 $message ?: 'Class "%s" does not exist.',
@@ -2100,19 +2100,19 @@  discard block
 block discarded – undo
2100 2100
      */
2101 2101
     public function implementsInterface($interfaceName, $message = null, $propertyPath = null)
2102 2102
     {
2103
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2103
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2104 2104
         {
2105 2105
             return $this;
2106 2106
         }
2107 2107
         $reflection = new \ReflectionClass($this->value);
2108
-        if ( !$reflection->implementsInterface($interfaceName) )
2108
+        if ( ! $reflection->implementsInterface($interfaceName))
2109 2109
         {
2110 2110
             $message = sprintf(
2111 2111
                 $message ?: 'Class "%s" does not implement interface "%s".',
2112 2112
                 $this->stringify($this->value),
2113 2113
                 $this->stringify($interfaceName)
2114 2114
             );
2115
-            throw $this->createException($message, self::INTERFACE_NOT_IMPLEMENTED, $propertyPath, ['interface' => $interfaceName]);
2115
+            throw $this->createException($message, self::INTERFACE_NOT_IMPLEMENTED, $propertyPath, [ 'interface' => $interfaceName ]);
2116 2116
         }
2117 2117
         return $this;
2118 2118
     }
@@ -2133,11 +2133,11 @@  discard block
 block discarded – undo
2133 2133
      */
2134 2134
     public function isJsonString($message = null, $propertyPath = null)
2135 2135
     {
2136
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2136
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2137 2137
         {
2138 2138
             return $this;
2139 2139
         }
2140
-        if ( null === json_decode($this->value) && JSON_ERROR_NONE !== json_last_error() )
2140
+        if (null === json_decode($this->value) && JSON_ERROR_NONE !== json_last_error())
2141 2141
         {
2142 2142
             $message = sprintf(
2143 2143
                 $message ?: 'Value "%s" is not a valid JSON string.',
@@ -2160,16 +2160,16 @@  discard block
 block discarded – undo
2160 2160
      */
2161 2161
     public function uuid($message = null, $propertyPath = null)
2162 2162
     {
2163
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2163
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2164 2164
         {
2165 2165
             return $this;
2166 2166
         }
2167
-        $this->value = str_replace(['urn:', 'uuid:', '{', '}'], '', $this->value);
2168
-        if ( $this->value === '00000000-0000-0000-0000-000000000000' )
2167
+        $this->value = str_replace([ 'urn:', 'uuid:', '{', '}' ], '', $this->value);
2168
+        if ($this->value === '00000000-0000-0000-0000-000000000000')
2169 2169
         {
2170 2170
             return $this;
2171 2171
         }
2172
-        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) )
2172
+        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))
2173 2173
         {
2174 2174
             $message = sprintf(
2175 2175
                 $message ?: 'Value "%s" is not a valid UUID.',
@@ -2191,18 +2191,18 @@  discard block
 block discarded – undo
2191 2191
      */
2192 2192
     public function count($count, $message = null, $propertyPath = null)
2193 2193
     {
2194
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2194
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2195 2195
         {
2196 2196
             return $this;
2197 2197
         }
2198
-        if ( $count !== count($this->value) )
2198
+        if ($count !== count($this->value))
2199 2199
         {
2200 2200
             $message = sprintf(
2201 2201
                 $message ?: 'List does not contain exactly "%d" elements.',
2202 2202
                 $this->stringify($this->value),
2203 2203
                 $this->stringify($count)
2204 2204
             );
2205
-            throw $this->createException($message, self::INVALID_COUNT, $propertyPath, ['count' => $count]);
2205
+            throw $this->createException($message, self::INVALID_COUNT, $propertyPath, [ 'count' => $count ]);
2206 2206
         }
2207 2207
         return $this;
2208 2208
     }
@@ -2215,24 +2215,24 @@  discard block
 block discarded – undo
2215 2215
      */
2216 2216
     protected function doAllOrNullOr($func, $args)
2217 2217
     {
2218
-        if ( $this->nullOr && is_null($this->value) )
2218
+        if ($this->nullOr && is_null($this->value))
2219 2219
         {
2220 2220
             return true;
2221 2221
         }
2222
-        if ( $this->emptyOr && empty($this->value) )
2222
+        if ($this->emptyOr && empty($this->value))
2223 2223
         {
2224 2224
             return true;
2225 2225
         }
2226
-        if ( $this->all && (new Assert($this->value))->setExceptionClass($this->exceptionClass)->isTraversable() )
2226
+        if ($this->all && (new Assert($this->value))->setExceptionClass($this->exceptionClass)->isTraversable())
2227 2227
         {
2228
-            foreach ( $this->value as $idx => $value )
2228
+            foreach ($this->value as $idx => $value)
2229 2229
             {
2230 2230
                 $object = (new Assert($value))->setExceptionClass($this->exceptionClass);
2231
-                call_user_func_array([$object, $func], $args);
2231
+                call_user_func_array([ $object, $func ], $args);
2232 2232
             }
2233 2233
             return true;
2234 2234
         }
2235
-        return ( $this->nullOr && is_null($this->value) ) || ( $this->emptyOr && empty($this->value) ) ? true : false;
2235
+        return ($this->nullOr && is_null($this->value)) || ($this->emptyOr && empty($this->value)) ? true : false;
2236 2236
     }
2237 2237
 
2238 2238
     /**
@@ -2245,12 +2245,12 @@  discard block
 block discarded – undo
2245 2245
      */
2246 2246
     public function choicesNotEmpty(array $choices, $message = null, $propertyPath = null)
2247 2247
     {
2248
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2248
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2249 2249
         {
2250 2250
             return $this;
2251 2251
         }
2252 2252
         $this->notEmpty($message, $propertyPath);
2253
-        foreach ( $choices as $choice )
2253
+        foreach ($choices as $choice)
2254 2254
         {
2255 2255
             $this->notEmptyKey($choice, $message, $propertyPath);
2256 2256
         }
@@ -2268,12 +2268,12 @@  discard block
 block discarded – undo
2268 2268
      */
2269 2269
     public function methodExists($object, $message = null, $propertyPath = null)
2270 2270
     {
2271
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2271
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2272 2272
         {
2273 2273
             return $this;
2274 2274
         }
2275 2275
         (new Assert($object))->setExceptionClass($this->exceptionClass)->isObject($message, $propertyPath);
2276
-        if ( !method_exists($object, $this->value) )
2276
+        if ( ! method_exists($object, $this->value))
2277 2277
         {
2278 2278
             $message = sprintf(
2279 2279
                 $message ?: 'Expected "%s" does not a exist in provided object.',
@@ -2294,11 +2294,11 @@  discard block
 block discarded – undo
2294 2294
      */
2295 2295
     public function isObject($message = null, $propertyPath = null)
2296 2296
     {
2297
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2297
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2298 2298
         {
2299 2299
             return $this;
2300 2300
         }
2301
-        if ( !is_object($this->value) )
2301
+        if ( ! is_object($this->value))
2302 2302
         {
2303 2303
             $message = sprintf(
2304 2304
                 $message ?: 'Provided "%s" is not a valid object.',
@@ -2317,32 +2317,32 @@  discard block
 block discarded – undo
2317 2317
      */
2318 2318
     private function stringify($value)
2319 2319
     {
2320
-        if ( is_bool($value) )
2320
+        if (is_bool($value))
2321 2321
         {
2322 2322
             return $value ? '<TRUE>' : '<FALSE>';
2323 2323
         }
2324
-        if ( is_scalar($value) )
2324
+        if (is_scalar($value))
2325 2325
         {
2326 2326
             $val = (string)$value;
2327
-            if ( strlen($val) > 100 )
2327
+            if (strlen($val) > 100)
2328 2328
             {
2329
-                $val = substr($val, 0, 97) . '...';
2329
+                $val = substr($val, 0, 97).'...';
2330 2330
             }
2331 2331
             return $val;
2332 2332
         }
2333
-        if ( is_array($value) )
2333
+        if (is_array($value))
2334 2334
         {
2335 2335
             return '<ARRAY>';
2336 2336
         }
2337
-        if ( is_object($value) )
2337
+        if (is_object($value))
2338 2338
         {
2339 2339
             return get_class($value);
2340 2340
         }
2341
-        if ( is_resource($value) )
2341
+        if (is_resource($value))
2342 2342
         {
2343 2343
             return '<RESOURCE>';
2344 2344
         }
2345
-        if ( $value === null )
2345
+        if ($value === null)
2346 2346
         {
2347 2347
             return '<NULL>';
2348 2348
         }
Please login to merge, or discard this patch.