Completed
Push — master ( 5d2291...19042c )
by Terry
01:59
created
bin/benchmark.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1
-<?php declare(strict_types=1);
1
+<?php declare(strict_types = 1);
2 2
 
3 3
 
4
-require_once __DIR__ . '/../../../../vendor/autoload.php';
4
+require_once __DIR__.'/../../../../vendor/autoload.php';
5 5
 
6 6
 use function Terah\Assert\Assert;
7 7
 
@@ -14,30 +14,30 @@  discard block
 block discarded – undo
14 14
 echo "Benchmarking static Terah\\Assert";
15 15
 $start = microtime(true);
16 16
 
17
-for ( $i = 0 ; $i < 100000 ; $i++ )
17
+for ($i = 0; $i < 100000; $i++)
18 18
 {
19 19
     Assert::that(true)->true();
20 20
 }
21 21
 $time = microtime(true) - $start;
22
-echo "Taken: $time" . PHP_EOL;
22
+echo "Taken: $time".PHP_EOL;
23 23
 
24 24
 echo "Benchmarking new Terah\\Assert";
25 25
 $start = microtime(true);
26 26
 
27
-for ( $i = 0 ; $i < 100000 ; $i++ )
27
+for ($i = 0; $i < 100000; $i++)
28 28
 {
29 29
     Assert(true)->true();
30 30
 }
31 31
 $time = microtime(true) - $start;
32
-echo "Taken: $time" . PHP_EOL;
32
+echo "Taken: $time".PHP_EOL;
33 33
 
34 34
 echo "Benchmarking fluent Beberlei";
35 35
 $start = microtime(true);
36 36
 
37
-for ( $i = 0 ; $i < 100000 ; $i++ )
37
+for ($i = 0; $i < 100000; $i++)
38 38
 {
39 39
     Beberlei\that(true)->true();
40 40
 }
41 41
 $time = microtime(true) - $start;
42
-echo "Taken: $time" . PHP_EOL;
42
+echo "Taken: $time".PHP_EOL;
43 43
 
Please login to merge, or discard this patch.
src/Validate.php 1 patch
Spacing   +2 added lines, -2 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
 
@@ -10,5 +10,5 @@  discard block
 block discarded – undo
10 10
      *
11 11
      * @var string
12 12
      */
13
-    protected $exceptionClass           = 'Terah\Assert\ValidationFailedException';
13
+    protected $exceptionClass = 'Terah\Assert\ValidationFailedException';
14 14
 }
15 15
\ No newline at end of file
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/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.
src/Assert.php 3 patches
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -158,8 +158,7 @@  discard block
 block discarded – undo
158 158
             {
159 159
 
160 160
                 $validator->__invoke();
161
-            }
162
-            catch ( AssertionFailedException $e )
161
+            } catch ( AssertionFailedException $e )
163 162
             {
164 163
                 $errors[$fieldName]     = $e->getMessage();
165 164
             }
@@ -2206,8 +2205,7 @@  discard block
 block discarded – undo
2206 2205
             );
2207 2206
 
2208 2207
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_EMAIL, $fieldName);
2209
-        }
2210
-        else
2208
+        } else
2211 2209
         {
2212 2210
             $host = substr($this->value, strpos($this->value, '@') + 1);
2213 2211
             // Likely not a FQDN, bug in PHP FILTER_VALIDATE_EMAIL prior to PHP 5.3.3
@@ -2341,8 +2339,7 @@  discard block
 block discarded – undo
2341 2339
         try
2342 2340
         {
2343 2341
             $this->regex('/^04[0-9]{8})$/', $message, $fieldName);
2344
-        }
2345
-        catch ( AssertionFailedException $e )
2342
+        } catch ( AssertionFailedException $e )
2346 2343
         {
2347 2344
             $message = $message ?: $this->overrideError;
2348 2345
             $message = sprintf(
@@ -2374,8 +2371,7 @@  discard block
 block discarded – undo
2374 2371
         try
2375 2372
         {
2376 2373
             $this->regex('(^([a-zA-Z]{1}[a-zA-Z0-9]*)$)', $message, $fieldName);
2377
-        }
2378
-        catch (AssertionFailedException $e)
2374
+        } catch (AssertionFailedException $e)
2379 2375
         {
2380 2376
             $message = $message ?: $this->overrideError;
2381 2377
             $message = sprintf(
@@ -2681,8 +2677,7 @@  discard block
 block discarded – undo
2681 2677
         try
2682 2678
         {
2683 2679
             $this->email($message, $fieldName);
2684
-        }
2685
-        catch (AssertionFailedException $e)
2680
+        } catch (AssertionFailedException $e)
2686 2681
         {
2687 2682
             $message = $message ?: $this->overrideError;
2688 2683
             $message = sprintf(
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1408,7 +1408,7 @@  discard block
 block discarded – undo
1408 1408
     /**
1409 1409
      * Alias of {@see choice()}
1410 1410
      *
1411
-     * @param array  $choices
1411
+     * @param integer[]  $choices
1412 1412
      * @param string $message
1413 1413
      * @param string $fieldName
1414 1414
      * @return Assert
@@ -2728,7 +2728,7 @@  discard block
 block discarded – undo
2728 2728
     }
2729 2729
 
2730 2730
     /**
2731
-     * @param $func
2731
+     * @param string $func
2732 2732
      * @param $args
2733 2733
      * @return bool
2734 2734
      * @throws AssertionFailedException
Please login to merge, or discard this patch.
Spacing   +223 added lines, -223 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,17 +151,17 @@  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
 
160 160
                 $validator->__invoke();
161 161
             }
162
-            catch ( AssertionFailedException $e )
162
+            catch (AssertionFailedException $e)
163 163
             {
164
-                $errors[$fieldName]     = $e->getMessage();
164
+                $errors[ $fieldName ] = $e->getMessage();
165 165
             }
166 166
         }
167 167
 
@@ -176,22 +176,22 @@  discard block
 block discarded – undo
176 176
      * @param string $level
177 177
      * @return Assert
178 178
      */
179
-    public static function that($value, string $fieldName = '', int $code=0, string $error='', string $level=Assert::WARNING) : Assert
179
+    public static function that($value, string $fieldName = '', int $code = 0, string $error = '', string $level = Assert::WARNING) : Assert
180 180
     {
181 181
         $assert = new static($value);
182
-        if ( $fieldName )
182
+        if ($fieldName)
183 183
         {
184 184
             $assert->fieldName($fieldName);
185 185
         }
186
-        if ( $code )
186
+        if ($code)
187 187
         {
188 188
             $assert->code($code);
189 189
         }
190
-        if ( $error )
190
+        if ($error)
191 191
         {
192 192
             $assert->error($error);
193 193
         }
194
-        if ( $level )
194
+        if ($level)
195 195
         {
196 196
             $assert->level($level);
197 197
         }
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
      * @param string $level
271 271
      * @return AssertionFailedException
272 272
      */
273
-    protected function createException(string $message, int $code, string $fieldName, array $constraints = [], string $level = '') : AssertionFailedException
273
+    protected function createException(string $message, int $code, string $fieldName, array $constraints = [ ], string $level = '') : AssertionFailedException
274 274
     {
275 275
         $exceptionClass = $this->exceptionClass;
276 276
         $fieldName      = empty($fieldName) ? $this->fieldName : $fieldName;
@@ -362,11 +362,11 @@  discard block
 block discarded – undo
362 362
      */
363 363
     public function eq($value2, string $message = '', string $fieldName = '') : Assert
364 364
     {
365
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
365
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
366 366
         {
367 367
             return $this;
368 368
         }
369
-        if ( $this->value != $value2 )
369
+        if ($this->value != $value2)
370 370
         {
371 371
             $message = $message ?: $this->overrideError;
372 372
             $message = sprintf(
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
                 $this->stringify($value2)
376 376
             );
377 377
 
378
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $fieldName, ['expected' => $value2]);
378
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $fieldName, [ 'expected' => $value2 ]);
379 379
         }
380 380
 
381 381
         return $this;
@@ -392,11 +392,11 @@  discard block
 block discarded – undo
392 392
      */
393 393
     public function greaterThan($value2, string $message = '', string $fieldName = '') : Assert
394 394
     {
395
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
395
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
396 396
         {
397 397
             return $this;
398 398
         }
399
-        if ( ! ( $this->value > $value2 ) )
399
+        if ( ! ($this->value > $value2))
400 400
         {
401 401
             $message = $message ?: $this->overrideError;
402 402
             $message = sprintf(
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
                 $this->stringify($value2)
406 406
             );
407 407
 
408
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $fieldName, ['expected' => $value2]);
408
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $fieldName, [ 'expected' => $value2 ]);
409 409
         }
410 410
 
411 411
         return $this;
@@ -422,11 +422,11 @@  discard block
 block discarded – undo
422 422
      */
423 423
     public function greaterThanOrEq($value2, string $message = '', string $fieldName = '') : Assert
424 424
     {
425
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
425
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
426 426
         {
427 427
             return $this;
428 428
         }
429
-        if ( ! ( $this->value >= $value2 ) )
429
+        if ( ! ($this->value >= $value2))
430 430
         {
431 431
             $message = $message ?: $this->overrideError;
432 432
             $message = sprintf(
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
                 $this->stringify($value2)
436 436
             );
437 437
 
438
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $fieldName, ['expected' => $value2]);
438
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $fieldName, [ 'expected' => $value2 ]);
439 439
         }
440 440
 
441 441
         return $this;
@@ -452,11 +452,11 @@  discard block
 block discarded – undo
452 452
      */
453 453
     public function lessThan($value2, string $message = '', string $fieldName = '') : Assert
454 454
     {
455
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
455
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
456 456
         {
457 457
             return $this;
458 458
         }
459
-        if ( ! ( $this->value < $value2 ) )
459
+        if ( ! ($this->value < $value2))
460 460
         {
461 461
             $message = $message ?: $this->overrideError;
462 462
             $message = sprintf(
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
                 $this->stringify($value2)
466 466
             );
467 467
 
468
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_LESS_THAN, $fieldName, ['expected' => $value2]);
468
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_LESS_THAN, $fieldName, [ 'expected' => $value2 ]);
469 469
         }
470 470
 
471 471
         return $this;
@@ -482,11 +482,11 @@  discard block
 block discarded – undo
482 482
      */
483 483
     public function lessThanOrEq($value2, string $message = '', string $fieldName = '') : Assert
484 484
     {
485
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
485
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
486 486
         {
487 487
             return $this;
488 488
         }
489
-        if ( ! ( $this->value <= $value2 ) )
489
+        if ( ! ($this->value <= $value2))
490 490
         {
491 491
             $message = $message ?: $this->overrideError;
492 492
             $message = sprintf(
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
                 $this->stringify($value2)
496 496
             );
497 497
 
498
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_LESS_THAN_OR_EQ, $fieldName, ['expected' => $value2]);
498
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_LESS_THAN_OR_EQ, $fieldName, [ 'expected' => $value2 ]);
499 499
         }
500 500
 
501 501
         return $this;
@@ -512,11 +512,11 @@  discard block
 block discarded – undo
512 512
      */
513 513
     public function same($value2, string $message = '', string $fieldName = '') : Assert
514 514
     {
515
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
515
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
516 516
         {
517 517
             return $this;
518 518
         }
519
-        if ( $this->value !== $value2 )
519
+        if ($this->value !== $value2)
520 520
         {
521 521
             $message = $message ?: $this->overrideError;
522 522
             $message = sprintf(
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
                 $this->stringify($value2)
526 526
             );
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
 
531 531
         return $this;
@@ -542,11 +542,11 @@  discard block
 block discarded – undo
542 542
      */
543 543
     public function notEq($value2, string $message = '', string $fieldName = '') : Assert
544 544
     {
545
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
545
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
546 546
         {
547 547
             return $this;
548 548
         }
549
-        if ( $this->value == $value2 )
549
+        if ($this->value == $value2)
550 550
         {
551 551
             $message = $message ?: $this->overrideError;
552 552
             $message = sprintf(
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
                 $this->stringify($value2)
556 556
             );
557 557
 
558
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_EQ, $fieldName, ['expected' => $value2]);
558
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_EQ, $fieldName, [ 'expected' => $value2 ]);
559 559
         }
560 560
 
561 561
         return $this;
@@ -571,11 +571,11 @@  discard block
 block discarded – undo
571 571
      */
572 572
     public function isCallable(string $message = '', string $fieldName = '') : Assert
573 573
     {
574
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
574
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
575 575
         {
576 576
             return $this;
577 577
         }
578
-        if ( !is_callable($this->value) )
578
+        if ( ! is_callable($this->value))
579 579
         {
580 580
             $message = $message ?: $this->overrideError;
581 581
             $message = sprintf(
@@ -600,11 +600,11 @@  discard block
 block discarded – undo
600 600
      */
601 601
     public function notSame($value2, string $message = '', string $fieldName = '') : Assert
602 602
     {
603
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
603
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
604 604
         {
605 605
             return $this;
606 606
         }
607
-        if ( $this->value === $value2 )
607
+        if ($this->value === $value2)
608 608
         {
609 609
             $message = $message ?: $this->overrideError;
610 610
             $message = sprintf(
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
                 $this->stringify($value2)
614 614
             );
615 615
 
616
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_SAME, $fieldName, ['expected' => $value2]);
616
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_SAME, $fieldName, [ 'expected' => $value2 ]);
617 617
         }
618 618
 
619 619
         return $this;
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
         $message = $message ?: $this->overrideError;
680 680
         $message = $message ?: 'Value "%s" is not a valid status.';
681 681
 
682
-        return $this->integer($message, $fieldName)->inArray([-1, 0, 1]);
682
+        return $this->integer($message, $fieldName)->inArray([-1, 0, 1 ]);
683 683
     }
684 684
 
685 685
     /**
@@ -731,11 +731,11 @@  discard block
 block discarded – undo
731 731
      */
732 732
     public function integer(string $message = '', string $fieldName = '') : Assert
733 733
     {
734
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
734
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
735 735
         {
736 736
             return $this;
737 737
         }
738
-        if ( !is_int($this->value) )
738
+        if ( ! is_int($this->value))
739 739
         {
740 740
             $message = $message ?: $this->overrideError;
741 741
             $message = sprintf(
@@ -759,11 +759,11 @@  discard block
 block discarded – undo
759 759
      */
760 760
     public function float(string $message = '', string $fieldName = '') : Assert
761 761
     {
762
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
762
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
763 763
         {
764 764
             return $this;
765 765
         }
766
-        if ( ! is_float($this->value) )
766
+        if ( ! is_float($this->value))
767 767
         {
768 768
             $message = $message ?: $this->overrideError;
769 769
             $message = sprintf(
@@ -787,11 +787,11 @@  discard block
 block discarded – undo
787 787
      */
788 788
     public function digit(string $message = '', string $fieldName = '') : Assert
789 789
     {
790
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
790
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
791 791
         {
792 792
             return $this;
793 793
         }
794
-        if ( ! ctype_digit((string)$this->value) )
794
+        if ( ! ctype_digit((string)$this->value))
795 795
         {
796 796
             $message = $message ?: $this->overrideError;
797 797
             $message = sprintf(
@@ -815,12 +815,12 @@  discard block
 block discarded – undo
815 815
      */
816 816
     public function date(string $message = '', string $fieldName = '') : Assert
817 817
     {
818
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
818
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
819 819
         {
820 820
             return $this;
821 821
         }
822 822
         $this->notEmpty($message, $fieldName);
823
-        if ( strtotime($this->value) === false )
823
+        if (strtotime($this->value) === false)
824 824
         {
825 825
             $message = $message ?: $this->overrideError;
826 826
             $message = sprintf(
@@ -844,11 +844,11 @@  discard block
 block discarded – undo
844 844
      */
845 845
     public function integerish(string $message = '', string $fieldName = '') : Assert
846 846
     {
847
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
847
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
848 848
         {
849 849
             return $this;
850 850
         }
851
-        if ( is_object($this->value) || strval(intval($this->value)) != $this->value || is_bool($this->value) || is_null($this->value) )
851
+        if (is_object($this->value) || strval(intval($this->value)) != $this->value || is_bool($this->value) || is_null($this->value))
852 852
         {
853 853
             $message = $message ?: $this->overrideError;
854 854
             $message = sprintf(
@@ -872,11 +872,11 @@  discard block
 block discarded – undo
872 872
      */
873 873
     public function boolean(string $message = '', string $fieldName = '') : Assert
874 874
     {
875
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
875
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
876 876
         {
877 877
             return $this;
878 878
         }
879
-        if ( ! is_bool($this->value) )
879
+        if ( ! is_bool($this->value))
880 880
         {
881 881
             $message = $message ?: $this->overrideError;
882 882
             $message = sprintf(
@@ -900,11 +900,11 @@  discard block
 block discarded – undo
900 900
      */
901 901
     public function scalar(string $message = '', string $fieldName = '') : Assert
902 902
     {
903
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
903
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
904 904
         {
905 905
             return $this;
906 906
         }
907
-        if ( ! is_scalar($this->value) )
907
+        if ( ! is_scalar($this->value))
908 908
         {
909 909
             $message = $message ?: $this->overrideError;
910 910
             $message = sprintf(
@@ -928,11 +928,11 @@  discard block
 block discarded – undo
928 928
      */
929 929
     public function notEmpty(string $message = '', string $fieldName = '') : Assert
930 930
     {
931
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
931
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
932 932
         {
933 933
             return $this;
934 934
         }
935
-        if ( ( is_object($this->value) && empty((array)$this->value) ) || empty($this->value) )
935
+        if ((is_object($this->value) && empty((array)$this->value)) || empty($this->value))
936 936
         {
937 937
             $message = $message ?: $this->overrideError;
938 938
             $message = sprintf(
@@ -956,11 +956,11 @@  discard block
 block discarded – undo
956 956
      */
957 957
     public function noContent(string $message = '', string $fieldName = '') : Assert
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 ( !empty( $this->value ) )
963
+        if ( ! empty($this->value))
964 964
         {
965 965
             $message = $message ?: $this->overrideError;
966 966
             $message = sprintf(
@@ -984,11 +984,11 @@  discard block
 block discarded – undo
984 984
      */
985 985
     public function notNull(string $message = '', string $fieldName = '') : Assert
986 986
     {
987
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
987
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
988 988
         {
989 989
             return $this;
990 990
         }
991
-        if ( $this->value === null )
991
+        if ($this->value === null)
992 992
         {
993 993
             $message = $message ?: $this->overrideError;
994 994
             $message = sprintf(
@@ -1012,11 +1012,11 @@  discard block
 block discarded – undo
1012 1012
      */
1013 1013
     public function string(string $message = '', string $fieldName = '') : Assert
1014 1014
     {
1015
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1015
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1016 1016
         {
1017 1017
             return $this;
1018 1018
         }
1019
-        if ( !is_string($this->value) )
1019
+        if ( ! is_string($this->value))
1020 1020
         {
1021 1021
             $message = $message ?: $this->overrideError;
1022 1022
             $message = sprintf(
@@ -1042,12 +1042,12 @@  discard block
 block discarded – undo
1042 1042
      */
1043 1043
     public function regex(string $pattern, string $message = '', string $fieldName = '') : Assert
1044 1044
     {
1045
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1045
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1046 1046
         {
1047 1047
             return $this;
1048 1048
         }
1049 1049
         $this->string($message, $fieldName);
1050
-        if ( ! preg_match($pattern, $this->value) )
1050
+        if ( ! preg_match($pattern, $this->value))
1051 1051
         {
1052 1052
             $message = $message ?: $this->overrideError;
1053 1053
             $message = sprintf(
@@ -1055,7 +1055,7 @@  discard block
 block discarded – undo
1055 1055
                 $this->stringify($this->value)
1056 1056
             );
1057 1057
 
1058
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_REGEX, $fieldName, ['pattern' => $pattern]);
1058
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_REGEX, $fieldName, [ 'pattern' => $pattern ]);
1059 1059
         }
1060 1060
 
1061 1061
         return $this;
@@ -1071,13 +1071,13 @@  discard block
 block discarded – undo
1071 1071
      */
1072 1072
     public function ipAddress(string $message = '', string $fieldName = '') : Assert
1073 1073
     {
1074
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1074
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1075 1075
         {
1076 1076
             return $this;
1077 1077
         }
1078 1078
         $this->string($message, $fieldName);
1079
-        $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])$/';
1080
-        if ( ! preg_match($pattern, $this->value) )
1079
+        $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])$/';
1080
+        if ( ! preg_match($pattern, $this->value))
1081 1081
         {
1082 1082
             $message = $message ?: $this->overrideError;
1083 1083
             $message = sprintf(
@@ -1102,12 +1102,12 @@  discard block
 block discarded – undo
1102 1102
      */
1103 1103
     public function notRegex(string $pattern, string $message = '', string $fieldName = '') : Assert
1104 1104
     {
1105
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1105
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1106 1106
         {
1107 1107
             return $this;
1108 1108
         }
1109 1109
         $this->string($message, $fieldName);
1110
-        if ( preg_match($pattern, $this->value) )
1110
+        if (preg_match($pattern, $this->value))
1111 1111
         {
1112 1112
             $message = $message ?: $this->overrideError;
1113 1113
             $message = sprintf(
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
                 $this->stringify($this->value)
1116 1116
             );
1117 1117
 
1118
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_REGEX, $fieldName, ['pattern' => $pattern]);
1118
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_REGEX, $fieldName, [ 'pattern' => $pattern ]);
1119 1119
         }
1120 1120
 
1121 1121
         return $this;
@@ -1133,12 +1133,12 @@  discard block
 block discarded – undo
1133 1133
      */
1134 1134
     public function length(int $length, string $message = '', string $fieldName = '', $encoding = 'utf8') : Assert
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 1140
         $this->string($message, $fieldName);
1141
-        if ( mb_strlen($this->value, $encoding) !== $length )
1141
+        if (mb_strlen($this->value, $encoding) !== $length)
1142 1142
         {
1143 1143
             $message    = $message ?: $this->overrideError;
1144 1144
             $message    = sprintf(
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
                 $length,
1148 1148
                 mb_strlen($this->value, $encoding)
1149 1149
             );
1150
-            $constraints = ['length' => $length, 'encoding' => $encoding];
1150
+            $constraints = [ 'length' => $length, 'encoding' => $encoding ];
1151 1151
 
1152 1152
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_LENGTH, $fieldName, $constraints);
1153 1153
         }
@@ -1168,22 +1168,22 @@  discard block
 block discarded – undo
1168 1168
      */
1169 1169
     public function minLength(int $minLength, string $message = '', string $fieldName = '', $encoding = 'utf8') : Assert
1170 1170
     {
1171
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1171
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1172 1172
         {
1173 1173
             return $this;
1174 1174
         }
1175 1175
         $this->string($message, $fieldName);
1176
-        if ( mb_strlen($this->value, $encoding) < $minLength )
1176
+        if (mb_strlen($this->value, $encoding) < $minLength)
1177 1177
         {
1178 1178
             $message = $message ?: $this->overrideError;
1179
-            $message     = sprintf(
1179
+            $message = sprintf(
1180 1180
                 $message
1181 1181
                     ?: 'Value "%s" is too short, it should have more than %d characters, but only has %d characters.',
1182 1182
                 $this->stringify($this->value),
1183 1183
                 $minLength,
1184 1184
                 mb_strlen($this->value, $encoding)
1185 1185
             );
1186
-            $constraints = ['min_length' => $minLength, 'encoding' => $encoding];
1186
+            $constraints = [ 'min_length' => $minLength, 'encoding' => $encoding ];
1187 1187
 
1188 1188
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_MIN_LENGTH, $fieldName, $constraints);
1189 1189
         }
@@ -1204,21 +1204,21 @@  discard block
 block discarded – undo
1204 1204
      */
1205 1205
     public function maxLength(int $maxLength, string $message = '', string $fieldName = '', $encoding = 'utf8') : Assert
1206 1206
     {
1207
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1207
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1208 1208
         {
1209 1209
             return $this;
1210 1210
         }
1211 1211
         $this->string($message, $fieldName);
1212
-        if ( mb_strlen($this->value, $encoding) > $maxLength )
1212
+        if (mb_strlen($this->value, $encoding) > $maxLength)
1213 1213
         {
1214 1214
             $message = $message ?: $this->overrideError;
1215
-            $message     = sprintf(
1215
+            $message = sprintf(
1216 1216
                 $message ?: 'Value "%s" is too long, it should have no more than %d characters, but has %d characters.',
1217 1217
                 $this->stringify($this->value),
1218 1218
                 $maxLength,
1219 1219
                 mb_strlen($this->value, $encoding)
1220 1220
             );
1221
-            $constraints = ['max_length' => $maxLength, 'encoding' => $encoding];
1221
+            $constraints = [ 'max_length' => $maxLength, 'encoding' => $encoding ];
1222 1222
 
1223 1223
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_MAX_LENGTH, $fieldName, $constraints);
1224 1224
         }
@@ -1239,35 +1239,35 @@  discard block
 block discarded – undo
1239 1239
      */
1240 1240
     public function betweenLength(int $minLength, int $maxLength, string $message = '', string $fieldName = '', $encoding = 'utf8') : Assert
1241 1241
     {
1242
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1242
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1243 1243
         {
1244 1244
             return $this;
1245 1245
         }
1246 1246
         $this->string($message, $fieldName);
1247
-        if ( mb_strlen($this->value, $encoding) < $minLength )
1247
+        if (mb_strlen($this->value, $encoding) < $minLength)
1248 1248
         {
1249 1249
             $message = $message ?: $this->overrideError;
1250
-            $message     = sprintf(
1250
+            $message = sprintf(
1251 1251
                 $message
1252 1252
                     ?: 'Value "%s" is too short, it should have more than %d characters, but only has %d characters.',
1253 1253
                 $this->stringify($this->value),
1254 1254
                 $minLength,
1255 1255
                 mb_strlen($this->value, $encoding)
1256 1256
             );
1257
-            $constraints = ['min_length' => $minLength, 'encoding' => $encoding];
1257
+            $constraints = [ 'min_length' => $minLength, 'encoding' => $encoding ];
1258 1258
 
1259 1259
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_MIN_LENGTH, $fieldName, $constraints);
1260 1260
         }
1261
-        if ( mb_strlen($this->value, $encoding) > $maxLength )
1261
+        if (mb_strlen($this->value, $encoding) > $maxLength)
1262 1262
         {
1263 1263
             $message = $message ?: $this->overrideError;
1264
-            $message     = sprintf(
1264
+            $message = sprintf(
1265 1265
                 $message ?: 'Value "%s" is too long, it should have no more than %d characters, but has %d characters.',
1266 1266
                 $this->stringify($this->value),
1267 1267
                 $maxLength,
1268 1268
                 mb_strlen($this->value, $encoding)
1269 1269
             );
1270
-            $constraints = ['max_length' => $maxLength, 'encoding' => $encoding];
1270
+            $constraints = [ 'max_length' => $maxLength, 'encoding' => $encoding ];
1271 1271
 
1272 1272
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_MAX_LENGTH, $fieldName, $constraints);
1273 1273
         }
@@ -1287,20 +1287,20 @@  discard block
 block discarded – undo
1287 1287
      */
1288 1288
     public function startsWith(string $needle, string $message = '', string $fieldName = '', string $encoding = 'utf8') : Assert
1289 1289
     {
1290
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1290
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1291 1291
         {
1292 1292
             return $this;
1293 1293
         }
1294 1294
         $this->string($message, $fieldName);
1295
-        if ( mb_strpos($this->value, $needle, 0, $encoding) !== 0 )
1295
+        if (mb_strpos($this->value, $needle, 0, $encoding) !== 0)
1296 1296
         {
1297 1297
             $message = $message ?: $this->overrideError;
1298
-            $message     = sprintf(
1298
+            $message = sprintf(
1299 1299
                 $message ?: 'Value "%s" does not start with "%s".',
1300 1300
                 $this->stringify($this->value),
1301 1301
                 $this->stringify($needle)
1302 1302
             );
1303
-            $constraints = ['needle' => $needle, 'encoding' => $encoding];
1303
+            $constraints = [ 'needle' => $needle, 'encoding' => $encoding ];
1304 1304
 
1305 1305
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_STRING_START, $fieldName, $constraints);
1306 1306
         }
@@ -1320,21 +1320,21 @@  discard block
 block discarded – undo
1320 1320
      */
1321 1321
     public function endsWith(string $needle, string $message = '', string $fieldName = '', string $encoding = 'utf8') : Assert
1322 1322
     {
1323
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1323
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1324 1324
         {
1325 1325
             return $this;
1326 1326
         }
1327 1327
         $this->string($message, $fieldName);
1328 1328
         $stringPosition = mb_strlen($this->value, $encoding) - mb_strlen($needle, $encoding);
1329
-        if ( mb_strripos($this->value, $needle, 0 , $encoding) !== $stringPosition )
1329
+        if (mb_strripos($this->value, $needle, 0, $encoding) !== $stringPosition)
1330 1330
         {
1331 1331
             $message = $message ?: $this->overrideError;
1332
-            $message     = sprintf(
1332
+            $message = sprintf(
1333 1333
                 $message ?: 'Value "%s" does not end with "%s".',
1334 1334
                 $this->stringify($this->value),
1335 1335
                 $this->stringify($needle)
1336 1336
             );
1337
-            $constraints = ['needle' => $needle, 'encoding' => $encoding];
1337
+            $constraints = [ 'needle' => $needle, 'encoding' => $encoding ];
1338 1338
 
1339 1339
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_STRING_END, $fieldName, $constraints);
1340 1340
         }
@@ -1354,20 +1354,20 @@  discard block
 block discarded – undo
1354 1354
      */
1355 1355
     public function contains(string $needle, string $message = '', string $fieldName = '', string$encoding = 'utf8') : Assert
1356 1356
     {
1357
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1357
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1358 1358
         {
1359 1359
             return $this;
1360 1360
         }
1361 1361
         $this->string($message, $fieldName);
1362
-        if ( mb_strpos($this->value, $needle, 0, $encoding) === false )
1362
+        if (mb_strpos($this->value, $needle, 0, $encoding) === false)
1363 1363
         {
1364 1364
             $message = $message ?: $this->overrideError;
1365
-            $message     = sprintf(
1365
+            $message = sprintf(
1366 1366
                 $message ?: 'Value "%s" does not contain "%s".',
1367 1367
                 $this->stringify($this->value),
1368 1368
                 $this->stringify($needle)
1369 1369
             );
1370
-            $constraints = ['needle' => $needle, 'encoding' => $encoding];
1370
+            $constraints = [ 'needle' => $needle, 'encoding' => $encoding ];
1371 1371
 
1372 1372
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_STRING_CONTAINS, $fieldName, $constraints);
1373 1373
         }
@@ -1386,11 +1386,11 @@  discard block
 block discarded – undo
1386 1386
      */
1387 1387
     public function choice(array $choices, string $message = '', string $fieldName = '') : Assert
1388 1388
     {
1389
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1389
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1390 1390
         {
1391 1391
             return $this;
1392 1392
         }
1393
-        if ( !in_array($this->value, $choices, true) )
1393
+        if ( ! in_array($this->value, $choices, true))
1394 1394
         {
1395 1395
             $message = $message ?: $this->overrideError;
1396 1396
             $message = sprintf(
@@ -1399,7 +1399,7 @@  discard block
 block discarded – undo
1399 1399
                 implode(", ", array_map('Terah\Assert\Assert::stringify', $choices))
1400 1400
             );
1401 1401
 
1402
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_CHOICE, $fieldName, ['choices' => $choices]);
1402
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_CHOICE, $fieldName, [ 'choices' => $choices ]);
1403 1403
         }
1404 1404
 
1405 1405
         return $this;
@@ -1416,7 +1416,7 @@  discard block
 block discarded – undo
1416 1416
      */
1417 1417
     public function inArray(array $choices, string $message = '', string $fieldName = '') : Assert
1418 1418
     {
1419
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1419
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1420 1420
         {
1421 1421
             return $this;
1422 1422
         }
@@ -1435,11 +1435,11 @@  discard block
 block discarded – undo
1435 1435
      */
1436 1436
     public function numeric(string $message = '', string $fieldName = '') : Assert
1437 1437
     {
1438
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1438
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1439 1439
         {
1440 1440
             return $this;
1441 1441
         }
1442
-        if ( ! is_numeric($this->value) )
1442
+        if ( ! is_numeric($this->value))
1443 1443
         {
1444 1444
             $message = $message ?: $this->overrideError;
1445 1445
             $message = sprintf(
@@ -1508,11 +1508,11 @@  discard block
 block discarded – undo
1508 1508
      */
1509 1509
     public function isArray(string $message = '', string $fieldName = '') : Assert
1510 1510
     {
1511
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1511
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1512 1512
         {
1513 1513
             return $this;
1514 1514
         }
1515
-        if ( !is_array($this->value) )
1515
+        if ( ! is_array($this->value))
1516 1516
         {
1517 1517
             $message = $message ?: $this->overrideError;
1518 1518
             $message = sprintf(
@@ -1536,11 +1536,11 @@  discard block
 block discarded – undo
1536 1536
      */
1537 1537
     public function isTraversable(string $message = '', string $fieldName = '') : Assert
1538 1538
     {
1539
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1539
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1540 1540
         {
1541 1541
             return $this;
1542 1542
         }
1543
-        if ( !is_array($this->value) && !$this->value instanceof \Traversable )
1543
+        if ( ! is_array($this->value) && ! $this->value instanceof \Traversable)
1544 1544
         {
1545 1545
             $message = $message ?: $this->overrideError;
1546 1546
             $message = sprintf(
@@ -1564,11 +1564,11 @@  discard block
 block discarded – undo
1564 1564
      */
1565 1565
     public function isArrayAccessible(string $message = '', string $fieldName = '') : Assert
1566 1566
     {
1567
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1567
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1568 1568
         {
1569 1569
             return $this;
1570 1570
         }
1571
-        if ( !is_array($this->value) && !$this->value instanceof \ArrayAccess )
1571
+        if ( ! is_array($this->value) && ! $this->value instanceof \ArrayAccess)
1572 1572
         {
1573 1573
             $message = $message ?: $this->overrideError;
1574 1574
             $message = sprintf(
@@ -1593,12 +1593,12 @@  discard block
 block discarded – undo
1593 1593
      */
1594 1594
     public function keyExists($key, string $message = '', string $fieldName = '') : Assert
1595 1595
     {
1596
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1596
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1597 1597
         {
1598 1598
             return $this;
1599 1599
         }
1600 1600
         $this->isArray($message, $fieldName);
1601
-        if ( !array_key_exists($key, $this->value) )
1601
+        if ( ! array_key_exists($key, $this->value))
1602 1602
         {
1603 1603
             $message = $message ?: $this->overrideError;
1604 1604
             $message = sprintf(
@@ -1606,7 +1606,7 @@  discard block
 block discarded – undo
1606 1606
                 $this->stringify($key)
1607 1607
             );
1608 1608
 
1609
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEY_EXISTS, $fieldName, ['key' => $key]);
1609
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEY_EXISTS, $fieldName, [ 'key' => $key ]);
1610 1610
         }
1611 1611
 
1612 1612
         return $this;
@@ -1623,21 +1623,21 @@  discard block
 block discarded – undo
1623 1623
      */
1624 1624
     public function keysExist(array $keys, string $message = '', string $fieldName = '') : Assert
1625 1625
     {
1626
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1626
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1627 1627
         {
1628 1628
             return $this;
1629 1629
         }
1630 1630
         $this->isArray($message, $fieldName);
1631
-        foreach ( $keys as $key )
1631
+        foreach ($keys as $key)
1632 1632
         {
1633
-            if ( !array_key_exists($key, $this->value) )
1633
+            if ( ! array_key_exists($key, $this->value))
1634 1634
             {
1635 1635
                 $message = $message
1636 1636
                     ?: sprintf(
1637 1637
                         'Array does not contain an element with key "%s"',
1638 1638
                         $this->stringify($key)
1639 1639
                     );
1640
-                throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEYS_EXIST, $fieldName, ['key' => $key]);
1640
+                throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEYS_EXIST, $fieldName, [ 'key' => $key ]);
1641 1641
             }
1642 1642
         }
1643 1643
 
@@ -1655,12 +1655,12 @@  discard block
 block discarded – undo
1655 1655
      */
1656 1656
     public function propertyExists($key, string $message = '', string $fieldName = '') : Assert
1657 1657
     {
1658
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1658
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1659 1659
         {
1660 1660
             return $this;
1661 1661
         }
1662 1662
         $this->isObject($message, $fieldName);
1663
-        if ( !property_exists($this->value, $key) && !isset( $this->value->{$key} ) )
1663
+        if ( ! property_exists($this->value, $key) && ! isset($this->value->{$key} ))
1664 1664
         {
1665 1665
             $message = $message
1666 1666
                 ?: sprintf(
@@ -1668,7 +1668,7 @@  discard block
 block discarded – undo
1668 1668
                     $this->stringify($key)
1669 1669
                 );
1670 1670
 
1671
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_PROPERTY_EXISTS, $fieldName, ['key' => $key]);
1671
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_PROPERTY_EXISTS, $fieldName, [ 'key' => $key ]);
1672 1672
         }
1673 1673
 
1674 1674
         return $this;
@@ -1685,22 +1685,22 @@  discard block
 block discarded – undo
1685 1685
      */
1686 1686
     public function propertiesExist(array $keys, string $message = '', string $fieldName = '') : Assert
1687 1687
     {
1688
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1688
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1689 1689
         {
1690 1690
             return $this;
1691 1691
         }
1692 1692
         $this->isObject($message, $fieldName);
1693
-        foreach ( $keys as $key )
1693
+        foreach ($keys as $key)
1694 1694
         {
1695 1695
             // Using isset to allow resolution of magically defined properties
1696
-            if ( !property_exists($this->value, $key) && !isset( $this->value->{$key} ) )
1696
+            if ( ! property_exists($this->value, $key) && ! isset($this->value->{$key} ))
1697 1697
             {
1698 1698
                 $message = $message
1699 1699
                     ?: sprintf(
1700 1700
                         'Object does not contain a property with key "%s"',
1701 1701
                         $this->stringify($key)
1702 1702
                     );
1703
-                throw $this->createException($message, $this->overrideCode ?: self::INVALID_PROPERTIES_EXIST, $fieldName, ['key' => $key]);
1703
+                throw $this->createException($message, $this->overrideCode ?: self::INVALID_PROPERTIES_EXIST, $fieldName, [ 'key' => $key ]);
1704 1704
             }
1705 1705
         }
1706 1706
 
@@ -1717,12 +1717,12 @@  discard block
 block discarded – undo
1717 1717
      */
1718 1718
     public function utf8(string $message = '', string $fieldName = '') : Assert
1719 1719
     {
1720
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1720
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1721 1721
         {
1722 1722
             return $this;
1723 1723
         }
1724 1724
         $this->string($message, $fieldName);
1725
-        if ( mb_detect_encoding($this->value, 'UTF-8', true) !== 'UTF-8' )
1725
+        if (mb_detect_encoding($this->value, 'UTF-8', true) !== 'UTF-8')
1726 1726
         {
1727 1727
             $message = $message
1728 1728
                 ?: sprintf(
@@ -1747,12 +1747,12 @@  discard block
 block discarded – undo
1747 1747
      */
1748 1748
     public function ascii(string $message = '', string $fieldName = '') : Assert
1749 1749
     {
1750
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1750
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1751 1751
         {
1752 1752
             return $this;
1753 1753
         }
1754 1754
         $this->string($message, $fieldName);
1755
-        if ( ! preg_match('/^[ -~]+$/', $this->value) )
1755
+        if ( ! preg_match('/^[ -~]+$/', $this->value))
1756 1756
         {
1757 1757
             $message = $message
1758 1758
                 ?: sprintf(
@@ -1778,12 +1778,12 @@  discard block
 block discarded – undo
1778 1778
      */
1779 1779
     public function keyIsset($key, string $message = '', string $fieldName = '') : Assert
1780 1780
     {
1781
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1781
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1782 1782
         {
1783 1783
             return $this;
1784 1784
         }
1785 1785
         $this->isArrayAccessible($message, $fieldName);
1786
-        if ( !isset( $this->value[$key] ) )
1786
+        if ( ! isset($this->value[ $key ]))
1787 1787
         {
1788 1788
             $message = $message ?: $this->overrideError;
1789 1789
             $message = sprintf(
@@ -1791,7 +1791,7 @@  discard block
 block discarded – undo
1791 1791
                 $this->stringify($key)
1792 1792
             );
1793 1793
 
1794
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEY_ISSET, $fieldName, ['key' => $key]);
1794
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEY_ISSET, $fieldName, [ 'key' => $key ]);
1795 1795
         }
1796 1796
 
1797 1797
         return $this;
@@ -1809,12 +1809,12 @@  discard block
 block discarded – undo
1809 1809
      */
1810 1810
     public function notEmptyKey($key, string $message = '', string $fieldName = '') : Assert
1811 1811
     {
1812
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1812
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1813 1813
         {
1814 1814
             return $this;
1815 1815
         }
1816 1816
         $this->keyIsset($key, $message, $fieldName);
1817
-        (new Assert($this->value[$key]))->setExceptionClass($this->exceptionClass)->notEmpty($message, $fieldName);
1817
+        (new Assert($this->value[ $key ]))->setExceptionClass($this->exceptionClass)->notEmpty($message, $fieldName);
1818 1818
 
1819 1819
         return $this;
1820 1820
     }
@@ -1829,11 +1829,11 @@  discard block
 block discarded – undo
1829 1829
      */
1830 1830
     public function notBlank(string $message = '', string $fieldName = '') : Assert
1831 1831
     {
1832
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1832
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1833 1833
         {
1834 1834
             return $this;
1835 1835
         }
1836
-        if ( false === $this->value || ( empty( $this->value ) && '0' != $this->value ) )
1836
+        if (false === $this->value || (empty($this->value) && '0' != $this->value))
1837 1837
         {
1838 1838
             $message = $message ?: $this->overrideError;
1839 1839
             $message = sprintf(
@@ -1858,11 +1858,11 @@  discard block
 block discarded – undo
1858 1858
      */
1859 1859
     public function isInstanceOf(string $className, string $message = '', string $fieldName = '') : Assert
1860 1860
     {
1861
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1861
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1862 1862
         {
1863 1863
             return $this;
1864 1864
         }
1865
-        if ( !( $this->value instanceof $className ) )
1865
+        if ( ! ($this->value instanceof $className))
1866 1866
         {
1867 1867
             $message = $message ?: $this->overrideError;
1868 1868
             $message = sprintf(
@@ -1871,7 +1871,7 @@  discard block
 block discarded – undo
1871 1871
                 $className
1872 1872
             );
1873 1873
 
1874
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_INSTANCE_OF, $fieldName, ['class' => $className]);
1874
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_INSTANCE_OF, $fieldName, [ 'class' => $className ]);
1875 1875
         }
1876 1876
 
1877 1877
         return $this;
@@ -1888,11 +1888,11 @@  discard block
 block discarded – undo
1888 1888
      */
1889 1889
     public function notIsInstanceOf(string $className, string $message = '', string $fieldName = '') : Assert
1890 1890
     {
1891
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1891
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1892 1892
         {
1893 1893
             return $this;
1894 1894
         }
1895
-        if ( $this->value instanceof $className )
1895
+        if ($this->value instanceof $className)
1896 1896
         {
1897 1897
             $message = $message ?: $this->overrideError;
1898 1898
             $message = sprintf(
@@ -1901,7 +1901,7 @@  discard block
 block discarded – undo
1901 1901
                 $className
1902 1902
             );
1903 1903
 
1904
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_INSTANCE_OF, $fieldName, ['class' => $className]);
1904
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_INSTANCE_OF, $fieldName, [ 'class' => $className ]);
1905 1905
         }
1906 1906
 
1907 1907
         return $this;
@@ -1918,11 +1918,11 @@  discard block
 block discarded – undo
1918 1918
      */
1919 1919
     public function subclassOf(string $className, string $message = '', string $fieldName = '') : Assert
1920 1920
     {
1921
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1921
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1922 1922
         {
1923 1923
             return $this;
1924 1924
         }
1925
-        if ( !is_subclass_of($this->value, $className) )
1925
+        if ( ! is_subclass_of($this->value, $className))
1926 1926
         {
1927 1927
             $message = $message ?: $this->overrideError;
1928 1928
             $message = sprintf(
@@ -1931,7 +1931,7 @@  discard block
 block discarded – undo
1931 1931
                 $className
1932 1932
             );
1933 1933
 
1934
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_SUBCLASS_OF, $fieldName, ['class' => $className]);
1934
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_SUBCLASS_OF, $fieldName, [ 'class' => $className ]);
1935 1935
         }
1936 1936
 
1937 1937
         return $this;
@@ -1949,12 +1949,12 @@  discard block
 block discarded – undo
1949 1949
      */
1950 1950
     public function range(float $minValue, float $maxValue, string $message = '', string $fieldName = '') : Assert
1951 1951
     {
1952
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1952
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1953 1953
         {
1954 1954
             return $this;
1955 1955
         }
1956 1956
         $this->numeric($message, $fieldName);
1957
-        if ( $this->value < $minValue || $this->value > $maxValue )
1957
+        if ($this->value < $minValue || $this->value > $maxValue)
1958 1958
         {
1959 1959
             $message = $message ?: $this->overrideError;
1960 1960
             $message = sprintf(
@@ -1984,12 +1984,12 @@  discard block
 block discarded – undo
1984 1984
      */
1985 1985
     public function min(int $minValue, string $message = '', string $fieldName = '') : Assert
1986 1986
     {
1987
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1987
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1988 1988
         {
1989 1989
             return $this;
1990 1990
         }
1991 1991
         $this->numeric($message, $fieldName);
1992
-        if ( $this->value < $minValue )
1992
+        if ($this->value < $minValue)
1993 1993
         {
1994 1994
             $message = $message ?: $this->overrideError;
1995 1995
             $message = sprintf(
@@ -1998,7 +1998,7 @@  discard block
 block discarded – undo
1998 1998
                 $this->stringify($minValue)
1999 1999
             );
2000 2000
 
2001
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_MIN, $fieldName, ['min' => $minValue]);
2001
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_MIN, $fieldName, [ 'min' => $minValue ]);
2002 2002
         }
2003 2003
 
2004 2004
         return $this;
@@ -2015,12 +2015,12 @@  discard block
 block discarded – undo
2015 2015
      */
2016 2016
     public function max(int $maxValue, string $message = '', string $fieldName = '') : Assert
2017 2017
     {
2018
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2018
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2019 2019
         {
2020 2020
             return $this;
2021 2021
         }
2022 2022
         $this->numeric($message, $fieldName);
2023
-        if ( $this->value > $maxValue )
2023
+        if ($this->value > $maxValue)
2024 2024
         {
2025 2025
             $message = $message ?: $this->overrideError;
2026 2026
             $message = sprintf(
@@ -2029,7 +2029,7 @@  discard block
 block discarded – undo
2029 2029
                 $this->stringify($maxValue)
2030 2030
             );
2031 2031
 
2032
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_MAX, $fieldName, ['max' => $maxValue]);
2032
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_MAX, $fieldName, [ 'max' => $maxValue ]);
2033 2033
         }
2034 2034
 
2035 2035
         return $this;
@@ -2045,13 +2045,13 @@  discard block
 block discarded – undo
2045 2045
      */
2046 2046
     public function file(string $message = '', string $fieldName = '') : Assert
2047 2047
     {
2048
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2048
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2049 2049
         {
2050 2050
             return $this;
2051 2051
         }
2052 2052
         $this->string($message, $fieldName);
2053 2053
         $this->notEmpty($message, $fieldName);
2054
-        if ( !is_file($this->value) )
2054
+        if ( ! is_file($this->value))
2055 2055
         {
2056 2056
             $message = $message ?: $this->overrideError;
2057 2057
             $message = sprintf(
@@ -2075,13 +2075,13 @@  discard block
 block discarded – undo
2075 2075
      */
2076 2076
     public function fileOrDirectoryExists(string $message = '', string $fieldName = '') : Assert
2077 2077
     {
2078
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2078
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2079 2079
         {
2080 2080
             return $this;
2081 2081
         }
2082 2082
         $this->string($message, $fieldName);
2083 2083
         $this->notEmpty($message, $fieldName);
2084
-        if ( ! file_exists($this->value) )
2084
+        if ( ! file_exists($this->value))
2085 2085
         {
2086 2086
             $message = $message ?: $this->overrideError;
2087 2087
             $message = sprintf(
@@ -2105,12 +2105,12 @@  discard block
 block discarded – undo
2105 2105
      */
2106 2106
     public function directory(string $message = '', string $fieldName = '') : Assert
2107 2107
     {
2108
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2108
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2109 2109
         {
2110 2110
             return $this;
2111 2111
         }
2112 2112
         $this->string($message, $fieldName);
2113
-        if ( !is_dir($this->value) )
2113
+        if ( ! is_dir($this->value))
2114 2114
         {
2115 2115
             $message = $message ?: $this->overrideError;
2116 2116
             $message = sprintf(
@@ -2134,12 +2134,12 @@  discard block
 block discarded – undo
2134 2134
      */
2135 2135
     public function readable(string $message = '', string $fieldName = '') : Assert
2136 2136
     {
2137
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2137
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2138 2138
         {
2139 2139
             return $this;
2140 2140
         }
2141 2141
         $this->string($message, $fieldName);
2142
-        if ( !is_readable($this->value) )
2142
+        if ( ! is_readable($this->value))
2143 2143
         {
2144 2144
             $message = $message ?: $this->overrideError;
2145 2145
             $message = sprintf(
@@ -2163,12 +2163,12 @@  discard block
 block discarded – undo
2163 2163
      */
2164 2164
     public function writeable(string $message = '', string $fieldName = '') : Assert
2165 2165
     {
2166
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2166
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2167 2167
         {
2168 2168
             return $this;
2169 2169
         }
2170 2170
         $this->string($message, $fieldName);
2171
-        if ( !is_writeable($this->value) )
2171
+        if ( ! is_writeable($this->value))
2172 2172
         {
2173 2173
             $message = $message ?: $this->overrideError;
2174 2174
             $message = sprintf(
@@ -2192,12 +2192,12 @@  discard block
 block discarded – undo
2192 2192
      */
2193 2193
     public function email(string $message = '', string $fieldName = '') : Assert
2194 2194
     {
2195
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2195
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2196 2196
         {
2197 2197
             return $this;
2198 2198
         }
2199 2199
         $this->string($message, $fieldName);
2200
-        if ( ! filter_var($this->value, FILTER_VALIDATE_EMAIL) )
2200
+        if ( ! filter_var($this->value, FILTER_VALIDATE_EMAIL))
2201 2201
         {
2202 2202
             $message = $message ?: $this->overrideError;
2203 2203
             $message = sprintf(
@@ -2211,7 +2211,7 @@  discard block
 block discarded – undo
2211 2211
         {
2212 2212
             $host = substr($this->value, strpos($this->value, '@') + 1);
2213 2213
             // Likely not a FQDN, bug in PHP FILTER_VALIDATE_EMAIL prior to PHP 5.3.3
2214
-            if ( version_compare(PHP_VERSION, '5.3.3', '<') && strpos($host, '.') === false )
2214
+            if (version_compare(PHP_VERSION, '5.3.3', '<') && strpos($host, '.') === false)
2215 2215
             {
2216 2216
                 $message = $message ?: $this->overrideError;
2217 2217
                 $message = sprintf(
@@ -2235,7 +2235,7 @@  discard block
 block discarded – undo
2235 2235
      */
2236 2236
     public function emailPrefix(string $message = '', string $fieldName = '') : Assert
2237 2237
     {
2238
-        $this->value($this->value . '@example.com');
2238
+        $this->value($this->value.'@example.com');
2239 2239
 
2240 2240
         return $this->email($message, $fieldName);
2241 2241
     }
@@ -2256,12 +2256,12 @@  discard block
 block discarded – undo
2256 2256
      */
2257 2257
     public function url(string $message = '', string $fieldName = '') : Assert
2258 2258
     {
2259
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2259
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2260 2260
         {
2261 2261
             return $this;
2262 2262
         }
2263 2263
         $this->string($message, $fieldName);
2264
-        $protocols = ['http', 'https'];
2264
+        $protocols = [ 'http', 'https' ];
2265 2265
         $pattern   = '~^
2266 2266
             (%s)://                                 # protocol
2267 2267
             (
@@ -2276,8 +2276,8 @@  discard block
 block discarded – undo
2276 2276
             (:[0-9]+)?                              # a port (optional)
2277 2277
             (/?|/\S+)                               # a /, nothing or a / with something
2278 2278
         $~ixu';
2279
-        $pattern   = sprintf($pattern, implode('|', $protocols));
2280
-        if ( !preg_match($pattern, $this->value) )
2279
+        $pattern = sprintf($pattern, implode('|', $protocols));
2280
+        if ( ! preg_match($pattern, $this->value))
2281 2281
         {
2282 2282
             $message = $message ?: $this->overrideError;
2283 2283
             $message = sprintf(
@@ -2304,13 +2304,13 @@  discard block
 block discarded – undo
2304 2304
      */
2305 2305
     public function domainName(string $message = '', string $fieldName = '') : Assert
2306 2306
     {
2307
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2307
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2308 2308
         {
2309 2309
             return $this;
2310 2310
         }
2311 2311
         $this->string($message, $fieldName);
2312
-        $pattern   = '/^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}$/';
2313
-        if ( ! preg_match($pattern, $this->value) )
2312
+        $pattern = '/^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}$/';
2313
+        if ( ! preg_match($pattern, $this->value))
2314 2314
         {
2315 2315
             $message = $message ?: $this->overrideError;
2316 2316
             $message = sprintf(
@@ -2334,7 +2334,7 @@  discard block
 block discarded – undo
2334 2334
      */
2335 2335
     public function ausMobile(string $message = '', string $fieldName = '') : Assert
2336 2336
     {
2337
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2337
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2338 2338
         {
2339 2339
             return $this;
2340 2340
         }
@@ -2342,7 +2342,7 @@  discard block
 block discarded – undo
2342 2342
         {
2343 2343
             $this->regex('/^04[0-9]{8})$/', $message, $fieldName);
2344 2344
         }
2345
-        catch ( AssertionFailedException $e )
2345
+        catch (AssertionFailedException $e)
2346 2346
         {
2347 2347
             $message = $message ?: $this->overrideError;
2348 2348
             $message = sprintf(
@@ -2367,7 +2367,7 @@  discard block
 block discarded – undo
2367 2367
      */
2368 2368
     public function alnum(string $message = '', string $fieldName = '') : Assert
2369 2369
     {
2370
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2370
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2371 2371
         {
2372 2372
             return $this;
2373 2373
         }
@@ -2400,11 +2400,11 @@  discard block
 block discarded – undo
2400 2400
      */
2401 2401
     public function true(string $message = '', string $fieldName = '') : Assert
2402 2402
     {
2403
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2403
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2404 2404
         {
2405 2405
             return $this;
2406 2406
         }
2407
-        if ( $this->value !== true )
2407
+        if ($this->value !== true)
2408 2408
         {
2409 2409
             $message = $message ?: $this->overrideError;
2410 2410
             $message = sprintf(
@@ -2428,11 +2428,11 @@  discard block
 block discarded – undo
2428 2428
      */
2429 2429
     public function truthy(string $message = '', string $fieldName = '') : Assert
2430 2430
     {
2431
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2431
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2432 2432
         {
2433 2433
             return $this;
2434 2434
         }
2435
-        if ( ! $this->value )
2435
+        if ( ! $this->value)
2436 2436
         {
2437 2437
             $message = $message ?: $this->overrideError;
2438 2438
             $message = sprintf(
@@ -2456,11 +2456,11 @@  discard block
 block discarded – undo
2456 2456
      */
2457 2457
     public function false(string $message = '', string $fieldName = '') : Assert
2458 2458
     {
2459
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2459
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2460 2460
         {
2461 2461
             return $this;
2462 2462
         }
2463
-        if ( $this->value !== false )
2463
+        if ($this->value !== false)
2464 2464
         {
2465 2465
             $message = $message ?: $this->overrideError;
2466 2466
             $message = sprintf(
@@ -2484,11 +2484,11 @@  discard block
 block discarded – undo
2484 2484
      */
2485 2485
     public function notFalse(string $message = '', string $fieldName = '') : Assert
2486 2486
     {
2487
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2487
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2488 2488
         {
2489 2489
             return $this;
2490 2490
         }
2491
-        if ( $this->value === false )
2491
+        if ($this->value === false)
2492 2492
         {
2493 2493
             $message = $message ?: $this->overrideError;
2494 2494
             $message = sprintf(
@@ -2512,11 +2512,11 @@  discard block
 block discarded – undo
2512 2512
      */
2513 2513
     public function classExists(string $message = '', string $fieldName = '') : Assert
2514 2514
     {
2515
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2515
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2516 2516
         {
2517 2517
             return $this;
2518 2518
         }
2519
-        if ( !class_exists($this->value) )
2519
+        if ( ! class_exists($this->value))
2520 2520
         {
2521 2521
             $message = $message ?: $this->overrideError;
2522 2522
             $message = sprintf(
@@ -2540,12 +2540,12 @@  discard block
 block discarded – undo
2540 2540
      */
2541 2541
     public function implementsInterface(string $interfaceName, string $message = '', string $fieldName = '') : Assert
2542 2542
     {
2543
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2543
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2544 2544
         {
2545 2545
             return $this;
2546 2546
         }
2547 2547
         $reflection = new \ReflectionClass($this->value);
2548
-        if ( !$reflection->implementsInterface($interfaceName) )
2548
+        if ( ! $reflection->implementsInterface($interfaceName))
2549 2549
         {
2550 2550
             $message = $message ?: $this->overrideError;
2551 2551
             $message = sprintf(
@@ -2554,7 +2554,7 @@  discard block
 block discarded – undo
2554 2554
                 $this->stringify($interfaceName)
2555 2555
             );
2556 2556
 
2557
-            throw $this->createException($message, self::INTERFACE_NOT_IMPLEMENTED, $fieldName, ['interface' => $interfaceName]);
2557
+            throw $this->createException($message, self::INTERFACE_NOT_IMPLEMENTED, $fieldName, [ 'interface' => $interfaceName ]);
2558 2558
         }
2559 2559
 
2560 2560
         return $this;
@@ -2576,11 +2576,11 @@  discard block
 block discarded – undo
2576 2576
      */
2577 2577
     public function isJsonString(string $message = '', string $fieldName = '') : Assert
2578 2578
     {
2579
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2579
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2580 2580
         {
2581 2581
             return $this;
2582 2582
         }
2583
-        if ( null === json_decode($this->value) && JSON_ERROR_NONE !== json_last_error() )
2583
+        if (null === json_decode($this->value) && JSON_ERROR_NONE !== json_last_error())
2584 2584
         {
2585 2585
             $message = $message ?: $this->overrideError;
2586 2586
             $message = sprintf(
@@ -2606,16 +2606,16 @@  discard block
 block discarded – undo
2606 2606
      */
2607 2607
     public function uuid(string $message = '', string $fieldName = '') : Assert
2608 2608
     {
2609
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2609
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2610 2610
         {
2611 2611
             return $this;
2612 2612
         }
2613
-        $this->value = str_replace(['urn:', 'uuid:', '{', '}'], '', $this->value);
2614
-        if ( $this->value === '00000000-0000-0000-0000-000000000000' )
2613
+        $this->value = str_replace([ 'urn:', 'uuid:', '{', '}' ], '', $this->value);
2614
+        if ($this->value === '00000000-0000-0000-0000-000000000000')
2615 2615
         {
2616 2616
             return $this;
2617 2617
         }
2618
-        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) )
2618
+        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))
2619 2619
         {
2620 2620
             $message = $message ?: $this->overrideError;
2621 2621
             $message = sprintf(
@@ -2646,11 +2646,11 @@  discard block
 block discarded – undo
2646 2646
      */
2647 2647
     public function samAccountName(string $message = '', string $fieldName = '') : Assert
2648 2648
     {
2649
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2649
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2650 2650
         {
2651 2651
             return $this;
2652 2652
         }
2653
-        if ( !preg_match('/^([a-z0-9]{4,20})$/', $this->value) )
2653
+        if ( ! preg_match('/^([a-z0-9]{4,20})$/', $this->value))
2654 2654
         {
2655 2655
             $message = $message ?: $this->overrideError;
2656 2656
             $message = sprintf(
@@ -2674,7 +2674,7 @@  discard block
 block discarded – undo
2674 2674
      */
2675 2675
     public function userPrincipalName(string $message = '', string $fieldName = '') : Assert
2676 2676
     {
2677
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2677
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2678 2678
         {
2679 2679
             return $this;
2680 2680
         }
@@ -2708,11 +2708,11 @@  discard block
 block discarded – undo
2708 2708
      */
2709 2709
     public function count(int $count, string $message = '', string $fieldName = '') : Assert
2710 2710
     {
2711
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2711
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2712 2712
         {
2713 2713
             return $this;
2714 2714
         }
2715
-        if ( $count !== count($this->value) )
2715
+        if ($count !== count($this->value))
2716 2716
         {
2717 2717
             $message = $message ?: $this->overrideError;
2718 2718
             $message = sprintf(
@@ -2721,7 +2721,7 @@  discard block
 block discarded – undo
2721 2721
                 $this->stringify($count)
2722 2722
             );
2723 2723
 
2724
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_COUNT, $fieldName, ['count' => $count]);
2724
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_COUNT, $fieldName, [ 'count' => $count ]);
2725 2725
         }
2726 2726
 
2727 2727
         return $this;
@@ -2735,25 +2735,25 @@  discard block
 block discarded – undo
2735 2735
      */
2736 2736
     protected function doAllOrNullOr($func, $args) : bool
2737 2737
     {
2738
-        if ( $this->nullOr && is_null($this->value) )
2738
+        if ($this->nullOr && is_null($this->value))
2739 2739
         {
2740 2740
             return true;
2741 2741
         }
2742
-        if ( $this->emptyOr && empty($this->value) )
2742
+        if ($this->emptyOr && empty($this->value))
2743 2743
         {
2744 2744
             return true;
2745 2745
         }
2746
-        if ( $this->all && (new Assert($this->value))->setExceptionClass($this->exceptionClass)->isTraversable() )
2746
+        if ($this->all && (new Assert($this->value))->setExceptionClass($this->exceptionClass)->isTraversable())
2747 2747
         {
2748
-            foreach ( $this->value as $idx => $value )
2748
+            foreach ($this->value as $idx => $value)
2749 2749
             {
2750 2750
                 $object = (new Assert($value))->setExceptionClass($this->exceptionClass);
2751
-                call_user_func_array([$object, $func], $args);
2751
+                call_user_func_array([ $object, $func ], $args);
2752 2752
             }
2753 2753
             return true;
2754 2754
         }
2755 2755
 
2756
-        return ( $this->nullOr && is_null($this->value) ) || ( $this->emptyOr && empty($this->value) ) ? true : false;
2756
+        return ($this->nullOr && is_null($this->value)) || ($this->emptyOr && empty($this->value)) ? true : false;
2757 2757
     }
2758 2758
 
2759 2759
     /**
@@ -2767,12 +2767,12 @@  discard block
 block discarded – undo
2767 2767
      */
2768 2768
     public function choicesNotEmpty(array $choices, string $message = '', string $fieldName = '') : Assert
2769 2769
     {
2770
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2770
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2771 2771
         {
2772 2772
             return $this;
2773 2773
         }
2774 2774
         $this->notEmpty($message, $fieldName);
2775
-        foreach ( $choices as $choice )
2775
+        foreach ($choices as $choice)
2776 2776
         {
2777 2777
             $this->notEmptyKey($choice, $message, $fieldName);
2778 2778
         }
@@ -2791,12 +2791,12 @@  discard block
 block discarded – undo
2791 2791
      */
2792 2792
     public function methodExists($object, string $message = '', string $fieldName = '') : Assert
2793 2793
     {
2794
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2794
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2795 2795
         {
2796 2796
             return $this;
2797 2797
         }
2798 2798
         (new Assert($object))->setExceptionClass($this->exceptionClass)->isObject($message, $fieldName);
2799
-        if ( !method_exists($object, $this->value) )
2799
+        if ( ! method_exists($object, $this->value))
2800 2800
         {
2801 2801
             $message = $message ?: $this->overrideError;
2802 2802
             $message = sprintf(
@@ -2820,11 +2820,11 @@  discard block
 block discarded – undo
2820 2820
      */
2821 2821
     public function isObject(string $message = '', string $fieldName = '') : Assert
2822 2822
     {
2823
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2823
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2824 2824
         {
2825 2825
             return $this;
2826 2826
         }
2827
-        if ( !is_object($this->value) )
2827
+        if ( ! is_object($this->value))
2828 2828
         {
2829 2829
             $message = $message ?: $this->overrideError;
2830 2830
             $message = sprintf(
@@ -2846,32 +2846,32 @@  discard block
 block discarded – undo
2846 2846
      */
2847 2847
     private function stringify($value) : string
2848 2848
     {
2849
-        if ( is_bool($value) )
2849
+        if (is_bool($value))
2850 2850
         {
2851 2851
             return $value ? '<TRUE>' : '<FALSE>';
2852 2852
         }
2853
-        if ( is_scalar($value) )
2853
+        if (is_scalar($value))
2854 2854
         {
2855 2855
             $val = (string)$value;
2856
-            if ( strlen($val) > 100 )
2856
+            if (strlen($val) > 100)
2857 2857
             {
2858
-                $val = substr($val, 0, 97) . '...';
2858
+                $val = substr($val, 0, 97).'...';
2859 2859
             }
2860 2860
             return $val;
2861 2861
         }
2862
-        if ( is_array($value) )
2862
+        if (is_array($value))
2863 2863
         {
2864 2864
             return '<ARRAY>';
2865 2865
         }
2866
-        if ( is_object($value) )
2866
+        if (is_object($value))
2867 2867
         {
2868 2868
             return get_class($value);
2869 2869
         }
2870
-        if ( is_resource($value) )
2870
+        if (is_resource($value))
2871 2871
         {
2872 2872
             return '<RESOURCE>';
2873 2873
         }
2874
-        if ( $value === null )
2874
+        if ($value === null)
2875 2875
         {
2876 2876
             return '<NULL>';
2877 2877
         }
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 = '', $value, array $constraints=[], string $level='critical', string $propertyPath = '')
43
+    public function __construct(string $message, int $code, string $fieldName = '', $value, array $constraints = [ ], string $level = 'critical', string $propertyPath = '')
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'] ??0?: '';
58
-            if ( $class !== 'Terah\\Assert\\Assert' )
57
+            $class = $point[ 'class' ] ??0 ?: '';
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.