| @@ -1,7 +1,7 @@ discard block | ||
| 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 | ||
| 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 | |
| @@ -1,4 +1,4 @@ | ||
| 1 | -<?php declare(strict_types=1); | |
| 1 | +<?php declare(strict_types = 1); | |
| 2 | 2 | |
| 3 | 3 | namespace Terah\Assert; | 
| 4 | 4 | |
| @@ -158,8 +158,7 @@ discard block | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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( | 
| @@ -1,4 +1,4 @@ discard block | ||
| 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 | ||
| 134 | 134 | * | 
| 135 | 135 | * @var string | 
| 136 | 136 | */ | 
| 137 | - protected $exceptionClass = AssertionFailedException::class; | |
| 137 | + protected $exceptionClass = AssertionFailedException::class; | |
| 138 | 138 | |
| 139 | 139 | /** | 
| 140 | 140 | * @param mixed $value | 
| @@ -151,17 +151,17 @@ discard block | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | } | 
| @@ -534,7 +534,7 @@ discard block | ||
| 534 | 534 | /** | 
| 535 | 535 | * Assert that value is not equal to a provided value (using == ). | 
| 536 | 536 | * | 
| 537 | - * @param mixed $value2 | |
| 537 | + * @param string $value2 | |
| 538 | 538 | * @param string $message | 
| 539 | 539 | * @param string $fieldName | 
| 540 | 540 | * @return Assert | 
| @@ -1408,7 +1408,7 @@ discard block | ||
| 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 | 
| @@ -1585,7 +1585,7 @@ discard block | ||
| 1585 | 1585 | /** | 
| 1586 | 1586 | * Assert that key exists in the values array. | 
| 1587 | 1587 | * | 
| 1588 | - * @param string|integer $key | |
| 1588 | + * @param string $key | |
| 1589 | 1589 | * @param string $message | 
| 1590 | 1590 | * @param string $fieldName | 
| 1591 | 1591 | * @return Assert | 
| @@ -2728,7 +2728,7 @@ discard block | ||
| 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 | 
| @@ -42,7 +42,7 @@ discard block | ||
| 42 | 42 | * @param Closure $test | 
| 43 | 43 | * @param string $suiteName | 
| 44 | 44 | * @param string $successMessage | 
| 45 | - * @param int|null $exceptionCode | |
| 45 | + * @param integer $exceptionCode | |
| 46 | 46 | * @param string $exceptionClass | 
| 47 | 47 | * @return Suite | 
| 48 | 48 | * @throws AssertionFailedException | 
| @@ -166,7 +166,7 @@ discard block | ||
| 166 | 166 | * @param string $testName | 
| 167 | 167 | * @param Closure $test | 
| 168 | 168 | * @param string $successMessage | 
| 169 | - * @param int|null $exceptionCode | |
| 169 | + * @param integer $exceptionCode | |
| 170 | 170 | * @param string $exceptionClass | 
| 171 | 171 | * @return Suite | 
| 172 | 172 | * @throws AssertionFailedException | 
| @@ -251,7 +251,7 @@ discard block | ||
| 251 | 251 | * @param string $testName | 
| 252 | 252 | * @param Closure $test | 
| 253 | 253 | * @param string $successMessage | 
| 254 | - * @param int|null $exceptionCode | |
| 254 | + * @param integer $exceptionCode | |
| 255 | 255 | * @param string $exceptionClass | 
| 256 | 256 | * @throws AssertionFailedException | 
| 257 | 257 | */ | 
| @@ -707,8 +707,8 @@ discard block | ||
| 707 | 707 | /** | 
| 708 | 708 | * Log messages to resource | 
| 709 | 709 | * | 
| 710 | - * @param mixed $level The level of the log message | |
| 711 | - * @param string|object $message If an object is passed it must implement __toString() | |
| 710 | + * @param string $level The level of the log message | |
| 711 | + * @param string $message If an object is passed it must implement __toString() | |
| 712 | 712 | * @param array $context Placeholders to be substituted in the message | 
| 713 | 713 | */ | 
| 714 | 714 | public function log($level, $message, array $context=[]) | 
| @@ -784,7 +784,7 @@ discard block | ||
| 784 | 784 | } | 
| 785 | 785 | |
| 786 | 786 | /** | 
| 787 | - * @return mixed|resource | |
| 787 | + * @return resource | |
| 788 | 788 | * @throws \Exception | 
| 789 | 789 | */ | 
| 790 | 790 | protected function getResource() | 
| @@ -132,8 +132,7 @@ discard block | ||
| 132 | 132 |                  $this->getLogger()->info("[{$testName}] - Starting..."); | 
| 133 | 133 | $testCase->runTest($this); | 
| 134 | 134 |                  $this->getLogger()->info("[{$testName}] - " . $testCase->getSuccessMessage()); | 
| 135 | - } | |
| 136 | - catch ( \Exception $e ) | |
| 135 | + } catch ( \Exception $e ) | |
| 137 | 136 |              { | 
| 138 | 137 | $expectedCode = $testCase->getExceptionCode(); | 
| 139 | 138 | $expectedClass = $testCase->getExceptionType(); | 
| @@ -723,8 +722,7 @@ discard block | ||
| 723 | 722 | if ( is_callable($this->formatter) ) | 
| 724 | 723 |          { | 
| 725 | 724 | $message = $this->formatter->__invoke(static::$logLevels[$level][4], $message, $context); | 
| 726 | - } | |
| 727 | - else | |
| 725 | + } else | |
| 728 | 726 |          { | 
| 729 | 727 | $message = $this->formatMessage($level, $message, $context); | 
| 730 | 728 | } | 
| @@ -1,4 +1,4 @@ discard block | ||
| 1 | -<?php declare(strict_types=1); | |
| 1 | +<?php declare(strict_types = 1); | |
| 2 | 2 | |
| 3 | 3 | namespace Terah\Assert; | 
| 4 | 4 | |
| @@ -12,7 +12,7 @@ discard block | ||
| 12 | 12 | protected static $currentSuite = self::DEFAULT_SUITE; | 
| 13 | 13 | |
| 14 | 14 | /** @var Suite[] */ | 
| 15 | - protected static $suites = []; | |
| 15 | + protected static $suites = [ ]; | |
| 16 | 16 | |
| 17 | 17 | /** @var Logger $logger */ | 
| 18 | 18 | public static $logger = null; | 
| @@ -29,12 +29,12 @@ discard block | ||
| 29 | 29 | * @param string $suiteName | 
| 30 | 30 | * @return Suite | 
| 31 | 31 | */ | 
| 32 | - public static function suite(string $suiteName='') : Suite | |
| 32 | + public static function suite(string $suiteName = '') : Suite | |
| 33 | 33 |      { | 
| 34 | 34 | $suiteName = $suiteName ?: static::$currentSuite; | 
| 35 | - static::$suites[$suiteName] = new Suite(); | |
| 35 | + static::$suites[ $suiteName ] = new Suite(); | |
| 36 | 36 | |
| 37 | - return static::$suites[$suiteName]; | |
| 37 | + return static::$suites[ $suiteName ]; | |
| 38 | 38 | } | 
| 39 | 39 | |
| 40 | 40 | /** | 
| @@ -47,7 +47,7 @@ discard block | ||
| 47 | 47 | * @return Suite | 
| 48 | 48 | * @throws AssertionFailedException | 
| 49 | 49 | */ | 
| 50 | - public static function test(string $testName, Closure $test, string $suiteName='', string $successMessage='', int $exceptionCode=0, string $exceptionClass='') : Suite | |
| 50 | + public static function test(string $testName, Closure $test, string $suiteName = '', string $successMessage = '', int $exceptionCode = 0, string $exceptionClass = '') : Suite | |
| 51 | 51 |      { | 
| 52 | 52 | Assert::that($successMessage)->notEmpty(); | 
| 53 | 53 | Assert::that($test)->isCallable(); | 
| @@ -61,17 +61,17 @@ discard block | ||
| 61 | 61 | * @param string $testName | 
| 62 | 62 | * @return array | 
| 63 | 63 | */ | 
| 64 | - public static function run(string $suiteName='', string $testName='') : array | |
| 64 | + public static function run(string $suiteName = '', string $testName = '') : array | |
| 65 | 65 |      { | 
| 66 | 66 | $totalFailed = 0; | 
| 67 | 67 | $totalTests = 0; | 
| 68 | 68 | $suites = static::$suites; | 
| 69 | - if ( ! empty($suiteName) ) | |
| 69 | + if ( ! empty($suiteName)) | |
| 70 | 70 |          { | 
| 71 | 71 |              Assert::that($suites)->keyExists($suiteName, "The test suite ({$suiteName}) has not been loaded"); | 
| 72 | - $suites = [$suites[$suiteName]]; | |
| 72 | + $suites = [ $suites[ $suiteName ] ]; | |
| 73 | 73 | } | 
| 74 | - foreach ( $suites as $suite ) | |
| 74 | + foreach ($suites as $suite) | |
| 75 | 75 |          { | 
| 76 | 76 | $totalFailed += $suite->run($testName); | 
| 77 | 77 | $totalTests += $suite->totalTestsCount(); | 
| @@ -85,7 +85,7 @@ discard block | ||
| 85 | 85 | */ | 
| 86 | 86 | public static function getLogger() : Logger | 
| 87 | 87 |      { | 
| 88 | - if ( ! static::$logger ) | |
| 88 | + if ( ! static::$logger) | |
| 89 | 89 |          { | 
| 90 | 90 | static::$logger = new Logger(); | 
| 91 | 91 | } | 
| @@ -97,15 +97,15 @@ discard block | ||
| 97 | 97 | * @param string $suiteName | 
| 98 | 98 | * @return Suite | 
| 99 | 99 | */ | 
| 100 | - protected static function getSuite(string $suiteName='') : Suite | |
| 100 | + protected static function getSuite(string $suiteName = '') : Suite | |
| 101 | 101 |      { | 
| 102 | - $suiteName = $suiteName ?: static::$currentSuite; | |
| 103 | - if ( ! array_key_exists($suiteName, static::$suites) ) | |
| 102 | + $suiteName = $suiteName ?: static::$currentSuite; | |
| 103 | + if ( ! array_key_exists($suiteName, static::$suites)) | |
| 104 | 104 |          { | 
| 105 | 105 | return static::suite($suiteName); | 
| 106 | 106 | } | 
| 107 | 107 | |
| 108 | - return static::$suites[$suiteName]; | |
| 108 | + return static::$suites[ $suiteName ]; | |
| 109 | 109 | } | 
| 110 | 110 | |
| 111 | 111 | |
| @@ -122,22 +122,22 @@ discard block | ||
| 122 | 122 | |
| 123 | 123 | $className = array_values(array_diff_key(get_declared_classes(), $declaredClasses)); | 
| 124 | 124 | |
| 125 | - $reflectionClass = new \ReflectionClass($className[0]); | |
| 125 | + $reflectionClass = new \ReflectionClass($className[ 0 ]); | |
| 126 | 126 | $publicMethods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC); | 
| 127 | 127 | $fullClassName = $reflectionClass->getName(); | 
| 128 | 128 | $className = $reflectionClass->getShortName(); | 
| 129 | 129 | $namespace = $reflectionClass->getNamespaceName(); | 
| 130 | 130 | $constructorParams = ''; | 
| 131 | - foreach ( $publicMethods as $method ) | |
| 131 | + foreach ($publicMethods as $method) | |
| 132 | 132 |          { | 
| 133 | - if ( $method->isConstructor() ) | |
| 133 | + if ($method->isConstructor()) | |
| 134 | 134 |              { | 
| 135 | - $constructorParams = static::getMethodParams($method); | |
| 135 | + $constructorParams = static::getMethodParams($method); | |
| 136 | 136 | } | 
| 137 | 137 | } | 
| 138 | 138 |          $objectInit         = "new {$fullClassName}({$constructorParams})"; | 
| 139 | - $output = []; | |
| 140 | - $output[] = <<<PHP | |
| 139 | + $output = [ ]; | |
| 140 | + $output[ ] = <<<PHP | |
| 141 | 141 | <?php declare(strict_types=1); | 
| 142 | 142 | |
| 143 | 143 |  namespace {$namespace}\Test; | 
| @@ -151,22 +151,22 @@ discard block | ||
| 151 | 151 |      ->fixture('testSubject', {$objectInit}) | 
| 152 | 152 | PHP; | 
| 153 | 153 | |
| 154 | - foreach ( $publicMethods as $method ) | |
| 154 | + foreach ($publicMethods as $method) | |
| 155 | 155 |          { | 
| 156 | 156 | $methodName = $method->getName(); | 
| 157 | 157 | $methodParams = static::getMethodParams($method); | 
| 158 | - $testName = 'test' . ucfirst($methodName); | |
| 158 | + $testName = 'test'.ucfirst($methodName); | |
| 159 | 159 | $successArgs = static::getMethodArgs($method); | 
| 160 | 160 | $failArgs = static::getMethodArgs($method, ' '); | 
| 161 | 161 | $returnVal = static::getReturnVal($method); | 
| 162 | 162 |              $methodSignature    = "\$suite->getFixture('testSubject')->{$methodName}({$methodParams})"; | 
| 163 | 163 | |
| 164 | - if ( $method->isStatic() ) | |
| 164 | + if ($method->isStatic()) | |
| 165 | 165 |              { | 
| 166 | 166 |                  $methodSignature = "{$className}::{$methodName}({$methodParams})"; | 
| 167 | 167 | } | 
| 168 | 168 | |
| 169 | - $output[] = <<<PHP | |
| 169 | + $output[ ] = <<<PHP | |
| 170 | 170 | |
| 171 | 171 |      ->test('{$testName}Success', function(Suite \$suite) { | 
| 172 | 172 | |
| @@ -190,7 +190,7 @@ discard block | ||
| 190 | 190 | |
| 191 | 191 | } | 
| 192 | 192 | |
| 193 | - $output[] = " ;"; | |
| 193 | + $output[ ] = " ;"; | |
| 194 | 194 | |
| 195 | 195 |          return static::createDirectoriesAndSaveFile($outputPath, implode("\n", $output)); | 
| 196 | 196 | } | 
| @@ -203,7 +203,7 @@ discard block | ||
| 203 | 203 | * @param int $dirMode | 
| 204 | 204 | * @return bool | 
| 205 | 205 | */ | 
| 206 | - protected static function createDirectoriesAndSaveFile(string $filePath, $data, $flags=0, $dirMode=0755) : bool | |
| 206 | + protected static function createDirectoriesAndSaveFile(string $filePath, $data, $flags = 0, $dirMode = 0755) : bool | |
| 207 | 207 |      { | 
| 208 | 208 | static::createParentDirectories($filePath, $dirMode); | 
| 209 | 209 |          Assert::that(file_put_contents($filePath, $data, $flags))->notFalse("Failed to put contents in file ({$filePath})"); | 
| @@ -216,13 +216,13 @@ discard block | ||
| 216 | 216 | * @param int $mode | 
| 217 | 217 | * @return bool | 
| 218 | 218 | */ | 
| 219 | - protected static function createParentDirectories(string $filePath, $mode=0755) : bool | |
| 219 | + protected static function createParentDirectories(string $filePath, $mode = 0755) : bool | |
| 220 | 220 |      { | 
| 221 | -        $directoryPath  = preg_match('/.*\//', $filePath); | |
| 221 | +        $directoryPath = preg_match('/.*\//', $filePath); | |
| 222 | 222 | Assert::that($filePath) | 
| 223 | 223 |              ->notEmpty("Failed to identify path ({$directoryPath}) to create") | 
| 224 | 224 |              ->notEq(DIRECTORY_SEPARATOR, "Failed to identify path ({$directoryPath}) to create"); | 
| 225 | - if ( file_exists($directoryPath) ) | |
| 225 | + if (file_exists($directoryPath)) | |
| 226 | 226 |          { | 
| 227 | 227 |              Assert::that(is_dir($directoryPath))->notFalse("Failed to create parent directories.. files exists and is not a directory({$directoryPath})"); | 
| 228 | 228 | |
| @@ -240,10 +240,10 @@ discard block | ||
| 240 | 240 | */ | 
| 241 | 241 | protected static function getMethodParams(\ReflectionMethod $method) : string | 
| 242 | 242 |      { | 
| 243 | - $output = []; | |
| 244 | - foreach ( $method->getParameters() as $param ) | |
| 243 | + $output = [ ]; | |
| 244 | + foreach ($method->getParameters() as $param) | |
| 245 | 245 |          { | 
| 246 | - $output[] = '$' . $param->getName(); | |
| 246 | + $output[ ] = '$'.$param->getName(); | |
| 247 | 247 | } | 
| 248 | 248 | |
| 249 | 249 |          return implode(', ', $output); | 
| @@ -254,16 +254,16 @@ discard block | ||
| 254 | 254 | * @param string $extraPadding | 
| 255 | 255 | * @return string | 
| 256 | 256 | */ | 
| 257 | - protected static function getMethodArgs(\ReflectionMethod $method, string $extraPadding='') : string | |
| 257 | + protected static function getMethodArgs(\ReflectionMethod $method, string $extraPadding = '') : string | |
| 258 | 258 |      { | 
| 259 | - $output = []; | |
| 259 | + $output = [ ]; | |
| 260 | 260 | $params = $method->getParameters(); | 
| 261 | - foreach ( $params as $param ) | |
| 261 | + foreach ($params as $param) | |
| 262 | 262 |          { | 
| 263 | 263 | $type = $param->hasType() ? $param->getType()->_toString() : ''; | 
| 264 | -            $paramDef   = str_pad('$' . $param->getName(), 32, ' ') . '= '; | |
| 265 | - $paramDef .= static::getDefaultValue($type); | |
| 266 | - $output[] = $paramDef . ';'; | |
| 264 | +            $paramDef   = str_pad('$'.$param->getName(), 32, ' ').'= '; | |
| 265 | + $paramDef .= static::getDefaultValue($type); | |
| 266 | + $output[ ] = $paramDef.';'; | |
| 267 | 267 | } | 
| 268 | 268 | |
| 269 | 269 |          return implode("\n        {$extraPadding}", $output); | 
| @@ -286,9 +286,9 @@ discard block | ||
| 286 | 286 | * @param string $default | 
| 287 | 287 | * @return string | 
| 288 | 288 | */ | 
| 289 | - protected static function getDefaultValue(string $type='', string $default='null') : string | |
| 289 | + protected static function getDefaultValue(string $type = '', string $default = 'null') : string | |
| 290 | 290 |      { | 
| 291 | - $typeMap = [ | |
| 291 | + $typeMap = [ | |
| 292 | 292 | 'int' => "0", | 
| 293 | 293 | 'float' => "0.0", | 
| 294 | 294 | 'string' => "''", | 
| @@ -297,7 +297,7 @@ discard block | ||
| 297 | 297 | 'array' => "[]", | 
| 298 | 298 | ]; | 
| 299 | 299 | |
| 300 | - return $typeMap[$type] ?? $default; | |
| 300 | + return $typeMap[ $type ] ?? $default; | |
| 301 | 301 | } | 
| 302 | 302 | } | 
| 303 | 303 | |
| @@ -305,10 +305,10 @@ discard block | ||
| 305 | 305 | class Suite | 
| 306 | 306 |  { | 
| 307 | 307 | /** @var Test[] */ | 
| 308 | - protected $tests = []; | |
| 308 | + protected $tests = [ ]; | |
| 309 | 309 | |
| 310 | 310 | /** @var mixed[] */ | 
| 311 | - protected $fixtures = []; | |
| 311 | + protected $fixtures = [ ]; | |
| 312 | 312 | |
| 313 | 313 | /** @var Logger */ | 
| 314 | 314 | protected $logger = null; | 
| @@ -320,12 +320,12 @@ discard block | ||
| 320 | 320 | * @param string $filter | 
| 321 | 321 | * @return int | 
| 322 | 322 | */ | 
| 323 | - public function run(string $filter='') : int | |
| 323 | + public function run(string $filter = '') : int | |
| 324 | 324 |      { | 
| 325 | - foreach ( $this->tests as $test => $testCase ) | |
| 325 | + foreach ($this->tests as $test => $testCase) | |
| 326 | 326 |          { | 
| 327 | - $testName = $testCase->getTestName(); | |
| 328 | - if ( $filter && $test !== $filter ) | |
| 327 | + $testName = $testCase->getTestName(); | |
| 328 | + if ($filter && $test !== $filter) | |
| 329 | 329 |              { | 
| 330 | 330 | continue; | 
| 331 | 331 | } | 
| @@ -333,36 +333,36 @@ discard block | ||
| 333 | 333 |              { | 
| 334 | 334 |                  $this->getLogger()->info("[{$testName}] - Starting..."); | 
| 335 | 335 | $testCase->runTest($this); | 
| 336 | -                $this->getLogger()->info("[{$testName}] - " . $testCase->getSuccessMessage()); | |
| 336 | +                $this->getLogger()->info("[{$testName}] - ".$testCase->getSuccessMessage()); | |
| 337 | 337 | } | 
| 338 | - catch ( \Exception $e ) | |
| 338 | + catch (\Exception $e) | |
| 339 | 339 |              { | 
| 340 | 340 | $expectedCode = $testCase->getExceptionCode(); | 
| 341 | 341 | $expectedClass = $testCase->getExceptionType(); | 
| 342 | 342 | $code = $e->getCode(); | 
| 343 | 343 | $exception = get_class($e); | 
| 344 | - if ( ! $expectedClass && ! $expectedCode ) | |
| 344 | + if ( ! $expectedClass && ! $expectedCode) | |
| 345 | 345 |                  { | 
| 346 | -                    $this->getLogger()->error($e->getMessage(), [compact('testName'), $e]); | |
| 346 | +                    $this->getLogger()->error($e->getMessage(), [ compact('testName'), $e ]); | |
| 347 | 347 | $this->failedCount++; | 
| 348 | 348 | |
| 349 | 349 | continue; | 
| 350 | 350 | } | 
| 351 | - if ( $expectedCode && $expectedCode !== $code ) | |
| 351 | + if ($expectedCode && $expectedCode !== $code) | |
| 352 | 352 |                  { | 
| 353 | -                    $this->getLogger()->error("Exception code({$code}) was expected to be ({$expectedCode})", [compact('testName'), $e]); | |
| 353 | +                    $this->getLogger()->error("Exception code({$code}) was expected to be ({$expectedCode})", [ compact('testName'), $e ]); | |
| 354 | 354 | $this->failedCount++; | 
| 355 | 355 | |
| 356 | 356 | continue; | 
| 357 | 357 | } | 
| 358 | - if ( $expectedClass && $expectedClass !== $exception ) | |
| 358 | + if ($expectedClass && $expectedClass !== $exception) | |
| 359 | 359 |                  { | 
| 360 | -                    $this->getLogger()->error("Exception class({$exception}) was expected to be ({$expectedClass})", [compact('testName'), $e]); | |
| 360 | +                    $this->getLogger()->error("Exception class({$exception}) was expected to be ({$expectedClass})", [ compact('testName'), $e ]); | |
| 361 | 361 | $this->failedCount++; | 
| 362 | 362 | |
| 363 | 363 | continue; | 
| 364 | 364 | } | 
| 365 | -                $this->getLogger()->info("[{$test}] - " . $testCase->getSuccessMessage()); | |
| 365 | +                $this->getLogger()->info("[{$test}] - ".$testCase->getSuccessMessage()); | |
| 366 | 366 | } | 
| 367 | 367 | } | 
| 368 | 368 | |
| @@ -394,9 +394,9 @@ discard block | ||
| 394 | 394 | * @return Suite | 
| 395 | 395 | * @throws AssertionFailedException | 
| 396 | 396 | */ | 
| 397 | - public function test(string $testName, Closure $test, string $successMessage='', int $exceptionCode=0, string $exceptionClass='') : Suite | |
| 397 | + public function test(string $testName, Closure $test, string $successMessage = '', int $exceptionCode = 0, string $exceptionClass = '') : Suite | |
| 398 | 398 |      { | 
| 399 | - $this->tests[] = new Test($testName, $test, $successMessage, $exceptionCode, $exceptionClass); | |
| 399 | + $this->tests[ ] = new Test($testName, $test, $successMessage, $exceptionCode, $exceptionClass); | |
| 400 | 400 | |
| 401 | 401 | return $this; | 
| 402 | 402 | } | 
| @@ -408,7 +408,7 @@ discard block | ||
| 408 | 408 | */ | 
| 409 | 409 | public function fixture(string $fixtureName, $value) : Suite | 
| 410 | 410 |      { | 
| 411 | - $this->fixtures[$fixtureName] = $value; | |
| 411 | + $this->fixtures[ $fixtureName ] = $value; | |
| 412 | 412 | |
| 413 | 413 | return $this; | 
| 414 | 414 | } | 
| @@ -422,7 +422,7 @@ discard block | ||
| 422 | 422 |      { | 
| 423 | 423 |          Assert::that($this->fixtures)->keyExists($fixtureName, "The fixture ({$fixtureName}) does not exist."); | 
| 424 | 424 | |
| 425 | - return $this->fixtures[$fixtureName]; | |
| 425 | + return $this->fixtures[ $fixtureName ]; | |
| 426 | 426 | } | 
| 427 | 427 | |
| 428 | 428 | |
| @@ -442,7 +442,7 @@ discard block | ||
| 442 | 442 | */ | 
| 443 | 443 | public function getLogger() : Logger | 
| 444 | 444 |      { | 
| 445 | - if ( ! $this->logger ) | |
| 445 | + if ( ! $this->logger) | |
| 446 | 446 |          { | 
| 447 | 447 | $this->logger = new Logger(); | 
| 448 | 448 | } | 
| @@ -479,7 +479,7 @@ discard block | ||
| 479 | 479 | * @param string $exceptionClass | 
| 480 | 480 | * @throws AssertionFailedException | 
| 481 | 481 | */ | 
| 482 | - public function __construct(string $testName, Closure $test, string $successMessage='', int $exceptionCode=0, string $exceptionClass='') | |
| 482 | + public function __construct(string $testName, Closure $test, string $successMessage = '', int $exceptionCode = 0, string $exceptionClass = '') | |
| 483 | 483 |      { | 
| 484 | 484 | $this->setTestName($testName); | 
| 485 | 485 | $this->setTest($test); | 
| @@ -514,7 +514,7 @@ discard block | ||
| 514 | 514 | */ | 
| 515 | 515 | public function getSuccessMessage() : string | 
| 516 | 516 |      { | 
| 517 | - if ( ! $this->successMessage ) | |
| 517 | + if ( ! $this->successMessage) | |
| 518 | 518 |          { | 
| 519 | 519 |              return "Successfully run {$this->testName}"; | 
| 520 | 520 | } | 
| @@ -667,21 +667,21 @@ discard block | ||
| 667 | 667 | /** | 
| 668 | 668 | * @var array $logLevels List of supported levels | 
| 669 | 669 | */ | 
| 670 | - static protected $logLevels = [ | |
| 671 | - self::EMERGENCY => [1, self::WHITE, self::RED, self::DEFAULT, 'EMERG'], | |
| 672 | - self::ALERT => [2, self::WHITE, self::YELLOW, self::DEFAULT, 'ALERT'], | |
| 673 | - self::CRITICAL => [3, self::RED, self::DEFAULT, self::BOLD , 'CRIT'], | |
| 674 | - self::ERROR => [4, self::RED, self::DEFAULT, self::DEFAULT, 'ERROR'], | |
| 675 | - self::WARNING => [5, self::YELLOW, self::DEFAULT, self::DEFAULT, 'WARN'], | |
| 676 | - self::NOTICE => [6, self::CYAN, self::DEFAULT, self::DEFAULT, 'NOTE'], | |
| 677 | - self::INFO => [7, self::GREEN, self::DEFAULT, self::DEFAULT, 'INFO'], | |
| 678 | - self::DEBUG => [8, self::LIGHT_GRAY, self::DEFAULT, self::DEFAULT, 'DEBUG'], | |
| 670 | + static protected $logLevels = [ | |
| 671 | + self::EMERGENCY => [ 1, self::WHITE, self::RED, self::DEFAULT, 'EMERG' ], | |
| 672 | + self::ALERT => [ 2, self::WHITE, self::YELLOW, self::DEFAULT, 'ALERT' ], | |
| 673 | + self::CRITICAL => [ 3, self::RED, self::DEFAULT, self::BOLD, 'CRIT' ], | |
| 674 | + self::ERROR => [ 4, self::RED, self::DEFAULT, self::DEFAULT, 'ERROR' ], | |
| 675 | + self::WARNING => [ 5, self::YELLOW, self::DEFAULT, self::DEFAULT, 'WARN' ], | |
| 676 | + self::NOTICE => [ 6, self::CYAN, self::DEFAULT, self::DEFAULT, 'NOTE' ], | |
| 677 | + self::INFO => [ 7, self::GREEN, self::DEFAULT, self::DEFAULT, 'INFO' ], | |
| 678 | + self::DEBUG => [ 8, self::LIGHT_GRAY, self::DEFAULT, self::DEFAULT, 'DEBUG' ], | |
| 679 | 679 | ]; | 
| 680 | 680 | |
| 681 | 681 | /** | 
| 682 | 682 | * @var array | 
| 683 | 683 | */ | 
| 684 | - static protected $colours = [ | |
| 684 | + static protected $colours = [ | |
| 685 | 685 | 'fore' => [ | 
| 686 | 686 | self::BLACK => '0;30', | 
| 687 | 687 | self::DARK_GRAY => '1;30', | 
| @@ -712,7 +712,7 @@ discard block | ||
| 712 | 712 | self::CYAN => '46', | 
| 713 | 713 | self::LIGHT_GRAY => '47', | 
| 714 | 714 | ], | 
| 715 | - self::BOLD => [], | |
| 715 | + self::BOLD => [ ], | |
| 716 | 716 | ]; | 
| 717 | 717 | |
| 718 | 718 | /** | 
| @@ -722,7 +722,7 @@ discard block | ||
| 722 | 722 | * @param bool $gzipFile | 
| 723 | 723 | * @param bool $addDate | 
| 724 | 724 | */ | 
| 725 | - public function __construct($resource=STDOUT, string $level=self::INFO, bool $useLocking=false, bool $gzipFile=false, bool $addDate=true) | |
| 725 | + public function __construct($resource = STDOUT, string $level = self::INFO, bool $useLocking = false, bool $gzipFile = false, bool $addDate = true) | |
| 726 | 726 |      { | 
| 727 | 727 | $this->resource = $resource; | 
| 728 | 728 | $this->setLogLevel($level); | 
| @@ -737,7 +737,7 @@ discard block | ||
| 737 | 737 | * @param string $message | 
| 738 | 738 | * @param array $context | 
| 739 | 739 | */ | 
| 740 | - public function emergency(string $message, array $context=[]) | |
| 740 | + public function emergency(string $message, array $context = [ ]) | |
| 741 | 741 |      { | 
| 742 | 742 | $this->log(self::EMERGENCY, $message, $context); | 
| 743 | 743 | } | 
| @@ -751,7 +751,7 @@ discard block | ||
| 751 | 751 | * @param string $message | 
| 752 | 752 | * @param array $context | 
| 753 | 753 | */ | 
| 754 | - public function alert(string $message, array $context=[]) | |
| 754 | + public function alert(string $message, array $context = [ ]) | |
| 755 | 755 |      { | 
| 756 | 756 | $this->log(self::ALERT, $message, $context); | 
| 757 | 757 | } | 
| @@ -764,7 +764,7 @@ discard block | ||
| 764 | 764 | * @param string $message | 
| 765 | 765 | * @param array $context | 
| 766 | 766 | */ | 
| 767 | - public function critical(string $message, array $context=[]) | |
| 767 | + public function critical(string $message, array $context = [ ]) | |
| 768 | 768 |      { | 
| 769 | 769 | $this->log(self::CRITICAL, $message, $context); | 
| 770 | 770 | } | 
| @@ -776,7 +776,7 @@ discard block | ||
| 776 | 776 | * @param string $message | 
| 777 | 777 | * @param array $context | 
| 778 | 778 | */ | 
| 779 | - public function error(string $message, array $context=[]) | |
| 779 | + public function error(string $message, array $context = [ ]) | |
| 780 | 780 |      { | 
| 781 | 781 | $this->log(self::ERROR, $message, $context); | 
| 782 | 782 | } | 
| @@ -790,7 +790,7 @@ discard block | ||
| 790 | 790 | * @param string $message | 
| 791 | 791 | * @param array $context | 
| 792 | 792 | */ | 
| 793 | - public function warning(string $message, array $context=[]) | |
| 793 | + public function warning(string $message, array $context = [ ]) | |
| 794 | 794 |      { | 
| 795 | 795 | $this->log(self::WARNING, $message, $context); | 
| 796 | 796 | } | 
| @@ -801,7 +801,7 @@ discard block | ||
| 801 | 801 | * @param string $message | 
| 802 | 802 | * @param array $context | 
| 803 | 803 | */ | 
| 804 | - public function notice(string $message, array $context=[]) | |
| 804 | + public function notice(string $message, array $context = [ ]) | |
| 805 | 805 |      { | 
| 806 | 806 | $this->log(self::NOTICE, $message, $context); | 
| 807 | 807 | } | 
| @@ -814,7 +814,7 @@ discard block | ||
| 814 | 814 | * @param string $message | 
| 815 | 815 | * @param array $context | 
| 816 | 816 | */ | 
| 817 | - public function info(string $message, array $context=[]) | |
| 817 | + public function info(string $message, array $context = [ ]) | |
| 818 | 818 |      { | 
| 819 | 819 | $this->log(self::INFO, $message, $context); | 
| 820 | 820 | } | 
| @@ -825,7 +825,7 @@ discard block | ||
| 825 | 825 | * @param string $message | 
| 826 | 826 | * @param array $context | 
| 827 | 827 | */ | 
| 828 | - public function debug(string $message, array $context=[]) | |
| 828 | + public function debug(string $message, array $context = [ ]) | |
| 829 | 829 |      { | 
| 830 | 830 | $this->log(self::DEBUG, $message, $context); | 
| 831 | 831 | } | 
| @@ -836,7 +836,7 @@ discard block | ||
| 836 | 836 | */ | 
| 837 | 837 | public function setLogFile($resource) : Logger | 
| 838 | 838 |      { | 
| 839 | - $this->resource = $resource; | |
| 839 | + $this->resource = $resource; | |
| 840 | 840 | |
| 841 | 841 | return $this; | 
| 842 | 842 | } | 
| @@ -848,23 +848,23 @@ discard block | ||
| 848 | 848 | * @param bool $bold | 
| 849 | 849 | * @return string | 
| 850 | 850 | */ | 
| 851 | - public static function addColour(string $string, string $foregroundColor='', string $backgroundColor='', bool $bold=false) : string | |
| 851 | + public static function addColour(string $string, string $foregroundColor = '', string $backgroundColor = '', bool $bold = false) : string | |
| 852 | 852 |      { | 
| 853 | 853 | // todo: support bold | 
| 854 | 854 | unset($bold); | 
| 855 | 855 | $coloredString = ''; | 
| 856 | 856 | // Check if given foreground color found | 
| 857 | - if ( isset(static::$colours['fore'][$foregroundColor]) ) | |
| 857 | + if (isset(static::$colours[ 'fore' ][ $foregroundColor ])) | |
| 858 | 858 |          { | 
| 859 | - $coloredString .= "\033[" . static::$colours['fore'][$foregroundColor] . "m"; | |
| 859 | + $coloredString .= "\033[".static::$colours[ 'fore' ][ $foregroundColor ]."m"; | |
| 860 | 860 | } | 
| 861 | 861 | // Check if given background color found | 
| 862 | - if ( isset(static::$colours['back'][$backgroundColor]) ) | |
| 862 | + if (isset(static::$colours[ 'back' ][ $backgroundColor ])) | |
| 863 | 863 |          { | 
| 864 | - $coloredString .= "\033[" . static::$colours['back'][$backgroundColor] . "m"; | |
| 864 | + $coloredString .= "\033[".static::$colours[ 'back' ][ $backgroundColor ]."m"; | |
| 865 | 865 | } | 
| 866 | 866 | // Add string and end coloring | 
| 867 | - $coloredString .= $string . "\033[0m"; | |
| 867 | + $coloredString .= $string."\033[0m"; | |
| 868 | 868 | |
| 869 | 869 | return $coloredString; | 
| 870 | 870 | } | 
| @@ -876,7 +876,7 @@ discard block | ||
| 876 | 876 | * @param bool $bold | 
| 877 | 877 | * @return string | 
| 878 | 878 | */ | 
| 879 | - public function colourize(string $string, string $foregroundColor='', string $backgroundColor='', bool $bold=false) : string | |
| 879 | + public function colourize(string $string, string $foregroundColor = '', string $backgroundColor = '', bool $bold = false) : string | |
| 880 | 880 |      { | 
| 881 | 881 | return static::addColour($string, $foregroundColor, $backgroundColor, $bold); | 
| 882 | 882 | } | 
| @@ -887,11 +887,11 @@ discard block | ||
| 887 | 887 | */ | 
| 888 | 888 | public function setLogLevel(string $level) : Logger | 
| 889 | 889 |      { | 
| 890 | - if ( ! isset(static::$logLevels[$level]) ) | |
| 890 | + if ( ! isset(static::$logLevels[ $level ])) | |
| 891 | 891 |          { | 
| 892 | 892 |              throw new \InvalidArgumentException("Log level is invalid"); | 
| 893 | 893 | } | 
| 894 | - $this->level = static::$logLevels[$level][0]; | |
| 894 | + $this->level = static::$logLevels[ $level ][ 0 ]; | |
| 895 | 895 | |
| 896 | 896 | return $this; | 
| 897 | 897 | } | 
| @@ -935,25 +935,25 @@ discard block | ||
| 935 | 935 | * @param string|object $message If an object is passed it must implement __toString() | 
| 936 | 936 | * @param array $context Placeholders to be substituted in the message | 
| 937 | 937 | */ | 
| 938 | - public function log($level, $message, array $context=[]) | |
| 938 | + public function log($level, $message, array $context = [ ]) | |
| 939 | 939 |      { | 
| 940 | - $level = isset(static::$logLevels[$level]) ? $level : self::INFO; | |
| 941 | - list($logLevel, $fore, $back, $style) = static::$logLevels[$level]; | |
| 940 | + $level = isset(static::$logLevels[ $level ]) ? $level : self::INFO; | |
| 941 | + list($logLevel, $fore, $back, $style) = static::$logLevels[ $level ]; | |
| 942 | 942 | unset($style); | 
| 943 | - if ( $logLevel > $this->level ) | |
| 943 | + if ($logLevel > $this->level) | |
| 944 | 944 |          { | 
| 945 | - return ; | |
| 945 | + return; | |
| 946 | 946 | } | 
| 947 | - if ( is_callable($this->formatter) ) | |
| 947 | + if (is_callable($this->formatter)) | |
| 948 | 948 |          { | 
| 949 | - $message = $this->formatter->__invoke(static::$logLevels[$level][4], $message, $context); | |
| 949 | + $message = $this->formatter->__invoke(static::$logLevels[ $level ][ 4 ], $message, $context); | |
| 950 | 950 | } | 
| 951 | 951 | else | 
| 952 | 952 |          { | 
| 953 | 953 | $message = $this->formatMessage($level, $message, $context); | 
| 954 | 954 | } | 
| 955 | 955 | $this->lastLogEntry = $message; | 
| 956 | - $this->write($this->colourize($message, $fore, $back) . PHP_EOL); | |
| 956 | + $this->write($this->colourize($message, $fore, $back).PHP_EOL); | |
| 957 | 957 | } | 
| 958 | 958 | |
| 959 | 959 | /** | 
| @@ -963,8 +963,8 @@ discard block | ||
| 963 | 963 | */ | 
| 964 | 964 | public static function style(string $style, string $message) : string | 
| 965 | 965 |      { | 
| 966 | - $style = isset(static::$logLevels[$style]) ? $style : self::INFO; | |
| 967 | - list($logLevel, $fore, $back, $style) = static::$logLevels[$style]; | |
| 966 | + $style = isset(static::$logLevels[ $style ]) ? $style : self::INFO; | |
| 967 | + list($logLevel, $fore, $back, $style) = static::$logLevels[ $style ]; | |
| 968 | 968 | unset($logLevel, $style); | 
| 969 | 969 | |
| 970 | 970 | return static::addColour($message, $fore, $back); | 
| @@ -976,14 +976,14 @@ discard block | ||
| 976 | 976 | * @param array $context | 
| 977 | 977 | * @return string | 
| 978 | 978 | */ | 
| 979 | - protected function formatMessage(string $level, string $message, array $context=[]) : string | |
| 979 | + protected function formatMessage(string $level, string $message, array $context = [ ]) : string | |
| 980 | 980 |      { | 
| 981 | 981 | # Handle objects implementing __toString | 
| 982 | - $message = (string) $message; | |
| 983 | - $message .= empty($context) ? '' : PHP_EOL . json_encode($context, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); | |
| 984 | -        $data               = $this->addDate ? ['date' => date('Y-m-d H:i:s')] : []; | |
| 985 | - $data['level'] = strtoupper(str_pad(static::$logLevels[$level][4], 5, ' ', STR_PAD_RIGHT)); | |
| 986 | - $data['message'] = $message; | |
| 982 | + $message = (string)$message; | |
| 983 | + $message .= empty($context) ? '' : PHP_EOL.json_encode($context, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); | |
| 984 | +        $data               = $this->addDate ? [ 'date' => date('Y-m-d H:i:s') ] : [ ]; | |
| 985 | + $data[ 'level' ] = strtoupper(str_pad(static::$logLevels[ $level ][ 4 ], 5, ' ', STR_PAD_RIGHT)); | |
| 986 | + $data[ 'message' ] = $message; | |
| 987 | 987 | |
| 988 | 988 | return implode($this->separator, $data); | 
| 989 | 989 | } | 
| @@ -996,12 +996,12 @@ discard block | ||
| 996 | 996 | public function write(string $content) | 
| 997 | 997 |      { | 
| 998 | 998 | $resource = $this->getResource(); | 
| 999 | - if ( $this->useLocking ) | |
| 999 | + if ($this->useLocking) | |
| 1000 | 1000 |          { | 
| 1001 | 1001 | flock($resource, LOCK_EX); | 
| 1002 | 1002 | } | 
| 1003 | 1003 | gzwrite($resource, $content); | 
| 1004 | - if ( $this->useLocking ) | |
| 1004 | + if ($this->useLocking) | |
| 1005 | 1005 |          { | 
| 1006 | 1006 | flock($resource, LOCK_UN); | 
| 1007 | 1007 | } | 
| @@ -1013,14 +1013,14 @@ discard block | ||
| 1013 | 1013 | */ | 
| 1014 | 1014 | protected function getResource() | 
| 1015 | 1015 |      { | 
| 1016 | - if ( is_resource($this->resource) ) | |
| 1016 | + if (is_resource($this->resource)) | |
| 1017 | 1017 |          { | 
| 1018 | 1018 | return $this->resource; | 
| 1019 | 1019 | } | 
| 1020 | 1020 | $fileName = $this->resource; | 
| 1021 | 1021 | $this->closeLocally = true; | 
| 1022 | 1022 | $this->resource = $this->openResource(); | 
| 1023 | - if ( ! is_resource($this->resource) ) | |
| 1023 | + if ( ! is_resource($this->resource)) | |
| 1024 | 1024 |          { | 
| 1025 | 1025 |              throw new \Exception("The resource ({$fileName}) could not be opened"); | 
| 1026 | 1026 | } | 
| @@ -1041,7 +1041,7 @@ discard block | ||
| 1041 | 1041 | */ | 
| 1042 | 1042 | protected function openResource() | 
| 1043 | 1043 |      { | 
| 1044 | - if ( $this->gzipFile ) | |
| 1044 | + if ($this->gzipFile) | |
| 1045 | 1045 |          { | 
| 1046 | 1046 | return gzopen($this->resource, 'a'); | 
| 1047 | 1047 | } | 
| @@ -1,4 +1,4 @@ discard block | ||
| 1 | -<?php declare(strict_types=1); | |
| 1 | +<?php declare(strict_types = 1); | |
| 2 | 2 | |
| 3 | 3 | namespace Terah\Assert; | 
| 4 | 4 | |
| @@ -29,5 +29,5 @@ discard block | ||
| 29 | 29 | * | 
| 30 | 30 | * @var string | 
| 31 | 31 | */ | 
| 32 | - protected $exceptionClass = ValidationFailedException::class; | |
| 32 | + protected $exceptionClass = ValidationFailedException::class; | |
| 33 | 33 | } | 
| 34 | 34 | \ No newline at end of file | 
| @@ -1,4 +1,4 @@ discard block | ||
| 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 | ||
| 31 | 31 | * @param string $level | 
| 32 | 32 | * @return Assert | 
| 33 | 33 | */ | 
| 34 | -function Assert($value, string $fieldName='', int $code=0, string $error='', string $level=Assert::WARNING) | |
| 34 | +function Assert($value, string $fieldName = '', int $code = 0, string $error = '', string $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 | ||
| 64 | 64 | * @param string $level | 
| 65 | 65 | * @return Assert | 
| 66 | 66 | */ | 
| 67 | -function Validate($value, string $fieldName='', int $code=0, string $error='', string $level=Assert::WARNING) | |
| 67 | +function Validate($value, string $fieldName = '', int $code = 0, string $error = '', string $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 | } | 
| @@ -1,4 +1,4 @@ discard block | ||
| 1 | -<?php declare(strict_types=1); | |
| 1 | +<?php declare(strict_types = 1); | |
| 2 | 2 | |
| 3 | 3 | namespace Terah\Assert; | 
| 4 | 4 | |
| @@ -41,7 +41,7 @@ discard block | ||
| 41 | 41 | * @param string $level | 
| 42 | 42 | * @param string $propertyPath | 
| 43 | 43 | */ | 
| 44 | - public function __construct(string $message, int $code, string $fieldName='', $value='', array $constraints=[], string $level='critical', string $propertyPath='') | |
| 44 | + public function __construct(string $message, int $code, string $fieldName = '', $value = '', array $constraints = [ ], string $level = 'critical', string $propertyPath = '') | |
| 45 | 45 |      { | 
| 46 | 46 | parent::__construct($message, $code); | 
| 47 | 47 | $this->fieldName = $fieldName; | 
| @@ -49,14 +49,14 @@ discard block | ||
| 49 | 49 | $this->constraints = $constraints; | 
| 50 | 50 | $this->level = $level; | 
| 51 | 51 | $this->propertyPath = $propertyPath; | 
| 52 | - foreach ( $this->getTrace() as $point ) | |
| 52 | + foreach ($this->getTrace() as $point) | |
| 53 | 53 |          { | 
| 54 | - if ( $this->location ) | |
| 54 | + if ($this->location) | |
| 55 | 55 |              { | 
| 56 | 56 | continue; | 
| 57 | 57 | } | 
| 58 | - $class = $point['class'] ??0?: ''; | |
| 59 | - if ( $class !== Assert::class ) | |
| 58 | + $class = $point[ 'class' ] ??0 ?: ''; | |
| 59 | + if ($class !== Assert::class) | |
| 60 | 60 |              { | 
| 61 | 61 | $this->location = (object)$point; | 
| 62 | 62 | } | 
| @@ -124,7 +124,7 @@ discard block | ||
| 124 | 124 | */ | 
| 125 | 125 | public function getPropertyPathAndCallingLocation() : string | 
| 126 | 126 |      { | 
| 127 | - return $this->getPropertyPath() . ' in ' . $this->getCallingFileAndLine(); | |
| 127 | + return $this->getPropertyPath().' in '.$this->getCallingFileAndLine(); | |
| 128 | 128 | } | 
| 129 | 129 | |
| 130 | 130 | /** | 
| @@ -135,15 +135,15 @@ discard block | ||
| 135 | 135 | */ | 
| 136 | 136 | protected function getCallingFileAndLine() : string | 
| 137 | 137 |      { | 
| 138 | - foreach ( $this->getTrace() as $trace ) | |
| 138 | + foreach ($this->getTrace() as $trace) | |
| 139 | 139 |          { | 
| 140 | 140 | $trace = (object)$trace; | 
| 141 | - if ( empty($trace->file) ) | |
| 141 | + if (empty($trace->file)) | |
| 142 | 142 |              { | 
| 143 | 143 | continue; | 
| 144 | 144 | } | 
| 145 | 145 |              $file = static::beforeLast('.php', static::afterLast('/', $trace->file)); | 
| 146 | - if ( in_array($file, ['AssertionChain', 'Assertion']) ) | |
| 146 | + if (in_array($file, [ 'AssertionChain', 'Assertion' ])) | |
| 147 | 147 |              { | 
| 148 | 148 | continue; | 
| 149 | 149 | } | 
| @@ -170,9 +170,9 @@ discard block | ||
| 170 | 170 | * @param bool $returnOriginal | 
| 171 | 171 | * @return string | 
| 172 | 172 | */ | 
| 173 | - public static function afterLast(string $needle, string $haystack, bool $returnOriginal=false) : string | |
| 173 | + public static function afterLast(string $needle, string $haystack, bool $returnOriginal = false) : string | |
| 174 | 174 |      { | 
| 175 | - if ( static::strrevpos($haystack, $needle) !== -1 ) | |
| 175 | + if (static::strrevpos($haystack, $needle) !== -1) | |
| 176 | 176 |          { | 
| 177 | 177 | return mb_substr($haystack, static::strrevpos($haystack, $needle) + mb_strlen($needle)); | 
| 178 | 178 | } | 
| @@ -199,7 +199,7 @@ discard block | ||
| 199 | 199 | */ | 
| 200 | 200 | public static function beforeLast(string $needle, string $haystack) : string | 
| 201 | 201 |      { | 
| 202 | - $position = static::strrevpos($haystack, $needle); | |
| 202 | + $position = static::strrevpos($haystack, $needle); | |
| 203 | 203 | |
| 204 | 204 | return $position === -1 ? '' : mb_substr($haystack, 0, static::strrevpos($haystack, $needle)); | 
| 205 | 205 | } |