@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
| 221 | - * @param $exceptionClass |
|
| 221 | + * @param string $exceptionClass |
|
| 222 | 222 | * @return Assert |
| 223 | 223 | */ |
| 224 | 224 | public function setExceptionClass($exceptionClass) |
@@ -1220,7 +1220,7 @@ discard block |
||
| 1220 | 1220 | * |
| 1221 | 1221 | * @throws AssertionFailedException |
| 1222 | 1222 | * |
| 1223 | - * @param array $choices |
|
| 1223 | + * @param integer[] $choices |
|
| 1224 | 1224 | * @param string|null $message |
| 1225 | 1225 | * @param string|null $propertyPath |
| 1226 | 1226 | * @return $this |
@@ -2352,7 +2352,7 @@ discard block |
||
| 2352 | 2352 | } |
| 2353 | 2353 | |
| 2354 | 2354 | /** |
| 2355 | - * @param $func |
|
| 2355 | + * @param string $func |
|
| 2356 | 2356 | * @param $args |
| 2357 | 2357 | * @return bool |
| 2358 | 2358 | * @throws AssertionFailedException |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * |
| 129 | 129 | * @var string |
| 130 | 130 | */ |
| 131 | - protected $exceptionClass = 'Terah\Assert\AssertionFailedException'; |
|
| 131 | + protected $exceptionClass = 'Terah\Assert\AssertionFailedException'; |
|
| 132 | 132 | |
| 133 | 133 | /** |
| 134 | 134 | * @param mixed $value |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | * @param string $level |
| 209 | 209 | * @return AssertionFailedException |
| 210 | 210 | */ |
| 211 | - protected function createException($message, $code, $propertyPath, array $constraints = [], $level=null) |
|
| 211 | + protected function createException($message, $code, $propertyPath, array $constraints = [ ], $level = null) |
|
| 212 | 212 | { |
| 213 | 213 | $exceptionClass = $this->exceptionClass; |
| 214 | 214 | $propertyPath = is_null($propertyPath) ? $this->propertyPath : $propertyPath; |
@@ -278,11 +278,11 @@ discard block |
||
| 278 | 278 | */ |
| 279 | 279 | public function eq($value2, $message = null, $propertyPath = null) |
| 280 | 280 | { |
| 281 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 281 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 282 | 282 | { |
| 283 | 283 | return $this; |
| 284 | 284 | } |
| 285 | - if ( $this->value != $value2 ) |
|
| 285 | + if ($this->value != $value2) |
|
| 286 | 286 | { |
| 287 | 287 | $message = $message ?: $this->overrideError; |
| 288 | 288 | $message = sprintf( |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | $this->stringify($this->value), |
| 291 | 291 | $this->stringify($value2) |
| 292 | 292 | ); |
| 293 | - throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $propertyPath, ['expected' => $value2]); |
|
| 293 | + throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $propertyPath, [ 'expected' => $value2 ]); |
|
| 294 | 294 | } |
| 295 | 295 | return $this; |
| 296 | 296 | } |
@@ -305,11 +305,11 @@ discard block |
||
| 305 | 305 | */ |
| 306 | 306 | public function greaterThan($value2, $message = null, $propertyPath = null) |
| 307 | 307 | { |
| 308 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 308 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 309 | 309 | { |
| 310 | 310 | return $this; |
| 311 | 311 | } |
| 312 | - if ( ! ( $this->value > $value2 ) ) |
|
| 312 | + if ( ! ($this->value > $value2)) |
|
| 313 | 313 | { |
| 314 | 314 | $message = $message ?: $this->overrideError; |
| 315 | 315 | $message = sprintf( |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | $this->stringify($this->value), |
| 318 | 318 | $this->stringify($value2) |
| 319 | 319 | ); |
| 320 | - throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $propertyPath, ['expected' => $value2]); |
|
| 320 | + throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $propertyPath, [ 'expected' => $value2 ]); |
|
| 321 | 321 | } |
| 322 | 322 | return $this; |
| 323 | 323 | } |
@@ -332,11 +332,11 @@ discard block |
||
| 332 | 332 | */ |
| 333 | 333 | public function greaterThanOrEq($value2, $message = null, $propertyPath = null) |
| 334 | 334 | { |
| 335 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 335 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 336 | 336 | { |
| 337 | 337 | return $this; |
| 338 | 338 | } |
| 339 | - if ( ! ( $this->value >= $value2 ) ) |
|
| 339 | + if ( ! ($this->value >= $value2)) |
|
| 340 | 340 | { |
| 341 | 341 | $message = $message ?: $this->overrideError; |
| 342 | 342 | $message = sprintf( |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | $this->stringify($this->value), |
| 345 | 345 | $this->stringify($value2) |
| 346 | 346 | ); |
| 347 | - throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $propertyPath, ['expected' => $value2]); |
|
| 347 | + throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $propertyPath, [ 'expected' => $value2 ]); |
|
| 348 | 348 | } |
| 349 | 349 | return $this; |
| 350 | 350 | } |
@@ -359,11 +359,11 @@ discard block |
||
| 359 | 359 | */ |
| 360 | 360 | public function lessThan($value2, $message = null, $propertyPath = null) |
| 361 | 361 | { |
| 362 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 362 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 363 | 363 | { |
| 364 | 364 | return $this; |
| 365 | 365 | } |
| 366 | - if ( ! ( $this->value < $value2 ) ) |
|
| 366 | + if ( ! ($this->value < $value2)) |
|
| 367 | 367 | { |
| 368 | 368 | $message = $message ?: $this->overrideError; |
| 369 | 369 | $message = sprintf( |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | $this->stringify($this->value), |
| 372 | 372 | $this->stringify($value2) |
| 373 | 373 | ); |
| 374 | - throw $this->createException($message, $this->overrideCode ?: self::INVALID_LESS_THAN, $propertyPath, ['expected' => $value2]); |
|
| 374 | + throw $this->createException($message, $this->overrideCode ?: self::INVALID_LESS_THAN, $propertyPath, [ 'expected' => $value2 ]); |
|
| 375 | 375 | } |
| 376 | 376 | return $this; |
| 377 | 377 | } |
@@ -386,11 +386,11 @@ discard block |
||
| 386 | 386 | */ |
| 387 | 387 | public function lessThanOrEq($value2, $message = null, $propertyPath = null) |
| 388 | 388 | { |
| 389 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 389 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 390 | 390 | { |
| 391 | 391 | return $this; |
| 392 | 392 | } |
| 393 | - if ( ! ( $this->value <= $value2 ) ) |
|
| 393 | + if ( ! ($this->value <= $value2)) |
|
| 394 | 394 | { |
| 395 | 395 | $message = $message ?: $this->overrideError; |
| 396 | 396 | $message = sprintf( |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | $this->stringify($this->value), |
| 399 | 399 | $this->stringify($value2) |
| 400 | 400 | ); |
| 401 | - throw $this->createException($message, $this->overrideCode ?: self::INVALID_LESS_THAN_OR_EQ, $propertyPath, ['expected' => $value2]); |
|
| 401 | + throw $this->createException($message, $this->overrideCode ?: self::INVALID_LESS_THAN_OR_EQ, $propertyPath, [ 'expected' => $value2 ]); |
|
| 402 | 402 | } |
| 403 | 403 | return $this; |
| 404 | 404 | } |
@@ -414,11 +414,11 @@ discard block |
||
| 414 | 414 | */ |
| 415 | 415 | public function same($value2, $message = null, $propertyPath = null) |
| 416 | 416 | { |
| 417 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 417 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 418 | 418 | { |
| 419 | 419 | return $this; |
| 420 | 420 | } |
| 421 | - if ( $this->value !== $value2 ) |
|
| 421 | + if ($this->value !== $value2) |
|
| 422 | 422 | { |
| 423 | 423 | $message = $message ?: $this->overrideError; |
| 424 | 424 | $message = sprintf( |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | $this->stringify($this->value), |
| 427 | 427 | $this->stringify($value2) |
| 428 | 428 | ); |
| 429 | - throw $this->createException($message, $this->overrideCode ?: self::INVALID_SAME, $propertyPath, ['expected' => $value2]); |
|
| 429 | + throw $this->createException($message, $this->overrideCode ?: self::INVALID_SAME, $propertyPath, [ 'expected' => $value2 ]); |
|
| 430 | 430 | } |
| 431 | 431 | return $this; |
| 432 | 432 | } |
@@ -442,11 +442,11 @@ discard block |
||
| 442 | 442 | */ |
| 443 | 443 | public function notEq($value2, $message = null, $propertyPath = null) |
| 444 | 444 | { |
| 445 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 445 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 446 | 446 | { |
| 447 | 447 | return $this; |
| 448 | 448 | } |
| 449 | - if ( $this->value == $value2 ) |
|
| 449 | + if ($this->value == $value2) |
|
| 450 | 450 | { |
| 451 | 451 | $message = $message ?: $this->overrideError; |
| 452 | 452 | $message = sprintf( |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | $this->stringify($this->value), |
| 455 | 455 | $this->stringify($value2) |
| 456 | 456 | ); |
| 457 | - throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_EQ, $propertyPath, ['expected' => $value2]); |
|
| 457 | + throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_EQ, $propertyPath, [ 'expected' => $value2 ]); |
|
| 458 | 458 | } |
| 459 | 459 | return $this; |
| 460 | 460 | } |
@@ -468,11 +468,11 @@ discard block |
||
| 468 | 468 | */ |
| 469 | 469 | public function isCallable($message = null, $propertyPath = null) |
| 470 | 470 | { |
| 471 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 471 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 472 | 472 | { |
| 473 | 473 | return $this; |
| 474 | 474 | } |
| 475 | - if ( !is_callable($this->value) ) |
|
| 475 | + if ( ! is_callable($this->value)) |
|
| 476 | 476 | { |
| 477 | 477 | $message = $message ?: $this->overrideError; |
| 478 | 478 | $message = sprintf( |
@@ -495,11 +495,11 @@ discard block |
||
| 495 | 495 | */ |
| 496 | 496 | public function notSame($value2, $message = null, $propertyPath = null) |
| 497 | 497 | { |
| 498 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 498 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 499 | 499 | { |
| 500 | 500 | return $this; |
| 501 | 501 | } |
| 502 | - if ( $this->value === $value2 ) |
|
| 502 | + if ($this->value === $value2) |
|
| 503 | 503 | { |
| 504 | 504 | $message = $message ?: $this->overrideError; |
| 505 | 505 | $message = sprintf( |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | $this->stringify($this->value), |
| 508 | 508 | $this->stringify($value2) |
| 509 | 509 | ); |
| 510 | - throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_SAME, $propertyPath, ['expected' => $value2]); |
|
| 510 | + throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_SAME, $propertyPath, [ 'expected' => $value2 ]); |
|
| 511 | 511 | } |
| 512 | 512 | return $this; |
| 513 | 513 | } |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | { |
| 549 | 549 | $message = $message ?: $this->overrideError; |
| 550 | 550 | $message = $message ?: 'Value "%s" is not a valid status.'; |
| 551 | - return $this->integer($message, $propertyPath)->inArray([-1, 0, 1]); |
|
| 551 | + return $this->integer($message, $propertyPath)->inArray([-1, 0, 1 ]); |
|
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | /** |
@@ -592,11 +592,11 @@ discard block |
||
| 592 | 592 | */ |
| 593 | 593 | public function integer($message = null, $propertyPath = null) |
| 594 | 594 | { |
| 595 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 595 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 596 | 596 | { |
| 597 | 597 | return $this; |
| 598 | 598 | } |
| 599 | - if ( !is_int($this->value) ) |
|
| 599 | + if ( ! is_int($this->value)) |
|
| 600 | 600 | { |
| 601 | 601 | $message = $message ?: $this->overrideError; |
| 602 | 602 | $message = sprintf( |
@@ -618,11 +618,11 @@ discard block |
||
| 618 | 618 | */ |
| 619 | 619 | public function float($message = null, $propertyPath = null) |
| 620 | 620 | { |
| 621 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 621 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 622 | 622 | { |
| 623 | 623 | return $this; |
| 624 | 624 | } |
| 625 | - if ( ! is_float($this->value) ) |
|
| 625 | + if ( ! is_float($this->value)) |
|
| 626 | 626 | { |
| 627 | 627 | $message = $message ?: $this->overrideError; |
| 628 | 628 | $message = sprintf( |
@@ -644,11 +644,11 @@ discard block |
||
| 644 | 644 | */ |
| 645 | 645 | public function digit($message = null, $propertyPath = null) |
| 646 | 646 | { |
| 647 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 647 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 648 | 648 | { |
| 649 | 649 | return $this; |
| 650 | 650 | } |
| 651 | - if ( ! ctype_digit((string)$this->value) ) |
|
| 651 | + if ( ! ctype_digit((string)$this->value)) |
|
| 652 | 652 | { |
| 653 | 653 | $message = $message ?: $this->overrideError; |
| 654 | 654 | $message = sprintf( |
@@ -670,12 +670,12 @@ discard block |
||
| 670 | 670 | */ |
| 671 | 671 | public function date($message = null, $propertyPath = null) |
| 672 | 672 | { |
| 673 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 673 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 674 | 674 | { |
| 675 | 675 | return $this; |
| 676 | 676 | } |
| 677 | 677 | $this->notEmpty($message, $propertyPath); |
| 678 | - if ( strtotime($this->value) === false ) |
|
| 678 | + if (strtotime($this->value) === false) |
|
| 679 | 679 | { |
| 680 | 680 | $message = $message ?: $this->overrideError; |
| 681 | 681 | $message = sprintf( |
@@ -697,11 +697,11 @@ discard block |
||
| 697 | 697 | */ |
| 698 | 698 | public function integerish($message = null, $propertyPath = null) |
| 699 | 699 | { |
| 700 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 700 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 701 | 701 | { |
| 702 | 702 | return $this; |
| 703 | 703 | } |
| 704 | - if ( is_object($this->value) || strval(intval($this->value)) != $this->value || is_bool($this->value) || is_null($this->value) ) |
|
| 704 | + if (is_object($this->value) || strval(intval($this->value)) != $this->value || is_bool($this->value) || is_null($this->value)) |
|
| 705 | 705 | { |
| 706 | 706 | $message = $message ?: $this->overrideError; |
| 707 | 707 | $message = sprintf( |
@@ -723,11 +723,11 @@ discard block |
||
| 723 | 723 | */ |
| 724 | 724 | public function boolean($message = null, $propertyPath = null) |
| 725 | 725 | { |
| 726 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 726 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 727 | 727 | { |
| 728 | 728 | return $this; |
| 729 | 729 | } |
| 730 | - if ( ! is_bool($this->value) ) |
|
| 730 | + if ( ! is_bool($this->value)) |
|
| 731 | 731 | { |
| 732 | 732 | $message = $message ?: $this->overrideError; |
| 733 | 733 | $message = sprintf( |
@@ -749,11 +749,11 @@ discard block |
||
| 749 | 749 | */ |
| 750 | 750 | public function scalar($message = null, $propertyPath = null) |
| 751 | 751 | { |
| 752 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 752 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 753 | 753 | { |
| 754 | 754 | return $this; |
| 755 | 755 | } |
| 756 | - if ( !is_scalar($this->value) ) |
|
| 756 | + if ( ! is_scalar($this->value)) |
|
| 757 | 757 | { |
| 758 | 758 | $message = $message ?: $this->overrideError; |
| 759 | 759 | $message = sprintf( |
@@ -775,11 +775,11 @@ discard block |
||
| 775 | 775 | */ |
| 776 | 776 | public function notEmpty($message = null, $propertyPath = null) |
| 777 | 777 | { |
| 778 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 778 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 779 | 779 | { |
| 780 | 780 | return $this; |
| 781 | 781 | } |
| 782 | - if ( ( is_object($this->value) && empty((array)$this->value) ) || empty($this->value) ) |
|
| 782 | + if ((is_object($this->value) && empty((array)$this->value)) || empty($this->value)) |
|
| 783 | 783 | { |
| 784 | 784 | $message = $message ?: $this->overrideError; |
| 785 | 785 | $message = sprintf( |
@@ -801,11 +801,11 @@ discard block |
||
| 801 | 801 | */ |
| 802 | 802 | public function noContent($message = null, $propertyPath = null) |
| 803 | 803 | { |
| 804 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 804 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 805 | 805 | { |
| 806 | 806 | return $this; |
| 807 | 807 | } |
| 808 | - if ( !empty( $this->value ) ) |
|
| 808 | + if ( ! empty($this->value)) |
|
| 809 | 809 | { |
| 810 | 810 | $message = $message ?: $this->overrideError; |
| 811 | 811 | $message = sprintf( |
@@ -827,11 +827,11 @@ discard block |
||
| 827 | 827 | */ |
| 828 | 828 | public function notNull($message = null, $propertyPath = null) |
| 829 | 829 | { |
| 830 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 830 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 831 | 831 | { |
| 832 | 832 | return $this; |
| 833 | 833 | } |
| 834 | - if ( $this->value === null ) |
|
| 834 | + if ($this->value === null) |
|
| 835 | 835 | { |
| 836 | 836 | $message = $message ?: $this->overrideError; |
| 837 | 837 | $message = sprintf( |
@@ -853,11 +853,11 @@ discard block |
||
| 853 | 853 | */ |
| 854 | 854 | public function string($message = null, $propertyPath = null) |
| 855 | 855 | { |
| 856 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 856 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 857 | 857 | { |
| 858 | 858 | return $this; |
| 859 | 859 | } |
| 860 | - if ( !is_string($this->value) ) |
|
| 860 | + if ( ! is_string($this->value)) |
|
| 861 | 861 | { |
| 862 | 862 | $message = $message ?: $this->overrideError; |
| 863 | 863 | $message = sprintf( |
@@ -879,21 +879,21 @@ discard block |
||
| 879 | 879 | * @return Assert |
| 880 | 880 | * @throws AssertionFailedException |
| 881 | 881 | */ |
| 882 | - public function regex($pattern, $message=null, $propertyPath=null) |
|
| 882 | + public function regex($pattern, $message = null, $propertyPath = null) |
|
| 883 | 883 | { |
| 884 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 884 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 885 | 885 | { |
| 886 | 886 | return $this; |
| 887 | 887 | } |
| 888 | 888 | $this->string($message, $propertyPath); |
| 889 | - if ( ! preg_match($pattern, $this->value) ) |
|
| 889 | + if ( ! preg_match($pattern, $this->value)) |
|
| 890 | 890 | { |
| 891 | 891 | $message = $message ?: $this->overrideError; |
| 892 | 892 | $message = sprintf( |
| 893 | 893 | $message ?: 'Value "%s" does not match expression.', |
| 894 | 894 | $this->stringify($this->value) |
| 895 | 895 | ); |
| 896 | - throw $this->createException($message, $this->overrideCode ?: self::INVALID_REGEX, $propertyPath, ['pattern' => $pattern]); |
|
| 896 | + throw $this->createException($message, $this->overrideCode ?: self::INVALID_REGEX, $propertyPath, [ 'pattern' => $pattern ]); |
|
| 897 | 897 | } |
| 898 | 898 | return $this; |
| 899 | 899 | } |
@@ -906,13 +906,13 @@ discard block |
||
| 906 | 906 | */ |
| 907 | 907 | public function ipAddress($message = null, $propertyPath = null) |
| 908 | 908 | { |
| 909 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 909 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 910 | 910 | { |
| 911 | 911 | return $this; |
| 912 | 912 | } |
| 913 | 913 | $this->string($message, $propertyPath); |
| 914 | - $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])$/'; |
|
| 915 | - if ( ! preg_match($pattern, $this->value) ) |
|
| 914 | + $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])$/'; |
|
| 915 | + if ( ! preg_match($pattern, $this->value)) |
|
| 916 | 916 | { |
| 917 | 917 | $message = $message ?: $this->overrideError; |
| 918 | 918 | $message = sprintf( |
@@ -933,19 +933,19 @@ discard block |
||
| 933 | 933 | */ |
| 934 | 934 | public function notRegex($pattern, $message = null, $propertyPath = null) |
| 935 | 935 | { |
| 936 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 936 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 937 | 937 | { |
| 938 | 938 | return $this; |
| 939 | 939 | } |
| 940 | 940 | $this->string($message, $propertyPath); |
| 941 | - if ( preg_match($pattern, $this->value) ) |
|
| 941 | + if (preg_match($pattern, $this->value)) |
|
| 942 | 942 | { |
| 943 | 943 | $message = $message ?: $this->overrideError; |
| 944 | 944 | $message = sprintf( |
| 945 | 945 | $message ?: 'Value "%s" does not match expression.', |
| 946 | 946 | $this->stringify($this->value) |
| 947 | 947 | ); |
| 948 | - throw $this->createException($message, $this->overrideCode ?: self::INVALID_REGEX, $propertyPath, ['pattern' => $pattern]); |
|
| 948 | + throw $this->createException($message, $this->overrideCode ?: self::INVALID_REGEX, $propertyPath, [ 'pattern' => $pattern ]); |
|
| 949 | 949 | } |
| 950 | 950 | return $this; |
| 951 | 951 | } |
@@ -962,12 +962,12 @@ discard block |
||
| 962 | 962 | */ |
| 963 | 963 | public function length($length, $message = null, $propertyPath = null, $encoding = 'utf8') |
| 964 | 964 | { |
| 965 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 965 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 966 | 966 | { |
| 967 | 967 | return $this; |
| 968 | 968 | } |
| 969 | 969 | $this->string($message, $propertyPath); |
| 970 | - if ( mb_strlen($this->value, $encoding) !== $length ) |
|
| 970 | + if (mb_strlen($this->value, $encoding) !== $length) |
|
| 971 | 971 | { |
| 972 | 972 | $message = $message ?: $this->overrideError; |
| 973 | 973 | $message = sprintf( |
@@ -976,7 +976,7 @@ discard block |
||
| 976 | 976 | $length, |
| 977 | 977 | mb_strlen($this->value, $encoding) |
| 978 | 978 | ); |
| 979 | - $constraints = ['length' => $length, 'encoding' => $encoding]; |
|
| 979 | + $constraints = [ 'length' => $length, 'encoding' => $encoding ]; |
|
| 980 | 980 | throw $this->createException($message, $this->overrideCode ?: self::INVALID_LENGTH, $propertyPath, $constraints); |
| 981 | 981 | } |
| 982 | 982 | return $this; |
@@ -994,22 +994,22 @@ discard block |
||
| 994 | 994 | */ |
| 995 | 995 | public function minLength($minLength, $message = null, $propertyPath = null, $encoding = 'utf8') |
| 996 | 996 | { |
| 997 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 997 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 998 | 998 | { |
| 999 | 999 | return $this; |
| 1000 | 1000 | } |
| 1001 | 1001 | $this->string($message, $propertyPath); |
| 1002 | - if ( mb_strlen($this->value, $encoding) < $minLength ) |
|
| 1002 | + if (mb_strlen($this->value, $encoding) < $minLength) |
|
| 1003 | 1003 | { |
| 1004 | 1004 | $message = $message ?: $this->overrideError; |
| 1005 | - $message = sprintf( |
|
| 1005 | + $message = sprintf( |
|
| 1006 | 1006 | $message |
| 1007 | 1007 | ?: 'Value "%s" is too short, it should have more than %d characters, but only has %d characters.', |
| 1008 | 1008 | $this->stringify($this->value), |
| 1009 | 1009 | $minLength, |
| 1010 | 1010 | mb_strlen($this->value, $encoding) |
| 1011 | 1011 | ); |
| 1012 | - $constraints = ['min_length' => $minLength, 'encoding' => $encoding]; |
|
| 1012 | + $constraints = [ 'min_length' => $minLength, 'encoding' => $encoding ]; |
|
| 1013 | 1013 | throw $this->createException($message, $this->overrideCode ?: self::INVALID_MIN_LENGTH, $propertyPath, $constraints); |
| 1014 | 1014 | } |
| 1015 | 1015 | return $this; |
@@ -1027,21 +1027,21 @@ discard block |
||
| 1027 | 1027 | */ |
| 1028 | 1028 | public function maxLength($maxLength, $message = null, $propertyPath = null, $encoding = 'utf8') |
| 1029 | 1029 | { |
| 1030 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1030 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1031 | 1031 | { |
| 1032 | 1032 | return $this; |
| 1033 | 1033 | } |
| 1034 | 1034 | $this->string($message, $propertyPath); |
| 1035 | - if ( mb_strlen($this->value, $encoding) > $maxLength ) |
|
| 1035 | + if (mb_strlen($this->value, $encoding) > $maxLength) |
|
| 1036 | 1036 | { |
| 1037 | 1037 | $message = $message ?: $this->overrideError; |
| 1038 | - $message = sprintf( |
|
| 1038 | + $message = sprintf( |
|
| 1039 | 1039 | $message ?: 'Value "%s" is too long, it should have no more than %d characters, but has %d characters.', |
| 1040 | 1040 | $this->stringify($this->value), |
| 1041 | 1041 | $maxLength, |
| 1042 | 1042 | mb_strlen($this->value, $encoding) |
| 1043 | 1043 | ); |
| 1044 | - $constraints = ['max_length' => $maxLength, 'encoding' => $encoding]; |
|
| 1044 | + $constraints = [ 'max_length' => $maxLength, 'encoding' => $encoding ]; |
|
| 1045 | 1045 | throw $this->createException($message, $this->overrideCode ?: self::INVALID_MAX_LENGTH, $propertyPath, $constraints); |
| 1046 | 1046 | } |
| 1047 | 1047 | return $this; |
@@ -1060,34 +1060,34 @@ discard block |
||
| 1060 | 1060 | */ |
| 1061 | 1061 | public function betweenLength($minLength, $maxLength, $message = null, $propertyPath = null, $encoding = 'utf8') |
| 1062 | 1062 | { |
| 1063 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1063 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1064 | 1064 | { |
| 1065 | 1065 | return $this; |
| 1066 | 1066 | } |
| 1067 | 1067 | $this->string($message, $propertyPath); |
| 1068 | - if ( mb_strlen($this->value, $encoding) < $minLength ) |
|
| 1068 | + if (mb_strlen($this->value, $encoding) < $minLength) |
|
| 1069 | 1069 | { |
| 1070 | 1070 | $message = $message ?: $this->overrideError; |
| 1071 | - $message = sprintf( |
|
| 1071 | + $message = sprintf( |
|
| 1072 | 1072 | $message |
| 1073 | 1073 | ?: 'Value "%s" is too short, it should have more than %d characters, but only has %d characters.', |
| 1074 | 1074 | $this->stringify($this->value), |
| 1075 | 1075 | $minLength, |
| 1076 | 1076 | mb_strlen($this->value, $encoding) |
| 1077 | 1077 | ); |
| 1078 | - $constraints = ['min_length' => $minLength, 'encoding' => $encoding]; |
|
| 1078 | + $constraints = [ 'min_length' => $minLength, 'encoding' => $encoding ]; |
|
| 1079 | 1079 | throw $this->createException($message, $this->overrideCode ?: self::INVALID_MIN_LENGTH, $propertyPath, $constraints); |
| 1080 | 1080 | } |
| 1081 | - if ( mb_strlen($this->value, $encoding) > $maxLength ) |
|
| 1081 | + if (mb_strlen($this->value, $encoding) > $maxLength) |
|
| 1082 | 1082 | { |
| 1083 | 1083 | $message = $message ?: $this->overrideError; |
| 1084 | - $message = sprintf( |
|
| 1084 | + $message = sprintf( |
|
| 1085 | 1085 | $message ?: 'Value "%s" is too long, it should have no more than %d characters, but has %d characters.', |
| 1086 | 1086 | $this->stringify($this->value), |
| 1087 | 1087 | $maxLength, |
| 1088 | 1088 | mb_strlen($this->value, $encoding) |
| 1089 | 1089 | ); |
| 1090 | - $constraints = ['max_length' => $maxLength, 'encoding' => $encoding]; |
|
| 1090 | + $constraints = [ 'max_length' => $maxLength, 'encoding' => $encoding ]; |
|
| 1091 | 1091 | throw $this->createException($message, $this->overrideCode ?: self::INVALID_MAX_LENGTH, $propertyPath, $constraints); |
| 1092 | 1092 | } |
| 1093 | 1093 | return $this; |
@@ -1105,20 +1105,20 @@ discard block |
||
| 1105 | 1105 | */ |
| 1106 | 1106 | public function startsWith($needle, $message = null, $propertyPath = null, $encoding = 'utf8') |
| 1107 | 1107 | { |
| 1108 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1108 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1109 | 1109 | { |
| 1110 | 1110 | return $this; |
| 1111 | 1111 | } |
| 1112 | 1112 | $this->string($message, $propertyPath); |
| 1113 | - if ( mb_strpos($this->value, $needle, null, $encoding) !== 0 ) |
|
| 1113 | + if (mb_strpos($this->value, $needle, null, $encoding) !== 0) |
|
| 1114 | 1114 | { |
| 1115 | 1115 | $message = $message ?: $this->overrideError; |
| 1116 | - $message = sprintf( |
|
| 1116 | + $message = sprintf( |
|
| 1117 | 1117 | $message ?: 'Value "%s" does not start with "%s".', |
| 1118 | 1118 | $this->stringify($this->value), |
| 1119 | 1119 | $this->stringify($needle) |
| 1120 | 1120 | ); |
| 1121 | - $constraints = ['needle' => $needle, 'encoding' => $encoding]; |
|
| 1121 | + $constraints = [ 'needle' => $needle, 'encoding' => $encoding ]; |
|
| 1122 | 1122 | throw $this->createException($message, $this->overrideCode ?: self::INVALID_STRING_START, $propertyPath, $constraints); |
| 1123 | 1123 | } |
| 1124 | 1124 | return $this; |
@@ -1136,21 +1136,21 @@ discard block |
||
| 1136 | 1136 | */ |
| 1137 | 1137 | public function endsWith($needle, $message = null, $propertyPath = null, $encoding = 'utf8') |
| 1138 | 1138 | { |
| 1139 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1139 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1140 | 1140 | { |
| 1141 | 1141 | return $this; |
| 1142 | 1142 | } |
| 1143 | 1143 | $this->string($message, $propertyPath); |
| 1144 | 1144 | $stringPosition = mb_strlen($this->value, $encoding) - mb_strlen($needle, $encoding); |
| 1145 | - if ( mb_strripos($this->value, $needle, null, $encoding) !== $stringPosition ) |
|
| 1145 | + if (mb_strripos($this->value, $needle, null, $encoding) !== $stringPosition) |
|
| 1146 | 1146 | { |
| 1147 | 1147 | $message = $message ?: $this->overrideError; |
| 1148 | - $message = sprintf( |
|
| 1148 | + $message = sprintf( |
|
| 1149 | 1149 | $message ?: 'Value "%s" does not end with "%s".', |
| 1150 | 1150 | $this->stringify($this->value), |
| 1151 | 1151 | $this->stringify($needle) |
| 1152 | 1152 | ); |
| 1153 | - $constraints = ['needle' => $needle, 'encoding' => $encoding]; |
|
| 1153 | + $constraints = [ 'needle' => $needle, 'encoding' => $encoding ]; |
|
| 1154 | 1154 | throw $this->createException($message, $this->overrideCode ?: self::INVALID_STRING_END, $propertyPath, $constraints); |
| 1155 | 1155 | } |
| 1156 | 1156 | return $this; |
@@ -1168,20 +1168,20 @@ discard block |
||
| 1168 | 1168 | */ |
| 1169 | 1169 | public function contains($needle, $message = null, $propertyPath = null, $encoding = 'utf8') |
| 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, $propertyPath); |
| 1176 | - if ( mb_strpos($this->value, $needle, null, $encoding) === false ) |
|
| 1176 | + if (mb_strpos($this->value, $needle, null, $encoding) === false) |
|
| 1177 | 1177 | { |
| 1178 | 1178 | $message = $message ?: $this->overrideError; |
| 1179 | - $message = sprintf( |
|
| 1179 | + $message = sprintf( |
|
| 1180 | 1180 | $message ?: 'Value "%s" does not contain "%s".', |
| 1181 | 1181 | $this->stringify($this->value), |
| 1182 | 1182 | $this->stringify($needle) |
| 1183 | 1183 | ); |
| 1184 | - $constraints = ['needle' => $needle, 'encoding' => $encoding]; |
|
| 1184 | + $constraints = [ 'needle' => $needle, 'encoding' => $encoding ]; |
|
| 1185 | 1185 | throw $this->createException($message, $this->overrideCode ?: self::INVALID_STRING_CONTAINS, $propertyPath, $constraints); |
| 1186 | 1186 | } |
| 1187 | 1187 | return $this; |
@@ -1198,11 +1198,11 @@ discard block |
||
| 1198 | 1198 | */ |
| 1199 | 1199 | public function choice(array $choices, $message = null, $propertyPath = null) |
| 1200 | 1200 | { |
| 1201 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1201 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1202 | 1202 | { |
| 1203 | 1203 | return $this; |
| 1204 | 1204 | } |
| 1205 | - if ( !in_array($this->value, $choices, true) ) |
|
| 1205 | + if ( ! in_array($this->value, $choices, true)) |
|
| 1206 | 1206 | { |
| 1207 | 1207 | $message = $message ?: $this->overrideError; |
| 1208 | 1208 | $message = sprintf( |
@@ -1210,7 +1210,7 @@ discard block |
||
| 1210 | 1210 | $this->stringify($this->value), |
| 1211 | 1211 | implode(", ", array_map('Terah\Assert\Assert::stringify', $choices)) |
| 1212 | 1212 | ); |
| 1213 | - throw $this->createException($message, $this->overrideCode ?: self::INVALID_CHOICE, $propertyPath, ['choices' => $choices]); |
|
| 1213 | + throw $this->createException($message, $this->overrideCode ?: self::INVALID_CHOICE, $propertyPath, [ 'choices' => $choices ]); |
|
| 1214 | 1214 | } |
| 1215 | 1215 | return $this; |
| 1216 | 1216 | } |
@@ -1227,7 +1227,7 @@ discard block |
||
| 1227 | 1227 | */ |
| 1228 | 1228 | public function inArray(array $choices, $message = null, $propertyPath = null) |
| 1229 | 1229 | { |
| 1230 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1230 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1231 | 1231 | { |
| 1232 | 1232 | return $this; |
| 1233 | 1233 | } |
@@ -1245,11 +1245,11 @@ discard block |
||
| 1245 | 1245 | */ |
| 1246 | 1246 | public function numeric($message = null, $propertyPath = null) |
| 1247 | 1247 | { |
| 1248 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1248 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1249 | 1249 | { |
| 1250 | 1250 | return $this; |
| 1251 | 1251 | } |
| 1252 | - if ( ! is_numeric($this->value) ) |
|
| 1252 | + if ( ! is_numeric($this->value)) |
|
| 1253 | 1253 | { |
| 1254 | 1254 | $message = $message ?: $this->overrideError; |
| 1255 | 1255 | $message = sprintf( |
@@ -1307,11 +1307,11 @@ discard block |
||
| 1307 | 1307 | */ |
| 1308 | 1308 | public function isArray($message = null, $propertyPath = null) |
| 1309 | 1309 | { |
| 1310 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1310 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1311 | 1311 | { |
| 1312 | 1312 | return $this; |
| 1313 | 1313 | } |
| 1314 | - if ( !is_array($this->value) ) |
|
| 1314 | + if ( ! is_array($this->value)) |
|
| 1315 | 1315 | { |
| 1316 | 1316 | $message = $message ?: $this->overrideError; |
| 1317 | 1317 | $message = sprintf( |
@@ -1333,11 +1333,11 @@ discard block |
||
| 1333 | 1333 | */ |
| 1334 | 1334 | public function isTraversable($message = null, $propertyPath = null) |
| 1335 | 1335 | { |
| 1336 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1336 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1337 | 1337 | { |
| 1338 | 1338 | return $this; |
| 1339 | 1339 | } |
| 1340 | - if ( !is_array($this->value) && !$this->value instanceof \Traversable ) |
|
| 1340 | + if ( ! is_array($this->value) && ! $this->value instanceof \Traversable) |
|
| 1341 | 1341 | { |
| 1342 | 1342 | $message = $message ?: $this->overrideError; |
| 1343 | 1343 | $message = sprintf( |
@@ -1359,11 +1359,11 @@ discard block |
||
| 1359 | 1359 | */ |
| 1360 | 1360 | public function isArrayAccessible($message = null, $propertyPath = null) |
| 1361 | 1361 | { |
| 1362 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1362 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1363 | 1363 | { |
| 1364 | 1364 | return $this; |
| 1365 | 1365 | } |
| 1366 | - if ( !is_array($this->value) && !$this->value instanceof \ArrayAccess ) |
|
| 1366 | + if ( ! is_array($this->value) && ! $this->value instanceof \ArrayAccess) |
|
| 1367 | 1367 | { |
| 1368 | 1368 | $message = $message ?: $this->overrideError; |
| 1369 | 1369 | $message = sprintf( |
@@ -1386,19 +1386,19 @@ discard block |
||
| 1386 | 1386 | */ |
| 1387 | 1387 | public function keyExists($key, $message = null, $propertyPath = null) |
| 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 | 1393 | $this->isArray($message, $propertyPath); |
| 1394 | - if ( !array_key_exists($key, $this->value) ) |
|
| 1394 | + if ( ! array_key_exists($key, $this->value)) |
|
| 1395 | 1395 | { |
| 1396 | 1396 | $message = $message ?: $this->overrideError; |
| 1397 | 1397 | $message = sprintf( |
| 1398 | 1398 | $message ?: 'Array does not contain an element with key "%s"', |
| 1399 | 1399 | $this->stringify($key) |
| 1400 | 1400 | ); |
| 1401 | - throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEY_EXISTS, $propertyPath, ['key' => $key]); |
|
| 1401 | + throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEY_EXISTS, $propertyPath, [ 'key' => $key ]); |
|
| 1402 | 1402 | } |
| 1403 | 1403 | return $this; |
| 1404 | 1404 | } |
@@ -1414,21 +1414,21 @@ discard block |
||
| 1414 | 1414 | */ |
| 1415 | 1415 | public function keysExist($keys, $message = null, $propertyPath = null) |
| 1416 | 1416 | { |
| 1417 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1417 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1418 | 1418 | { |
| 1419 | 1419 | return $this; |
| 1420 | 1420 | } |
| 1421 | 1421 | $this->isArray($message, $propertyPath); |
| 1422 | - foreach ( $keys as $key ) |
|
| 1422 | + foreach ($keys as $key) |
|
| 1423 | 1423 | { |
| 1424 | - if ( !array_key_exists($key, $this->value) ) |
|
| 1424 | + if ( ! array_key_exists($key, $this->value)) |
|
| 1425 | 1425 | { |
| 1426 | 1426 | $message = $message |
| 1427 | 1427 | ?: sprintf( |
| 1428 | 1428 | 'Array does not contain an element with key "%s"', |
| 1429 | 1429 | $this->stringify($key) |
| 1430 | 1430 | ); |
| 1431 | - throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEYS_EXIST, $propertyPath, ['key' => $key]); |
|
| 1431 | + throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEYS_EXIST, $propertyPath, [ 'key' => $key ]); |
|
| 1432 | 1432 | } |
| 1433 | 1433 | } |
| 1434 | 1434 | return $this; |
@@ -1445,19 +1445,19 @@ discard block |
||
| 1445 | 1445 | */ |
| 1446 | 1446 | public function propertyExists($key, $message = null, $propertyPath = null) |
| 1447 | 1447 | { |
| 1448 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1448 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1449 | 1449 | { |
| 1450 | 1450 | return $this; |
| 1451 | 1451 | } |
| 1452 | 1452 | $this->isObject($message, $propertyPath); |
| 1453 | - if ( !property_exists($this->value, $key) && !isset( $this->value->{$key} ) ) |
|
| 1453 | + if ( ! property_exists($this->value, $key) && ! isset($this->value->{$key} )) |
|
| 1454 | 1454 | { |
| 1455 | 1455 | $message = $message |
| 1456 | 1456 | ?: sprintf( |
| 1457 | 1457 | 'Object does not contain a property with key "%s"', |
| 1458 | 1458 | $this->stringify($key) |
| 1459 | 1459 | ); |
| 1460 | - throw $this->createException($message, $this->overrideCode ?: self::INVALID_PROPERTY_EXISTS, $propertyPath, ['key' => $key]); |
|
| 1460 | + throw $this->createException($message, $this->overrideCode ?: self::INVALID_PROPERTY_EXISTS, $propertyPath, [ 'key' => $key ]); |
|
| 1461 | 1461 | } |
| 1462 | 1462 | return $this; |
| 1463 | 1463 | } |
@@ -1473,22 +1473,22 @@ discard block |
||
| 1473 | 1473 | */ |
| 1474 | 1474 | public function propertiesExist(array $keys, $message = null, $propertyPath = null) |
| 1475 | 1475 | { |
| 1476 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1476 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1477 | 1477 | { |
| 1478 | 1478 | return $this; |
| 1479 | 1479 | } |
| 1480 | 1480 | $this->isObject($message, $propertyPath); |
| 1481 | - foreach ( $keys as $key ) |
|
| 1481 | + foreach ($keys as $key) |
|
| 1482 | 1482 | { |
| 1483 | 1483 | // Using isset to allow resolution of magically defined properties |
| 1484 | - if ( !property_exists($this->value, $key) && !isset( $this->value->{$key} ) ) |
|
| 1484 | + if ( ! property_exists($this->value, $key) && ! isset($this->value->{$key} )) |
|
| 1485 | 1485 | { |
| 1486 | 1486 | $message = $message |
| 1487 | 1487 | ?: sprintf( |
| 1488 | 1488 | 'Object does not contain a property with key "%s"', |
| 1489 | 1489 | $this->stringify($key) |
| 1490 | 1490 | ); |
| 1491 | - throw $this->createException($message, $this->overrideCode ?: self::INVALID_PROPERTIES_EXIST, $propertyPath, ['key' => $key]); |
|
| 1491 | + throw $this->createException($message, $this->overrideCode ?: self::INVALID_PROPERTIES_EXIST, $propertyPath, [ 'key' => $key ]); |
|
| 1492 | 1492 | } |
| 1493 | 1493 | } |
| 1494 | 1494 | return $this; |
@@ -1504,12 +1504,12 @@ discard block |
||
| 1504 | 1504 | */ |
| 1505 | 1505 | public function utf8($message = null, $propertyPath = null) |
| 1506 | 1506 | { |
| 1507 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1507 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1508 | 1508 | { |
| 1509 | 1509 | return $this; |
| 1510 | 1510 | } |
| 1511 | 1511 | $this->string($message, $propertyPath); |
| 1512 | - if ( mb_detect_encoding($this->value, 'UTF-8', true) !== 'UTF-8' ) |
|
| 1512 | + if (mb_detect_encoding($this->value, 'UTF-8', true) !== 'UTF-8') |
|
| 1513 | 1513 | { |
| 1514 | 1514 | $message = $message |
| 1515 | 1515 | ?: sprintf( |
@@ -1532,12 +1532,12 @@ discard block |
||
| 1532 | 1532 | */ |
| 1533 | 1533 | public function ascii($message = null, $propertyPath = null) |
| 1534 | 1534 | { |
| 1535 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1535 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1536 | 1536 | { |
| 1537 | 1537 | return $this; |
| 1538 | 1538 | } |
| 1539 | 1539 | $this->string($message, $propertyPath); |
| 1540 | - if ( ! preg_match('/^[ -~]+$/', $this->value) ) |
|
| 1540 | + if ( ! preg_match('/^[ -~]+$/', $this->value)) |
|
| 1541 | 1541 | { |
| 1542 | 1542 | $message = $message |
| 1543 | 1543 | ?: sprintf( |
@@ -1560,19 +1560,19 @@ discard block |
||
| 1560 | 1560 | */ |
| 1561 | 1561 | public function keyIsset($key, $message = null, $propertyPath = null) |
| 1562 | 1562 | { |
| 1563 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1563 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1564 | 1564 | { |
| 1565 | 1565 | return $this; |
| 1566 | 1566 | } |
| 1567 | 1567 | $this->isArrayAccessible($message, $propertyPath); |
| 1568 | - if ( !isset( $this->value[$key] ) ) |
|
| 1568 | + if ( ! isset($this->value[ $key ])) |
|
| 1569 | 1569 | { |
| 1570 | 1570 | $message = $message ?: $this->overrideError; |
| 1571 | 1571 | $message = sprintf( |
| 1572 | 1572 | $message ?: 'The element with key "%s" was not found', |
| 1573 | 1573 | $this->stringify($key) |
| 1574 | 1574 | ); |
| 1575 | - throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEY_ISSET, $propertyPath, ['key' => $key]); |
|
| 1575 | + throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEY_ISSET, $propertyPath, [ 'key' => $key ]); |
|
| 1576 | 1576 | } |
| 1577 | 1577 | return $this; |
| 1578 | 1578 | } |
@@ -1588,12 +1588,12 @@ discard block |
||
| 1588 | 1588 | */ |
| 1589 | 1589 | public function notEmptyKey($key, $message = null, $propertyPath = null) |
| 1590 | 1590 | { |
| 1591 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1591 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1592 | 1592 | { |
| 1593 | 1593 | return $this; |
| 1594 | 1594 | } |
| 1595 | 1595 | $this->keyIsset($key, $message, $propertyPath); |
| 1596 | - (new Assert($this->value[$key]))->setExceptionClass($this->exceptionClass)->notEmpty($message, $propertyPath); |
|
| 1596 | + (new Assert($this->value[ $key ]))->setExceptionClass($this->exceptionClass)->notEmpty($message, $propertyPath); |
|
| 1597 | 1597 | return $this; |
| 1598 | 1598 | } |
| 1599 | 1599 | |
@@ -1607,11 +1607,11 @@ discard block |
||
| 1607 | 1607 | */ |
| 1608 | 1608 | public function notBlank($message = null, $propertyPath = null) |
| 1609 | 1609 | { |
| 1610 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1610 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1611 | 1611 | { |
| 1612 | 1612 | return $this; |
| 1613 | 1613 | } |
| 1614 | - if ( false === $this->value || ( empty( $this->value ) && '0' != $this->value ) ) |
|
| 1614 | + if (false === $this->value || (empty($this->value) && '0' != $this->value)) |
|
| 1615 | 1615 | { |
| 1616 | 1616 | $message = $message ?: $this->overrideError; |
| 1617 | 1617 | $message = sprintf( |
@@ -1634,11 +1634,11 @@ discard block |
||
| 1634 | 1634 | */ |
| 1635 | 1635 | public function isInstanceOf($className, $message = null, $propertyPath = null) |
| 1636 | 1636 | { |
| 1637 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1637 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1638 | 1638 | { |
| 1639 | 1639 | return $this; |
| 1640 | 1640 | } |
| 1641 | - if ( !( $this->value instanceof $className ) ) |
|
| 1641 | + if ( ! ($this->value instanceof $className)) |
|
| 1642 | 1642 | { |
| 1643 | 1643 | $message = $message ?: $this->overrideError; |
| 1644 | 1644 | $message = sprintf( |
@@ -1646,7 +1646,7 @@ discard block |
||
| 1646 | 1646 | $this->stringify($this->value), |
| 1647 | 1647 | $className |
| 1648 | 1648 | ); |
| 1649 | - throw $this->createException($message, $this->overrideCode ?: self::INVALID_INSTANCE_OF, $propertyPath, ['class' => $className]); |
|
| 1649 | + throw $this->createException($message, $this->overrideCode ?: self::INVALID_INSTANCE_OF, $propertyPath, [ 'class' => $className ]); |
|
| 1650 | 1650 | } |
| 1651 | 1651 | return $this; |
| 1652 | 1652 | } |
@@ -1662,11 +1662,11 @@ discard block |
||
| 1662 | 1662 | */ |
| 1663 | 1663 | public function notIsInstanceOf($className, $message = null, $propertyPath = null) |
| 1664 | 1664 | { |
| 1665 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1665 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1666 | 1666 | { |
| 1667 | 1667 | return $this; |
| 1668 | 1668 | } |
| 1669 | - if ( $this->value instanceof $className ) |
|
| 1669 | + if ($this->value instanceof $className) |
|
| 1670 | 1670 | { |
| 1671 | 1671 | $message = $message ?: $this->overrideError; |
| 1672 | 1672 | $message = sprintf( |
@@ -1674,7 +1674,7 @@ discard block |
||
| 1674 | 1674 | $this->stringify($this->value), |
| 1675 | 1675 | $className |
| 1676 | 1676 | ); |
| 1677 | - throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_INSTANCE_OF, $propertyPath, ['class' => $className]); |
|
| 1677 | + throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_INSTANCE_OF, $propertyPath, [ 'class' => $className ]); |
|
| 1678 | 1678 | } |
| 1679 | 1679 | return $this; |
| 1680 | 1680 | } |
@@ -1690,11 +1690,11 @@ discard block |
||
| 1690 | 1690 | */ |
| 1691 | 1691 | public function subclassOf($className, $message = null, $propertyPath = null) |
| 1692 | 1692 | { |
| 1693 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1693 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1694 | 1694 | { |
| 1695 | 1695 | return $this; |
| 1696 | 1696 | } |
| 1697 | - if ( !is_subclass_of($this->value, $className) ) |
|
| 1697 | + if ( ! is_subclass_of($this->value, $className)) |
|
| 1698 | 1698 | { |
| 1699 | 1699 | $message = $message ?: $this->overrideError; |
| 1700 | 1700 | $message = sprintf( |
@@ -1702,7 +1702,7 @@ discard block |
||
| 1702 | 1702 | $this->stringify($this->value), |
| 1703 | 1703 | $className |
| 1704 | 1704 | ); |
| 1705 | - throw $this->createException($message, $this->overrideCode ?: self::INVALID_SUBCLASS_OF, $propertyPath, ['class' => $className]); |
|
| 1705 | + throw $this->createException($message, $this->overrideCode ?: self::INVALID_SUBCLASS_OF, $propertyPath, [ 'class' => $className ]); |
|
| 1706 | 1706 | } |
| 1707 | 1707 | return $this; |
| 1708 | 1708 | } |
@@ -1719,12 +1719,12 @@ discard block |
||
| 1719 | 1719 | */ |
| 1720 | 1720 | public function range($minValue, $maxValue, $message = null, $propertyPath = null) |
| 1721 | 1721 | { |
| 1722 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1722 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1723 | 1723 | { |
| 1724 | 1724 | return $this; |
| 1725 | 1725 | } |
| 1726 | 1726 | $this->numeric($message, $propertyPath); |
| 1727 | - if ( $this->value < $minValue || $this->value > $maxValue ) |
|
| 1727 | + if ($this->value < $minValue || $this->value > $maxValue) |
|
| 1728 | 1728 | { |
| 1729 | 1729 | $message = $message ?: $this->overrideError; |
| 1730 | 1730 | $message = sprintf( |
@@ -1752,12 +1752,12 @@ discard block |
||
| 1752 | 1752 | */ |
| 1753 | 1753 | public function min($minValue, $message = null, $propertyPath = null) |
| 1754 | 1754 | { |
| 1755 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1755 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1756 | 1756 | { |
| 1757 | 1757 | return $this; |
| 1758 | 1758 | } |
| 1759 | 1759 | $this->numeric($message, $propertyPath); |
| 1760 | - if ( $this->value < $minValue ) |
|
| 1760 | + if ($this->value < $minValue) |
|
| 1761 | 1761 | { |
| 1762 | 1762 | $message = $message ?: $this->overrideError; |
| 1763 | 1763 | $message = sprintf( |
@@ -1765,7 +1765,7 @@ discard block |
||
| 1765 | 1765 | $this->stringify($this->value), |
| 1766 | 1766 | $this->stringify($minValue) |
| 1767 | 1767 | ); |
| 1768 | - throw $this->createException($message, $this->overrideCode ?: self::INVALID_MIN, $propertyPath, ['min' => $minValue]); |
|
| 1768 | + throw $this->createException($message, $this->overrideCode ?: self::INVALID_MIN, $propertyPath, [ 'min' => $minValue ]); |
|
| 1769 | 1769 | } |
| 1770 | 1770 | return $this; |
| 1771 | 1771 | } |
@@ -1781,12 +1781,12 @@ discard block |
||
| 1781 | 1781 | */ |
| 1782 | 1782 | public function max($maxValue, $message = null, $propertyPath = null) |
| 1783 | 1783 | { |
| 1784 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1784 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1785 | 1785 | { |
| 1786 | 1786 | return $this; |
| 1787 | 1787 | } |
| 1788 | 1788 | $this->numeric($message, $propertyPath); |
| 1789 | - if ( $this->value > $maxValue ) |
|
| 1789 | + if ($this->value > $maxValue) |
|
| 1790 | 1790 | { |
| 1791 | 1791 | $message = $message ?: $this->overrideError; |
| 1792 | 1792 | $message = sprintf( |
@@ -1794,7 +1794,7 @@ discard block |
||
| 1794 | 1794 | $this->stringify($this->value), |
| 1795 | 1795 | $this->stringify($maxValue) |
| 1796 | 1796 | ); |
| 1797 | - throw $this->createException($message, $this->overrideCode ?: self::INVALID_MAX, $propertyPath, ['max' => $maxValue]); |
|
| 1797 | + throw $this->createException($message, $this->overrideCode ?: self::INVALID_MAX, $propertyPath, [ 'max' => $maxValue ]); |
|
| 1798 | 1798 | } |
| 1799 | 1799 | return $this; |
| 1800 | 1800 | } |
@@ -1809,13 +1809,13 @@ discard block |
||
| 1809 | 1809 | */ |
| 1810 | 1810 | public function file($message = null, $propertyPath = null) |
| 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->string($message, $propertyPath); |
| 1817 | 1817 | $this->notEmpty($message, $propertyPath); |
| 1818 | - if ( !is_file($this->value) ) |
|
| 1818 | + if ( ! is_file($this->value)) |
|
| 1819 | 1819 | { |
| 1820 | 1820 | $message = $message ?: $this->overrideError; |
| 1821 | 1821 | $message = sprintf( |
@@ -1835,13 +1835,13 @@ discard block |
||
| 1835 | 1835 | */ |
| 1836 | 1836 | public function fileExists($message = null, $propertyPath = null) |
| 1837 | 1837 | { |
| 1838 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1838 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1839 | 1839 | { |
| 1840 | 1840 | return $this; |
| 1841 | 1841 | } |
| 1842 | 1842 | $this->string($message, $propertyPath); |
| 1843 | 1843 | $this->notEmpty($message, $propertyPath); |
| 1844 | - if ( ! file_exists($this->value) ) |
|
| 1844 | + if ( ! file_exists($this->value)) |
|
| 1845 | 1845 | { |
| 1846 | 1846 | $message = $message ?: $this->overrideError; |
| 1847 | 1847 | $message = sprintf( |
@@ -1863,12 +1863,12 @@ discard block |
||
| 1863 | 1863 | */ |
| 1864 | 1864 | public function directory($message = null, $propertyPath = null) |
| 1865 | 1865 | { |
| 1866 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1866 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1867 | 1867 | { |
| 1868 | 1868 | return $this; |
| 1869 | 1869 | } |
| 1870 | 1870 | $this->string($message, $propertyPath); |
| 1871 | - if ( !is_dir($this->value) ) |
|
| 1871 | + if ( ! is_dir($this->value)) |
|
| 1872 | 1872 | { |
| 1873 | 1873 | $message = $message ?: $this->overrideError; |
| 1874 | 1874 | $message = sprintf( |
@@ -1890,12 +1890,12 @@ discard block |
||
| 1890 | 1890 | */ |
| 1891 | 1891 | public function readable($message = null, $propertyPath = null) |
| 1892 | 1892 | { |
| 1893 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1893 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1894 | 1894 | { |
| 1895 | 1895 | return $this; |
| 1896 | 1896 | } |
| 1897 | 1897 | $this->string($message, $propertyPath); |
| 1898 | - if ( !is_readable($this->value) ) |
|
| 1898 | + if ( ! is_readable($this->value)) |
|
| 1899 | 1899 | { |
| 1900 | 1900 | $message = $message ?: $this->overrideError; |
| 1901 | 1901 | $message = sprintf( |
@@ -1917,12 +1917,12 @@ discard block |
||
| 1917 | 1917 | */ |
| 1918 | 1918 | public function writeable($message = null, $propertyPath = null) |
| 1919 | 1919 | { |
| 1920 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1920 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1921 | 1921 | { |
| 1922 | 1922 | return $this; |
| 1923 | 1923 | } |
| 1924 | 1924 | $this->string($message, $propertyPath); |
| 1925 | - if ( !is_writeable($this->value) ) |
|
| 1925 | + if ( ! is_writeable($this->value)) |
|
| 1926 | 1926 | { |
| 1927 | 1927 | $message = $message ?: $this->overrideError; |
| 1928 | 1928 | $message = sprintf( |
@@ -1945,12 +1945,12 @@ discard block |
||
| 1945 | 1945 | */ |
| 1946 | 1946 | public function email($message = null, $propertyPath = null) |
| 1947 | 1947 | { |
| 1948 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1948 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1949 | 1949 | { |
| 1950 | 1950 | return $this; |
| 1951 | 1951 | } |
| 1952 | 1952 | $this->string($message, $propertyPath); |
| 1953 | - if ( ! filter_var($this->value, FILTER_VALIDATE_EMAIL) ) |
|
| 1953 | + if ( ! filter_var($this->value, FILTER_VALIDATE_EMAIL)) |
|
| 1954 | 1954 | { |
| 1955 | 1955 | $message = $message ?: $this->overrideError; |
| 1956 | 1956 | $message = sprintf( |
@@ -1963,7 +1963,7 @@ discard block |
||
| 1963 | 1963 | { |
| 1964 | 1964 | $host = substr($this->value, strpos($this->value, '@') + 1); |
| 1965 | 1965 | // Likely not a FQDN, bug in PHP FILTER_VALIDATE_EMAIL prior to PHP 5.3.3 |
| 1966 | - if ( version_compare(PHP_VERSION, '5.3.3', '<') && strpos($host, '.') === false ) |
|
| 1966 | + if (version_compare(PHP_VERSION, '5.3.3', '<') && strpos($host, '.') === false) |
|
| 1967 | 1967 | { |
| 1968 | 1968 | $message = $message ?: $this->overrideError; |
| 1969 | 1969 | $message = sprintf( |
@@ -1984,7 +1984,7 @@ discard block |
||
| 1984 | 1984 | */ |
| 1985 | 1985 | public function emailPrefix($message = null, $propertyPath = null) |
| 1986 | 1986 | { |
| 1987 | - $this->value($this->value . '@example.com'); |
|
| 1987 | + $this->value($this->value.'@example.com'); |
|
| 1988 | 1988 | return $this->email($message, $propertyPath); |
| 1989 | 1989 | } |
| 1990 | 1990 | |
@@ -2004,12 +2004,12 @@ discard block |
||
| 2004 | 2004 | */ |
| 2005 | 2005 | public function url($message = null, $propertyPath = null) |
| 2006 | 2006 | { |
| 2007 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 2007 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 2008 | 2008 | { |
| 2009 | 2009 | return $this; |
| 2010 | 2010 | } |
| 2011 | 2011 | $this->string($message, $propertyPath); |
| 2012 | - $protocols = ['http', 'https']; |
|
| 2012 | + $protocols = [ 'http', 'https' ]; |
|
| 2013 | 2013 | $pattern = '~^ |
| 2014 | 2014 | (%s):// # protocol |
| 2015 | 2015 | ( |
@@ -2024,8 +2024,8 @@ discard block |
||
| 2024 | 2024 | (:[0-9]+)? # a port (optional) |
| 2025 | 2025 | (/?|/\S+) # a /, nothing or a / with something |
| 2026 | 2026 | $~ixu'; |
| 2027 | - $pattern = sprintf($pattern, implode('|', $protocols)); |
|
| 2028 | - if ( !preg_match($pattern, $this->value) ) |
|
| 2027 | + $pattern = sprintf($pattern, implode('|', $protocols)); |
|
| 2028 | + if ( ! preg_match($pattern, $this->value)) |
|
| 2029 | 2029 | { |
| 2030 | 2030 | $message = $message ?: $this->overrideError; |
| 2031 | 2031 | $message = sprintf( |
@@ -2050,13 +2050,13 @@ discard block |
||
| 2050 | 2050 | */ |
| 2051 | 2051 | public function domainName($message = null, $propertyPath = null) |
| 2052 | 2052 | { |
| 2053 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 2053 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 2054 | 2054 | { |
| 2055 | 2055 | return $this; |
| 2056 | 2056 | } |
| 2057 | 2057 | $this->string($message, $propertyPath); |
| 2058 | - $pattern = '/^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}$/'; |
|
| 2059 | - if ( ! preg_match($pattern, $this->value) ) |
|
| 2058 | + $pattern = '/^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}$/'; |
|
| 2059 | + if ( ! preg_match($pattern, $this->value)) |
|
| 2060 | 2060 | { |
| 2061 | 2061 | $message = $message ?: $this->overrideError; |
| 2062 | 2062 | $message = sprintf( |
@@ -2078,7 +2078,7 @@ discard block |
||
| 2078 | 2078 | */ |
| 2079 | 2079 | public function alnum($message = null, $propertyPath = null) |
| 2080 | 2080 | { |
| 2081 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 2081 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 2082 | 2082 | { |
| 2083 | 2083 | return $this; |
| 2084 | 2084 | } |
@@ -2109,11 +2109,11 @@ discard block |
||
| 2109 | 2109 | */ |
| 2110 | 2110 | public function true($message = null, $propertyPath = null) |
| 2111 | 2111 | { |
| 2112 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 2112 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 2113 | 2113 | { |
| 2114 | 2114 | return $this; |
| 2115 | 2115 | } |
| 2116 | - if ( $this->value !== true ) |
|
| 2116 | + if ($this->value !== true) |
|
| 2117 | 2117 | { |
| 2118 | 2118 | $message = $message ?: $this->overrideError; |
| 2119 | 2119 | $message = sprintf( |
@@ -2135,11 +2135,11 @@ discard block |
||
| 2135 | 2135 | */ |
| 2136 | 2136 | public function truthy($message = null, $propertyPath = null) |
| 2137 | 2137 | { |
| 2138 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 2138 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 2139 | 2139 | { |
| 2140 | 2140 | return $this; |
| 2141 | 2141 | } |
| 2142 | - if ( ! $this->value ) |
|
| 2142 | + if ( ! $this->value) |
|
| 2143 | 2143 | { |
| 2144 | 2144 | $message = $message ?: $this->overrideError; |
| 2145 | 2145 | $message = sprintf( |
@@ -2161,11 +2161,11 @@ discard block |
||
| 2161 | 2161 | */ |
| 2162 | 2162 | public function false($message = null, $propertyPath = null) |
| 2163 | 2163 | { |
| 2164 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 2164 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 2165 | 2165 | { |
| 2166 | 2166 | return $this; |
| 2167 | 2167 | } |
| 2168 | - if ( $this->value !== false ) |
|
| 2168 | + if ($this->value !== false) |
|
| 2169 | 2169 | { |
| 2170 | 2170 | $message = $message ?: $this->overrideError; |
| 2171 | 2171 | $message = sprintf( |
@@ -2187,11 +2187,11 @@ discard block |
||
| 2187 | 2187 | */ |
| 2188 | 2188 | public function notFalse($message = null, $propertyPath = null) |
| 2189 | 2189 | { |
| 2190 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 2190 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 2191 | 2191 | { |
| 2192 | 2192 | return $this; |
| 2193 | 2193 | } |
| 2194 | - if ( $this->value === false ) |
|
| 2194 | + if ($this->value === false) |
|
| 2195 | 2195 | { |
| 2196 | 2196 | $message = $message ?: $this->overrideError; |
| 2197 | 2197 | $message = sprintf( |
@@ -2213,11 +2213,11 @@ discard block |
||
| 2213 | 2213 | */ |
| 2214 | 2214 | public function classExists($message = null, $propertyPath = null) |
| 2215 | 2215 | { |
| 2216 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 2216 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 2217 | 2217 | { |
| 2218 | 2218 | return $this; |
| 2219 | 2219 | } |
| 2220 | - if ( !class_exists($this->value) ) |
|
| 2220 | + if ( ! class_exists($this->value)) |
|
| 2221 | 2221 | { |
| 2222 | 2222 | $message = $message ?: $this->overrideError; |
| 2223 | 2223 | $message = sprintf( |
@@ -2240,12 +2240,12 @@ discard block |
||
| 2240 | 2240 | */ |
| 2241 | 2241 | public function implementsInterface($interfaceName, $message = null, $propertyPath = null) |
| 2242 | 2242 | { |
| 2243 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 2243 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 2244 | 2244 | { |
| 2245 | 2245 | return $this; |
| 2246 | 2246 | } |
| 2247 | 2247 | $reflection = new \ReflectionClass($this->value); |
| 2248 | - if ( !$reflection->implementsInterface($interfaceName) ) |
|
| 2248 | + if ( ! $reflection->implementsInterface($interfaceName)) |
|
| 2249 | 2249 | { |
| 2250 | 2250 | $message = $message ?: $this->overrideError; |
| 2251 | 2251 | $message = sprintf( |
@@ -2253,7 +2253,7 @@ discard block |
||
| 2253 | 2253 | $this->stringify($this->value), |
| 2254 | 2254 | $this->stringify($interfaceName) |
| 2255 | 2255 | ); |
| 2256 | - throw $this->createException($message, self::INTERFACE_NOT_IMPLEMENTED, $propertyPath, ['interface' => $interfaceName]); |
|
| 2256 | + throw $this->createException($message, self::INTERFACE_NOT_IMPLEMENTED, $propertyPath, [ 'interface' => $interfaceName ]); |
|
| 2257 | 2257 | } |
| 2258 | 2258 | return $this; |
| 2259 | 2259 | } |
@@ -2274,11 +2274,11 @@ discard block |
||
| 2274 | 2274 | */ |
| 2275 | 2275 | public function isJsonString($message = null, $propertyPath = null) |
| 2276 | 2276 | { |
| 2277 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 2277 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 2278 | 2278 | { |
| 2279 | 2279 | return $this; |
| 2280 | 2280 | } |
| 2281 | - if ( null === json_decode($this->value) && JSON_ERROR_NONE !== json_last_error() ) |
|
| 2281 | + if (null === json_decode($this->value) && JSON_ERROR_NONE !== json_last_error()) |
|
| 2282 | 2282 | { |
| 2283 | 2283 | $message = $message ?: $this->overrideError; |
| 2284 | 2284 | $message = sprintf( |
@@ -2302,16 +2302,16 @@ discard block |
||
| 2302 | 2302 | */ |
| 2303 | 2303 | public function uuid($message = null, $propertyPath = null) |
| 2304 | 2304 | { |
| 2305 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 2305 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 2306 | 2306 | { |
| 2307 | 2307 | return $this; |
| 2308 | 2308 | } |
| 2309 | - $this->value = str_replace(['urn:', 'uuid:', '{', '}'], '', $this->value); |
|
| 2310 | - if ( $this->value === '00000000-0000-0000-0000-000000000000' ) |
|
| 2309 | + $this->value = str_replace([ 'urn:', 'uuid:', '{', '}' ], '', $this->value); |
|
| 2310 | + if ($this->value === '00000000-0000-0000-0000-000000000000') |
|
| 2311 | 2311 | { |
| 2312 | 2312 | return $this; |
| 2313 | 2313 | } |
| 2314 | - 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) ) |
|
| 2314 | + 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)) |
|
| 2315 | 2315 | { |
| 2316 | 2316 | $message = $message ?: $this->overrideError; |
| 2317 | 2317 | $message = sprintf( |
@@ -2334,11 +2334,11 @@ discard block |
||
| 2334 | 2334 | */ |
| 2335 | 2335 | public function count($count, $message = null, $propertyPath = null) |
| 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 | } |
| 2341 | - if ( $count !== count($this->value) ) |
|
| 2341 | + if ($count !== count($this->value)) |
|
| 2342 | 2342 | { |
| 2343 | 2343 | $message = $message ?: $this->overrideError; |
| 2344 | 2344 | $message = sprintf( |
@@ -2346,7 +2346,7 @@ discard block |
||
| 2346 | 2346 | $this->stringify($this->value), |
| 2347 | 2347 | $this->stringify($count) |
| 2348 | 2348 | ); |
| 2349 | - throw $this->createException($message, $this->overrideCode ?: self::INVALID_COUNT, $propertyPath, ['count' => $count]); |
|
| 2349 | + throw $this->createException($message, $this->overrideCode ?: self::INVALID_COUNT, $propertyPath, [ 'count' => $count ]); |
|
| 2350 | 2350 | } |
| 2351 | 2351 | return $this; |
| 2352 | 2352 | } |
@@ -2359,24 +2359,24 @@ discard block |
||
| 2359 | 2359 | */ |
| 2360 | 2360 | protected function doAllOrNullOr($func, $args) |
| 2361 | 2361 | { |
| 2362 | - if ( $this->nullOr && is_null($this->value) ) |
|
| 2362 | + if ($this->nullOr && is_null($this->value)) |
|
| 2363 | 2363 | { |
| 2364 | 2364 | return true; |
| 2365 | 2365 | } |
| 2366 | - if ( $this->emptyOr && empty($this->value) ) |
|
| 2366 | + if ($this->emptyOr && empty($this->value)) |
|
| 2367 | 2367 | { |
| 2368 | 2368 | return true; |
| 2369 | 2369 | } |
| 2370 | - if ( $this->all && (new Assert($this->value))->setExceptionClass($this->exceptionClass)->isTraversable() ) |
|
| 2370 | + if ($this->all && (new Assert($this->value))->setExceptionClass($this->exceptionClass)->isTraversable()) |
|
| 2371 | 2371 | { |
| 2372 | - foreach ( $this->value as $idx => $value ) |
|
| 2372 | + foreach ($this->value as $idx => $value) |
|
| 2373 | 2373 | { |
| 2374 | 2374 | $object = (new Assert($value))->setExceptionClass($this->exceptionClass); |
| 2375 | - call_user_func_array([$object, $func], $args); |
|
| 2375 | + call_user_func_array([ $object, $func ], $args); |
|
| 2376 | 2376 | } |
| 2377 | 2377 | return true; |
| 2378 | 2378 | } |
| 2379 | - return ( $this->nullOr && is_null($this->value) ) || ( $this->emptyOr && empty($this->value) ) ? true : false; |
|
| 2379 | + return ($this->nullOr && is_null($this->value)) || ($this->emptyOr && empty($this->value)) ? true : false; |
|
| 2380 | 2380 | } |
| 2381 | 2381 | |
| 2382 | 2382 | /** |
@@ -2389,12 +2389,12 @@ discard block |
||
| 2389 | 2389 | */ |
| 2390 | 2390 | public function choicesNotEmpty(array $choices, $message = null, $propertyPath = null) |
| 2391 | 2391 | { |
| 2392 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 2392 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 2393 | 2393 | { |
| 2394 | 2394 | return $this; |
| 2395 | 2395 | } |
| 2396 | 2396 | $this->notEmpty($message, $propertyPath); |
| 2397 | - foreach ( $choices as $choice ) |
|
| 2397 | + foreach ($choices as $choice) |
|
| 2398 | 2398 | { |
| 2399 | 2399 | $this->notEmptyKey($choice, $message, $propertyPath); |
| 2400 | 2400 | } |
@@ -2412,12 +2412,12 @@ discard block |
||
| 2412 | 2412 | */ |
| 2413 | 2413 | public function methodExists($object, $message = null, $propertyPath = null) |
| 2414 | 2414 | { |
| 2415 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 2415 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 2416 | 2416 | { |
| 2417 | 2417 | return $this; |
| 2418 | 2418 | } |
| 2419 | 2419 | (new Assert($object))->setExceptionClass($this->exceptionClass)->isObject($message, $propertyPath); |
| 2420 | - if ( !method_exists($object, $this->value) ) |
|
| 2420 | + if ( ! method_exists($object, $this->value)) |
|
| 2421 | 2421 | { |
| 2422 | 2422 | $message = $message ?: $this->overrideError; |
| 2423 | 2423 | $message = sprintf( |
@@ -2439,11 +2439,11 @@ discard block |
||
| 2439 | 2439 | */ |
| 2440 | 2440 | public function isObject($message = null, $propertyPath = null) |
| 2441 | 2441 | { |
| 2442 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 2442 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 2443 | 2443 | { |
| 2444 | 2444 | return $this; |
| 2445 | 2445 | } |
| 2446 | - if ( !is_object($this->value) ) |
|
| 2446 | + if ( ! is_object($this->value)) |
|
| 2447 | 2447 | { |
| 2448 | 2448 | $message = $message ?: $this->overrideError; |
| 2449 | 2449 | $message = sprintf( |
@@ -2463,32 +2463,32 @@ discard block |
||
| 2463 | 2463 | */ |
| 2464 | 2464 | private function stringify($value) |
| 2465 | 2465 | { |
| 2466 | - if ( is_bool($value) ) |
|
| 2466 | + if (is_bool($value)) |
|
| 2467 | 2467 | { |
| 2468 | 2468 | return $value ? '<TRUE>' : '<FALSE>'; |
| 2469 | 2469 | } |
| 2470 | - if ( is_scalar($value) ) |
|
| 2470 | + if (is_scalar($value)) |
|
| 2471 | 2471 | { |
| 2472 | 2472 | $val = (string)$value; |
| 2473 | - if ( strlen($val) > 100 ) |
|
| 2473 | + if (strlen($val) > 100) |
|
| 2474 | 2474 | { |
| 2475 | - $val = substr($val, 0, 97) . '...'; |
|
| 2475 | + $val = substr($val, 0, 97).'...'; |
|
| 2476 | 2476 | } |
| 2477 | 2477 | return $val; |
| 2478 | 2478 | } |
| 2479 | - if ( is_array($value) ) |
|
| 2479 | + if (is_array($value)) |
|
| 2480 | 2480 | { |
| 2481 | 2481 | return '<ARRAY>'; |
| 2482 | 2482 | } |
| 2483 | - if ( is_object($value) ) |
|
| 2483 | + if (is_object($value)) |
|
| 2484 | 2484 | { |
| 2485 | 2485 | return get_class($value); |
| 2486 | 2486 | } |
| 2487 | - if ( is_resource($value) ) |
|
| 2487 | + if (is_resource($value)) |
|
| 2488 | 2488 | { |
| 2489 | 2489 | return '<RESOURCE>'; |
| 2490 | 2490 | } |
| 2491 | - if ( $value === null ) |
|
| 2491 | + if ($value === null) |
|
| 2492 | 2492 | { |
| 2493 | 2493 | return '<NULL>'; |
| 2494 | 2494 | } |
@@ -7,10 +7,10 @@ discard block |
||
| 7 | 7 | * @param bool|false $throwValidationError |
| 8 | 8 | * @return Assert |
| 9 | 9 | */ |
| 10 | -function Assert($value, $throwValidationError=false) |
|
| 10 | +function Assert($value, $throwValidationError = false) |
|
| 11 | 11 | { |
| 12 | 12 | $assert = new Assert($value); |
| 13 | - if ( ! $throwValidationError ) |
|
| 13 | + if ( ! $throwValidationError) |
|
| 14 | 14 | { |
| 15 | 15 | return $assert; |
| 16 | 16 | } |
@@ -24,23 +24,23 @@ discard block |
||
| 24 | 24 | * @param string $error |
| 25 | 25 | * @return Assert |
| 26 | 26 | */ |
| 27 | -function Validate($value, $name='', $code=0, $error='', $level=Assert::WARNING) |
|
| 27 | +function Validate($value, $name = '', $code = 0, $error = '', $level = Assert::WARNING) |
|
| 28 | 28 | { |
| 29 | 29 | $assert = new Assert($value); |
| 30 | 30 | $assert->setExceptionClass('Terah\Assert\ValidationFailedException'); |
| 31 | - if ( $name ) |
|
| 31 | + if ($name) |
|
| 32 | 32 | { |
| 33 | 33 | $assert->name($name); |
| 34 | 34 | } |
| 35 | - if ( $code ) |
|
| 35 | + if ($code) |
|
| 36 | 36 | { |
| 37 | 37 | $assert->code($code); |
| 38 | 38 | } |
| 39 | - if ( $error ) |
|
| 39 | + if ($error) |
|
| 40 | 40 | { |
| 41 | 41 | $assert->error($error); |
| 42 | 42 | } |
| 43 | - if ( $level ) |
|
| 43 | + if ($level) |
|
| 44 | 44 | { |
| 45 | 45 | $assert->level($level); |
| 46 | 46 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | private $constraints; |
| 20 | 20 | private $level; |
| 21 | 21 | |
| 22 | - public function __construct($message, $code, $propertyPath = null, $value, array $constraints = [], $level='critical') |
|
| 22 | + public function __construct($message, $code, $propertyPath = null, $value, array $constraints = [ ], $level = 'critical') |
|
| 23 | 23 | { |
| 24 | 24 | parent::__construct($message, $code); |
| 25 | 25 | $this->propertyPath = $propertyPath; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | public function getPropertyPath() |
| 40 | 40 | { |
| 41 | 41 | $calling_location = $this->getCallingFileAndLine(); |
| 42 | - return $this->propertyPath . ' in ' .$calling_location; |
|
| 42 | + return $this->propertyPath.' in '.$calling_location; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -63,15 +63,15 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | protected function getCallingFileAndLine() |
| 65 | 65 | { |
| 66 | - foreach ( $this->getTrace() as $trace ) |
|
| 66 | + foreach ($this->getTrace() as $trace) |
|
| 67 | 67 | { |
| 68 | 68 | $trace = (object)$trace; |
| 69 | - if ( empty($trace->file) ) |
|
| 69 | + if (empty($trace->file)) |
|
| 70 | 70 | { |
| 71 | 71 | continue; |
| 72 | 72 | } |
| 73 | 73 | $file = static::beforeLast('.php', static::afterLast('/', $trace->file)); |
| 74 | - if ( in_array($file, ['AssertionChain', 'Assertion']) ) |
|
| 74 | + if (in_array($file, [ 'AssertionChain', 'Assertion' ])) |
|
| 75 | 75 | { |
| 76 | 76 | continue; |
| 77 | 77 | } |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | return $this->constraints; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - public static function afterLast($needle, $haystack, $return_original=false) |
|
| 102 | + public static function afterLast($needle, $haystack, $return_original = false) |
|
| 103 | 103 | { |
| 104 | - if ( ! is_bool(static::strrevpos($haystack, $needle)) ) |
|
| 104 | + if ( ! is_bool(static::strrevpos($haystack, $needle))) |
|
| 105 | 105 | { |
| 106 | 106 | return mb_substr($haystack, static::strrevpos($haystack, $needle) + mb_strlen($needle)); |
| 107 | 107 | } |