@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * @param array $constraints |
| 171 | 171 | * @return AssertionFailedException |
| 172 | 172 | */ |
| 173 | - protected function createException($message, $code, $propertyPath, array $constraints = []) |
|
| 173 | + protected function createException($message, $code, $propertyPath, array $constraints = [ ]) |
|
| 174 | 174 | { |
| 175 | 175 | $exceptionClass = $this->exceptionClass; |
| 176 | 176 | $propertyPath = is_null($propertyPath) ? $this->propertyPath : $propertyPath; |
@@ -208,18 +208,18 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | public function eq($value2, $message = null, $propertyPath = null) |
| 210 | 210 | { |
| 211 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 211 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 212 | 212 | { |
| 213 | 213 | return $this; |
| 214 | 214 | } |
| 215 | - if ( $this->value != $value2 ) |
|
| 215 | + if ($this->value != $value2) |
|
| 216 | 216 | { |
| 217 | 217 | $message = sprintf( |
| 218 | 218 | $message ?: 'Value "%s" does not equal expected value "%s".', |
| 219 | 219 | $this->stringify($this->value), |
| 220 | 220 | $this->stringify($value2) |
| 221 | 221 | ); |
| 222 | - throw $this->createException($message, self::INVALID_EQ, $propertyPath, ['expected' => $value2]); |
|
| 222 | + throw $this->createException($message, self::INVALID_EQ, $propertyPath, [ 'expected' => $value2 ]); |
|
| 223 | 223 | } |
| 224 | 224 | return $this; |
| 225 | 225 | } |
@@ -235,18 +235,18 @@ discard block |
||
| 235 | 235 | */ |
| 236 | 236 | public function same($value2, $message = null, $propertyPath = null) |
| 237 | 237 | { |
| 238 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 238 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 239 | 239 | { |
| 240 | 240 | return $this; |
| 241 | 241 | } |
| 242 | - if ( $this->value !== $value2 ) |
|
| 242 | + if ($this->value !== $value2) |
|
| 243 | 243 | { |
| 244 | 244 | $message = sprintf( |
| 245 | 245 | $message ?: 'Value "%s" is not the same as expected value "%s".', |
| 246 | 246 | $this->stringify($this->value), |
| 247 | 247 | $this->stringify($value2) |
| 248 | 248 | ); |
| 249 | - throw $this->createException($message, self::INVALID_SAME, $propertyPath, ['expected' => $value2]); |
|
| 249 | + throw $this->createException($message, self::INVALID_SAME, $propertyPath, [ 'expected' => $value2 ]); |
|
| 250 | 250 | } |
| 251 | 251 | return $this; |
| 252 | 252 | } |
@@ -262,18 +262,18 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | public function notEq($value2, $message = null, $propertyPath = null) |
| 264 | 264 | { |
| 265 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 265 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 266 | 266 | { |
| 267 | 267 | return $this; |
| 268 | 268 | } |
| 269 | - if ( $this->value == $value2 ) |
|
| 269 | + if ($this->value == $value2) |
|
| 270 | 270 | { |
| 271 | 271 | $message = sprintf( |
| 272 | 272 | $message ?: 'Value "%s" is equal to expected value "%s".', |
| 273 | 273 | $this->stringify($this->value), |
| 274 | 274 | $this->stringify($value2) |
| 275 | 275 | ); |
| 276 | - throw $this->createException($message, self::INVALID_NOT_EQ, $propertyPath, ['expected' => $value2]); |
|
| 276 | + throw $this->createException($message, self::INVALID_NOT_EQ, $propertyPath, [ 'expected' => $value2 ]); |
|
| 277 | 277 | } |
| 278 | 278 | return $this; |
| 279 | 279 | } |
@@ -287,11 +287,11 @@ discard block |
||
| 287 | 287 | */ |
| 288 | 288 | public function isCallable($message = null, $propertyPath = null) |
| 289 | 289 | { |
| 290 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 290 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 291 | 291 | { |
| 292 | 292 | return $this; |
| 293 | 293 | } |
| 294 | - if ( !is_callable($this->value) ) |
|
| 294 | + if ( ! is_callable($this->value)) |
|
| 295 | 295 | { |
| 296 | 296 | $message = sprintf( |
| 297 | 297 | $message ?: 'Value "%s" is not callable.', |
@@ -313,18 +313,18 @@ discard block |
||
| 313 | 313 | */ |
| 314 | 314 | public function notSame($value2, $message = null, $propertyPath = null) |
| 315 | 315 | { |
| 316 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 316 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 317 | 317 | { |
| 318 | 318 | return $this; |
| 319 | 319 | } |
| 320 | - if ( $this->value === $value2 ) |
|
| 320 | + if ($this->value === $value2) |
|
| 321 | 321 | { |
| 322 | 322 | $message = sprintf( |
| 323 | 323 | $message ?: 'Value "%s" is the same as expected value "%s".', |
| 324 | 324 | $this->stringify($this->value), |
| 325 | 325 | $this->stringify($value2) |
| 326 | 326 | ); |
| 327 | - throw $this->createException($message, self::INVALID_NOT_SAME, $propertyPath, ['expected' => $value2]); |
|
| 327 | + throw $this->createException($message, self::INVALID_NOT_SAME, $propertyPath, [ 'expected' => $value2 ]); |
|
| 328 | 328 | } |
| 329 | 329 | return $this; |
| 330 | 330 | } |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | public function status($message = null, $propertyPath = null) |
| 345 | 345 | { |
| 346 | 346 | $message = $message ?: 'Value "%s" is not a valid status.'; |
| 347 | - return $this->integer($message, $propertyPath)->inArray([-1, 0, 1]); |
|
| 347 | + return $this->integer($message, $propertyPath)->inArray([-1, 0, 1 ]); |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | public function nullOrId($message = null, $propertyPath = null) |
@@ -372,11 +372,11 @@ discard block |
||
| 372 | 372 | */ |
| 373 | 373 | public function integer($message = null, $propertyPath = null) |
| 374 | 374 | { |
| 375 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 375 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 376 | 376 | { |
| 377 | 377 | return $this; |
| 378 | 378 | } |
| 379 | - if ( !is_int($this->value) ) |
|
| 379 | + if ( ! is_int($this->value)) |
|
| 380 | 380 | { |
| 381 | 381 | $message = sprintf( |
| 382 | 382 | $message ?: 'Value "%s" is not an integer.', |
@@ -397,11 +397,11 @@ discard block |
||
| 397 | 397 | */ |
| 398 | 398 | public function float($message = null, $propertyPath = null) |
| 399 | 399 | { |
| 400 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 400 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 401 | 401 | { |
| 402 | 402 | return $this; |
| 403 | 403 | } |
| 404 | - if ( !is_float($this->value) ) |
|
| 404 | + if ( ! is_float($this->value)) |
|
| 405 | 405 | { |
| 406 | 406 | $message = sprintf( |
| 407 | 407 | $message ?: 'Value "%s" is not a float.', |
@@ -422,11 +422,11 @@ discard block |
||
| 422 | 422 | */ |
| 423 | 423 | public function digit($message = null, $propertyPath = null) |
| 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 ( !ctype_digit((string)$this->value) ) |
|
| 429 | + if ( ! ctype_digit((string)$this->value)) |
|
| 430 | 430 | { |
| 431 | 431 | $message = sprintf( |
| 432 | 432 | $message ?: 'Value "%s" is not a digit.', |
@@ -447,12 +447,12 @@ discard block |
||
| 447 | 447 | */ |
| 448 | 448 | public function date($message = null, $propertyPath = null) |
| 449 | 449 | { |
| 450 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 450 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 451 | 451 | { |
| 452 | 452 | return $this; |
| 453 | 453 | } |
| 454 | 454 | $this->notEmpty($message, $propertyPath); |
| 455 | - if ( strtotime($this->value) === false ) |
|
| 455 | + if (strtotime($this->value) === false) |
|
| 456 | 456 | { |
| 457 | 457 | $message = sprintf( |
| 458 | 458 | $message ?: 'Value "%s" is not a date.', |
@@ -473,11 +473,11 @@ discard block |
||
| 473 | 473 | */ |
| 474 | 474 | public function integerish($message = null, $propertyPath = null) |
| 475 | 475 | { |
| 476 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 476 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 477 | 477 | { |
| 478 | 478 | return $this; |
| 479 | 479 | } |
| 480 | - if ( is_object($this->value) || strval(intval($this->value)) != $this->value || is_bool($this->value) || is_null($this->value) ) |
|
| 480 | + if (is_object($this->value) || strval(intval($this->value)) != $this->value || is_bool($this->value) || is_null($this->value)) |
|
| 481 | 481 | { |
| 482 | 482 | $message = sprintf( |
| 483 | 483 | $message ?: 'Value "%s" is not an integer or a number castable to integer.', |
@@ -498,11 +498,11 @@ discard block |
||
| 498 | 498 | */ |
| 499 | 499 | public function boolean($message = null, $propertyPath = null) |
| 500 | 500 | { |
| 501 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 501 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 502 | 502 | { |
| 503 | 503 | return $this; |
| 504 | 504 | } |
| 505 | - if ( !is_bool($this->value) ) |
|
| 505 | + if ( ! is_bool($this->value)) |
|
| 506 | 506 | { |
| 507 | 507 | $message = sprintf( |
| 508 | 508 | $message ?: 'Value "%s" is not a boolean.', |
@@ -523,11 +523,11 @@ discard block |
||
| 523 | 523 | */ |
| 524 | 524 | public function scalar($message = null, $propertyPath = null) |
| 525 | 525 | { |
| 526 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 526 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 527 | 527 | { |
| 528 | 528 | return $this; |
| 529 | 529 | } |
| 530 | - if ( !is_scalar($this->value) ) |
|
| 530 | + if ( ! is_scalar($this->value)) |
|
| 531 | 531 | { |
| 532 | 532 | $message = sprintf( |
| 533 | 533 | $message ?: 'Value "%s" is not a scalar.', |
@@ -548,11 +548,11 @@ discard block |
||
| 548 | 548 | */ |
| 549 | 549 | public function notEmpty($message = null, $propertyPath = null) |
| 550 | 550 | { |
| 551 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 551 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 552 | 552 | { |
| 553 | 553 | return $this; |
| 554 | 554 | } |
| 555 | - if ( ( is_object($this->value) && empty((array)$this->value) ) || empty($this->value) ) |
|
| 555 | + if ((is_object($this->value) && empty((array)$this->value)) || empty($this->value)) |
|
| 556 | 556 | { |
| 557 | 557 | $message = sprintf( |
| 558 | 558 | $message ?: 'Value "%s" is empty, but non empty value was expected.', |
@@ -573,11 +573,11 @@ discard block |
||
| 573 | 573 | */ |
| 574 | 574 | public function noContent($message = null, $propertyPath = null) |
| 575 | 575 | { |
| 576 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 576 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 577 | 577 | { |
| 578 | 578 | return $this; |
| 579 | 579 | } |
| 580 | - if ( !empty( $this->value ) ) |
|
| 580 | + if ( ! empty($this->value)) |
|
| 581 | 581 | { |
| 582 | 582 | $message = sprintf( |
| 583 | 583 | $message ?: 'Value "%s" is not empty, but empty value was expected.', |
@@ -598,11 +598,11 @@ discard block |
||
| 598 | 598 | */ |
| 599 | 599 | public function notNull($message = null, $propertyPath = null) |
| 600 | 600 | { |
| 601 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 601 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 602 | 602 | { |
| 603 | 603 | return $this; |
| 604 | 604 | } |
| 605 | - if ( $this->value === null ) |
|
| 605 | + if ($this->value === null) |
|
| 606 | 606 | { |
| 607 | 607 | $message = sprintf( |
| 608 | 608 | $message ?: 'Value "%s" is null, but non null value was expected.', |
@@ -623,11 +623,11 @@ discard block |
||
| 623 | 623 | */ |
| 624 | 624 | public function string($message = null, $propertyPath = null) |
| 625 | 625 | { |
| 626 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 626 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 627 | 627 | { |
| 628 | 628 | return $this; |
| 629 | 629 | } |
| 630 | - if ( !is_string($this->value) ) |
|
| 630 | + if ( ! is_string($this->value)) |
|
| 631 | 631 | { |
| 632 | 632 | $message = sprintf( |
| 633 | 633 | $message ?: 'Value "%s" expected to be string, type %s given.', |
@@ -650,36 +650,36 @@ discard block |
||
| 650 | 650 | */ |
| 651 | 651 | public function regex($pattern, $message = null, $propertyPath = null) |
| 652 | 652 | { |
| 653 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 653 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 654 | 654 | { |
| 655 | 655 | return $this; |
| 656 | 656 | } |
| 657 | 657 | $this->string($message, $propertyPath); |
| 658 | - if ( !preg_match($pattern, $this->value) ) |
|
| 658 | + if ( ! preg_match($pattern, $this->value)) |
|
| 659 | 659 | { |
| 660 | 660 | $message = sprintf( |
| 661 | 661 | $message ?: 'Value "%s" does not match expression.', |
| 662 | 662 | $this->stringify($this->value) |
| 663 | 663 | ); |
| 664 | - throw $this->createException($message, self::INVALID_REGEX, $propertyPath, ['pattern' => $pattern]); |
|
| 664 | + throw $this->createException($message, self::INVALID_REGEX, $propertyPath, [ 'pattern' => $pattern ]); |
|
| 665 | 665 | } |
| 666 | 666 | return $this; |
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | public function notRegex($pattern, $message = null, $propertyPath = null) |
| 670 | 670 | { |
| 671 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 671 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 672 | 672 | { |
| 673 | 673 | return $this; |
| 674 | 674 | } |
| 675 | 675 | $this->string($message, $propertyPath); |
| 676 | - if ( preg_match($pattern, $this->value) ) |
|
| 676 | + if (preg_match($pattern, $this->value)) |
|
| 677 | 677 | { |
| 678 | 678 | $message = sprintf( |
| 679 | 679 | $message ?: 'Value "%s" does not match expression.', |
| 680 | 680 | $this->stringify($this->value) |
| 681 | 681 | ); |
| 682 | - throw $this->createException($message, self::INVALID_REGEX, $propertyPath, ['pattern' => $pattern]); |
|
| 682 | + throw $this->createException($message, self::INVALID_REGEX, $propertyPath, [ 'pattern' => $pattern ]); |
|
| 683 | 683 | } |
| 684 | 684 | return $this; |
| 685 | 685 | } |
@@ -696,20 +696,20 @@ discard block |
||
| 696 | 696 | */ |
| 697 | 697 | public function length($length, $message = null, $propertyPath = null, $encoding = 'utf8') |
| 698 | 698 | { |
| 699 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 699 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 700 | 700 | { |
| 701 | 701 | return $this; |
| 702 | 702 | } |
| 703 | 703 | $this->string($message, $propertyPath); |
| 704 | - if ( mb_strlen($this->value, $encoding) !== $length ) |
|
| 704 | + if (mb_strlen($this->value, $encoding) !== $length) |
|
| 705 | 705 | { |
| 706 | - $message = sprintf( |
|
| 706 | + $message = sprintf( |
|
| 707 | 707 | $message ?: 'Value "%s" has to be %d exactly characters long, but length is %d.', |
| 708 | 708 | $this->stringify($this->value), |
| 709 | 709 | $length, |
| 710 | 710 | mb_strlen($this->value, $encoding) |
| 711 | 711 | ); |
| 712 | - $constraints = ['length' => $length, 'encoding' => $encoding]; |
|
| 712 | + $constraints = [ 'length' => $length, 'encoding' => $encoding ]; |
|
| 713 | 713 | throw $this->createException($message, self::INVALID_LENGTH, $propertyPath, $constraints); |
| 714 | 714 | } |
| 715 | 715 | return $this; |
@@ -727,21 +727,21 @@ discard block |
||
| 727 | 727 | */ |
| 728 | 728 | public function minLength($minLength, $message = null, $propertyPath = null, $encoding = 'utf8') |
| 729 | 729 | { |
| 730 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 730 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 731 | 731 | { |
| 732 | 732 | return $this; |
| 733 | 733 | } |
| 734 | 734 | $this->string($message, $propertyPath); |
| 735 | - if ( mb_strlen($this->value, $encoding) < $minLength ) |
|
| 735 | + if (mb_strlen($this->value, $encoding) < $minLength) |
|
| 736 | 736 | { |
| 737 | - $message = sprintf( |
|
| 737 | + $message = sprintf( |
|
| 738 | 738 | $message |
| 739 | 739 | ?: 'Value "%s" is too short, it should have more than %d characters, but only has %d characters.', |
| 740 | 740 | $this->stringify($this->value), |
| 741 | 741 | $minLength, |
| 742 | 742 | mb_strlen($this->value, $encoding) |
| 743 | 743 | ); |
| 744 | - $constraints = ['min_length' => $minLength, 'encoding' => $encoding]; |
|
| 744 | + $constraints = [ 'min_length' => $minLength, 'encoding' => $encoding ]; |
|
| 745 | 745 | throw $this->createException($message, self::INVALID_MIN_LENGTH, $propertyPath, $constraints); |
| 746 | 746 | } |
| 747 | 747 | return $this; |
@@ -759,20 +759,20 @@ discard block |
||
| 759 | 759 | */ |
| 760 | 760 | public function maxLength($maxLength, $message = null, $propertyPath = null, $encoding = 'utf8') |
| 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 | 766 | $this->string($message, $propertyPath); |
| 767 | - if ( mb_strlen($this->value, $encoding) > $maxLength ) |
|
| 767 | + if (mb_strlen($this->value, $encoding) > $maxLength) |
|
| 768 | 768 | { |
| 769 | - $message = sprintf( |
|
| 769 | + $message = sprintf( |
|
| 770 | 770 | $message ?: 'Value "%s" is too long, it should have no more than %d characters, but has %d characters.', |
| 771 | 771 | $this->stringify($this->value), |
| 772 | 772 | $maxLength, |
| 773 | 773 | mb_strlen($this->value, $encoding) |
| 774 | 774 | ); |
| 775 | - $constraints = ['max_length' => $maxLength, 'encoding' => $encoding]; |
|
| 775 | + $constraints = [ 'max_length' => $maxLength, 'encoding' => $encoding ]; |
|
| 776 | 776 | throw $this->createException($message, self::INVALID_MAX_LENGTH, $propertyPath, $constraints); |
| 777 | 777 | } |
| 778 | 778 | return $this; |
@@ -791,32 +791,32 @@ discard block |
||
| 791 | 791 | */ |
| 792 | 792 | public function betweenLength($minLength, $maxLength, $message = null, $propertyPath = null, $encoding = 'utf8') |
| 793 | 793 | { |
| 794 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 794 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 795 | 795 | { |
| 796 | 796 | return $this; |
| 797 | 797 | } |
| 798 | 798 | $this->string($message, $propertyPath); |
| 799 | - if ( mb_strlen($this->value, $encoding) < $minLength ) |
|
| 799 | + if (mb_strlen($this->value, $encoding) < $minLength) |
|
| 800 | 800 | { |
| 801 | - $message = sprintf( |
|
| 801 | + $message = sprintf( |
|
| 802 | 802 | $message |
| 803 | 803 | ?: 'Value "%s" is too short, it should have more than %d characters, but only has %d characters.', |
| 804 | 804 | $this->stringify($this->value), |
| 805 | 805 | $minLength, |
| 806 | 806 | mb_strlen($this->value, $encoding) |
| 807 | 807 | ); |
| 808 | - $constraints = ['min_length' => $minLength, 'encoding' => $encoding]; |
|
| 808 | + $constraints = [ 'min_length' => $minLength, 'encoding' => $encoding ]; |
|
| 809 | 809 | throw $this->createException($message, self::INVALID_MIN_LENGTH, $propertyPath, $constraints); |
| 810 | 810 | } |
| 811 | - if ( mb_strlen($this->value, $encoding) > $maxLength ) |
|
| 811 | + if (mb_strlen($this->value, $encoding) > $maxLength) |
|
| 812 | 812 | { |
| 813 | - $message = sprintf( |
|
| 813 | + $message = sprintf( |
|
| 814 | 814 | $message ?: 'Value "%s" is too long, it should have no more than %d characters, but has %d characters.', |
| 815 | 815 | $this->stringify($this->value), |
| 816 | 816 | $maxLength, |
| 817 | 817 | mb_strlen($this->value, $encoding) |
| 818 | 818 | ); |
| 819 | - $constraints = ['max_length' => $maxLength, 'encoding' => $encoding]; |
|
| 819 | + $constraints = [ 'max_length' => $maxLength, 'encoding' => $encoding ]; |
|
| 820 | 820 | throw $this->createException($message, self::INVALID_MAX_LENGTH, $propertyPath, $constraints); |
| 821 | 821 | } |
| 822 | 822 | return $this; |
@@ -834,19 +834,19 @@ discard block |
||
| 834 | 834 | */ |
| 835 | 835 | public function startsWith($needle, $message = null, $propertyPath = null, $encoding = 'utf8') |
| 836 | 836 | { |
| 837 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 837 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 838 | 838 | { |
| 839 | 839 | return $this; |
| 840 | 840 | } |
| 841 | 841 | $this->string($message, $propertyPath); |
| 842 | - if ( mb_strpos($this->value, $needle, null, $encoding) !== 0 ) |
|
| 842 | + if (mb_strpos($this->value, $needle, null, $encoding) !== 0) |
|
| 843 | 843 | { |
| 844 | - $message = sprintf( |
|
| 844 | + $message = sprintf( |
|
| 845 | 845 | $message ?: 'Value "%s" does not start with "%s".', |
| 846 | 846 | $this->stringify($this->value), |
| 847 | 847 | $this->stringify($needle) |
| 848 | 848 | ); |
| 849 | - $constraints = ['needle' => $needle, 'encoding' => $encoding]; |
|
| 849 | + $constraints = [ 'needle' => $needle, 'encoding' => $encoding ]; |
|
| 850 | 850 | throw $this->createException($message, self::INVALID_STRING_START, $propertyPath, $constraints); |
| 851 | 851 | } |
| 852 | 852 | return $this; |
@@ -864,20 +864,20 @@ discard block |
||
| 864 | 864 | */ |
| 865 | 865 | public function endsWith($needle, $message = null, $propertyPath = null, $encoding = 'utf8') |
| 866 | 866 | { |
| 867 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 867 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 868 | 868 | { |
| 869 | 869 | return $this; |
| 870 | 870 | } |
| 871 | 871 | $this->string($message, $propertyPath); |
| 872 | 872 | $stringPosition = mb_strlen($this->value, $encoding) - mb_strlen($needle, $encoding); |
| 873 | - if ( mb_strripos($this->value, $needle, null, $encoding) !== $stringPosition ) |
|
| 873 | + if (mb_strripos($this->value, $needle, null, $encoding) !== $stringPosition) |
|
| 874 | 874 | { |
| 875 | - $message = sprintf( |
|
| 875 | + $message = sprintf( |
|
| 876 | 876 | $message ?: 'Value "%s" does not end with "%s".', |
| 877 | 877 | $this->stringify($this->value), |
| 878 | 878 | $this->stringify($needle) |
| 879 | 879 | ); |
| 880 | - $constraints = ['needle' => $needle, 'encoding' => $encoding]; |
|
| 880 | + $constraints = [ 'needle' => $needle, 'encoding' => $encoding ]; |
|
| 881 | 881 | throw $this->createException($message, self::INVALID_STRING_END, $propertyPath, $constraints); |
| 882 | 882 | } |
| 883 | 883 | return $this; |
@@ -895,19 +895,19 @@ discard block |
||
| 895 | 895 | */ |
| 896 | 896 | public function contains($needle, $message = null, $propertyPath = null, $encoding = 'utf8') |
| 897 | 897 | { |
| 898 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 898 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 899 | 899 | { |
| 900 | 900 | return $this; |
| 901 | 901 | } |
| 902 | 902 | $this->string($message, $propertyPath); |
| 903 | - if ( mb_strpos($this->value, $needle, null, $encoding) === false ) |
|
| 903 | + if (mb_strpos($this->value, $needle, null, $encoding) === false) |
|
| 904 | 904 | { |
| 905 | - $message = sprintf( |
|
| 905 | + $message = sprintf( |
|
| 906 | 906 | $message ?: 'Value "%s" does not contain "%s".', |
| 907 | 907 | $this->stringify($this->value), |
| 908 | 908 | $this->stringify($needle) |
| 909 | 909 | ); |
| 910 | - $constraints = ['needle' => $needle, 'encoding' => $encoding]; |
|
| 910 | + $constraints = [ 'needle' => $needle, 'encoding' => $encoding ]; |
|
| 911 | 911 | throw $this->createException($message, self::INVALID_STRING_CONTAINS, $propertyPath, $constraints); |
| 912 | 912 | } |
| 913 | 913 | return $this; |
@@ -924,18 +924,18 @@ discard block |
||
| 924 | 924 | */ |
| 925 | 925 | public function choice(array $choices, $message = null, $propertyPath = null) |
| 926 | 926 | { |
| 927 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 927 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 928 | 928 | { |
| 929 | 929 | return $this; |
| 930 | 930 | } |
| 931 | - if ( !in_array($this->value, $choices, true) ) |
|
| 931 | + if ( ! in_array($this->value, $choices, true)) |
|
| 932 | 932 | { |
| 933 | 933 | $message = sprintf( |
| 934 | 934 | $message ?: 'Value "%s" is not an element of the valid values: %s', |
| 935 | 935 | $this->stringify($this->value), |
| 936 | 936 | implode(", ", array_map('Terah\Assert\Assert::stringify', $choices)) |
| 937 | 937 | ); |
| 938 | - throw $this->createException($message, self::INVALID_CHOICE, $propertyPath, ['choices' => $choices]); |
|
| 938 | + throw $this->createException($message, self::INVALID_CHOICE, $propertyPath, [ 'choices' => $choices ]); |
|
| 939 | 939 | } |
| 940 | 940 | return $this; |
| 941 | 941 | } |
@@ -952,7 +952,7 @@ discard block |
||
| 952 | 952 | */ |
| 953 | 953 | public function inArray(array $choices, $message = null, $propertyPath = null) |
| 954 | 954 | { |
| 955 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 955 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 956 | 956 | { |
| 957 | 957 | return $this; |
| 958 | 958 | } |
@@ -970,11 +970,11 @@ discard block |
||
| 970 | 970 | */ |
| 971 | 971 | public function numeric($message = null, $propertyPath = null) |
| 972 | 972 | { |
| 973 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 973 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 974 | 974 | { |
| 975 | 975 | return $this; |
| 976 | 976 | } |
| 977 | - if ( ! is_numeric($this->value) ) |
|
| 977 | + if ( ! is_numeric($this->value)) |
|
| 978 | 978 | { |
| 979 | 979 | $message = sprintf( |
| 980 | 980 | $message ?: 'Value "%s" is not numeric.', |
@@ -1013,11 +1013,11 @@ discard block |
||
| 1013 | 1013 | */ |
| 1014 | 1014 | public function isArray($message = null, $propertyPath = null) |
| 1015 | 1015 | { |
| 1016 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1016 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1017 | 1017 | { |
| 1018 | 1018 | return $this; |
| 1019 | 1019 | } |
| 1020 | - if ( !is_array($this->value) ) |
|
| 1020 | + if ( ! is_array($this->value)) |
|
| 1021 | 1021 | { |
| 1022 | 1022 | $message = sprintf( |
| 1023 | 1023 | $message ?: 'Value "%s" is not an array.', |
@@ -1038,11 +1038,11 @@ discard block |
||
| 1038 | 1038 | */ |
| 1039 | 1039 | public function isTraversable($message = null, $propertyPath = null) |
| 1040 | 1040 | { |
| 1041 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1041 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1042 | 1042 | { |
| 1043 | 1043 | return $this; |
| 1044 | 1044 | } |
| 1045 | - if ( !is_array($this->value) && !$this->value instanceof \Traversable ) |
|
| 1045 | + if ( ! is_array($this->value) && ! $this->value instanceof \Traversable) |
|
| 1046 | 1046 | { |
| 1047 | 1047 | $message = sprintf( |
| 1048 | 1048 | $message ?: 'Value "%s" is not an array and does not implement Traversable.', |
@@ -1063,11 +1063,11 @@ discard block |
||
| 1063 | 1063 | */ |
| 1064 | 1064 | public function isArrayAccessible($message = null, $propertyPath = null) |
| 1065 | 1065 | { |
| 1066 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1066 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1067 | 1067 | { |
| 1068 | 1068 | return $this; |
| 1069 | 1069 | } |
| 1070 | - if ( !is_array($this->value) && !$this->value instanceof \ArrayAccess ) |
|
| 1070 | + if ( ! is_array($this->value) && ! $this->value instanceof \ArrayAccess) |
|
| 1071 | 1071 | { |
| 1072 | 1072 | $message = sprintf( |
| 1073 | 1073 | $message ?: 'Value "%s" is not an array and does not implement ArrayAccess.', |
@@ -1089,18 +1089,18 @@ discard block |
||
| 1089 | 1089 | */ |
| 1090 | 1090 | public function keyExists($key, $message = null, $propertyPath = null) |
| 1091 | 1091 | { |
| 1092 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1092 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1093 | 1093 | { |
| 1094 | 1094 | return $this; |
| 1095 | 1095 | } |
| 1096 | 1096 | $this->isArray($message, $propertyPath); |
| 1097 | - if ( !array_key_exists($key, $this->value) ) |
|
| 1097 | + if ( ! array_key_exists($key, $this->value)) |
|
| 1098 | 1098 | { |
| 1099 | 1099 | $message = sprintf( |
| 1100 | 1100 | $message ?: 'Array does not contain an element with key "%s"', |
| 1101 | 1101 | $this->stringify($key) |
| 1102 | 1102 | ); |
| 1103 | - throw $this->createException($message, self::INVALID_KEY_EXISTS, $propertyPath, ['key' => $key]); |
|
| 1103 | + throw $this->createException($message, self::INVALID_KEY_EXISTS, $propertyPath, [ 'key' => $key ]); |
|
| 1104 | 1104 | } |
| 1105 | 1105 | return $this; |
| 1106 | 1106 | } |
@@ -1116,21 +1116,21 @@ discard block |
||
| 1116 | 1116 | */ |
| 1117 | 1117 | public function keysExist($keys, $message = null, $propertyPath = null) |
| 1118 | 1118 | { |
| 1119 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1119 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1120 | 1120 | { |
| 1121 | 1121 | return $this; |
| 1122 | 1122 | } |
| 1123 | 1123 | $this->isArray($message, $propertyPath); |
| 1124 | - foreach ( $keys as $key ) |
|
| 1124 | + foreach ($keys as $key) |
|
| 1125 | 1125 | { |
| 1126 | - if ( !array_key_exists($key, $this->value) ) |
|
| 1126 | + if ( ! array_key_exists($key, $this->value)) |
|
| 1127 | 1127 | { |
| 1128 | 1128 | $message = $message |
| 1129 | 1129 | ?: sprintf( |
| 1130 | 1130 | 'Array does not contain an element with key "%s"', |
| 1131 | 1131 | $this->stringify($key) |
| 1132 | 1132 | ); |
| 1133 | - throw $this->createException($message, self::INVALID_KEYS_EXIST, $propertyPath, ['key' => $key]); |
|
| 1133 | + throw $this->createException($message, self::INVALID_KEYS_EXIST, $propertyPath, [ 'key' => $key ]); |
|
| 1134 | 1134 | } |
| 1135 | 1135 | } |
| 1136 | 1136 | return $this; |
@@ -1147,19 +1147,19 @@ discard block |
||
| 1147 | 1147 | */ |
| 1148 | 1148 | public function propertyExists($key, $message = null, $propertyPath = null) |
| 1149 | 1149 | { |
| 1150 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1150 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1151 | 1151 | { |
| 1152 | 1152 | return $this; |
| 1153 | 1153 | } |
| 1154 | 1154 | $this->isObject($message, $propertyPath); |
| 1155 | - if ( !property_exists($this->value, $key) && !isset( $this->value->$key ) ) |
|
| 1155 | + if ( ! property_exists($this->value, $key) && ! isset($this->value->$key)) |
|
| 1156 | 1156 | { |
| 1157 | 1157 | $message = $message |
| 1158 | 1158 | ?: sprintf( |
| 1159 | 1159 | 'Object does not contain a property with key "%s"', |
| 1160 | 1160 | $this->stringify($key) |
| 1161 | 1161 | ); |
| 1162 | - throw $this->createException($message, self::INVALID_PROPERTY_EXISTS, $propertyPath, ['key' => $key]); |
|
| 1162 | + throw $this->createException($message, self::INVALID_PROPERTY_EXISTS, $propertyPath, [ 'key' => $key ]); |
|
| 1163 | 1163 | } |
| 1164 | 1164 | return $this; |
| 1165 | 1165 | } |
@@ -1175,22 +1175,22 @@ discard block |
||
| 1175 | 1175 | */ |
| 1176 | 1176 | public function propertiesExist(array $keys, $message = null, $propertyPath = null) |
| 1177 | 1177 | { |
| 1178 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1178 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1179 | 1179 | { |
| 1180 | 1180 | return $this; |
| 1181 | 1181 | } |
| 1182 | 1182 | $this->isObject($message, $propertyPath); |
| 1183 | - foreach ( $keys as $key ) |
|
| 1183 | + foreach ($keys as $key) |
|
| 1184 | 1184 | { |
| 1185 | 1185 | // Using isset to allow resolution of magically defined properties |
| 1186 | - if ( !property_exists($this->value, $key) && !isset( $this->value->$key ) ) |
|
| 1186 | + if ( ! property_exists($this->value, $key) && ! isset($this->value->$key)) |
|
| 1187 | 1187 | { |
| 1188 | 1188 | $message = $message |
| 1189 | 1189 | ?: sprintf( |
| 1190 | 1190 | 'Object does not contain a property with key "%s"', |
| 1191 | 1191 | $this->stringify($key) |
| 1192 | 1192 | ); |
| 1193 | - throw $this->createException($message, self::INVALID_PROPERTIES_EXIST, $propertyPath, ['key' => $key]); |
|
| 1193 | + throw $this->createException($message, self::INVALID_PROPERTIES_EXIST, $propertyPath, [ 'key' => $key ]); |
|
| 1194 | 1194 | } |
| 1195 | 1195 | } |
| 1196 | 1196 | return $this; |
@@ -1206,12 +1206,12 @@ discard block |
||
| 1206 | 1206 | */ |
| 1207 | 1207 | public function utf8($message = null, $propertyPath = null) |
| 1208 | 1208 | { |
| 1209 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1209 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1210 | 1210 | { |
| 1211 | 1211 | return $this; |
| 1212 | 1212 | } |
| 1213 | 1213 | $this->string($message, $propertyPath); |
| 1214 | - if ( mb_detect_encoding($this->value, 'UTF-8', true) !== 'UTF-8' ) |
|
| 1214 | + if (mb_detect_encoding($this->value, 'UTF-8', true) !== 'UTF-8') |
|
| 1215 | 1215 | { |
| 1216 | 1216 | $message = $message |
| 1217 | 1217 | ?: sprintf( |
@@ -1234,12 +1234,12 @@ discard block |
||
| 1234 | 1234 | */ |
| 1235 | 1235 | public function ascii($message = null, $propertyPath = null) |
| 1236 | 1236 | { |
| 1237 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1237 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1238 | 1238 | { |
| 1239 | 1239 | return $this; |
| 1240 | 1240 | } |
| 1241 | 1241 | $this->string($message, $propertyPath); |
| 1242 | - if ( ! preg_match('/^[ -~]+$/', $this->value) ) |
|
| 1242 | + if ( ! preg_match('/^[ -~]+$/', $this->value)) |
|
| 1243 | 1243 | { |
| 1244 | 1244 | $message = $message |
| 1245 | 1245 | ?: sprintf( |
@@ -1262,18 +1262,18 @@ discard block |
||
| 1262 | 1262 | */ |
| 1263 | 1263 | public function keyIsset($key, $message = null, $propertyPath = null) |
| 1264 | 1264 | { |
| 1265 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1265 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1266 | 1266 | { |
| 1267 | 1267 | return $this; |
| 1268 | 1268 | } |
| 1269 | 1269 | $this->isArrayAccessible($message, $propertyPath); |
| 1270 | - if ( !isset( $this->value[$key] ) ) |
|
| 1270 | + if ( ! isset($this->value[ $key ])) |
|
| 1271 | 1271 | { |
| 1272 | 1272 | $message = sprintf( |
| 1273 | 1273 | $message ?: 'The element with key "%s" was not found', |
| 1274 | 1274 | $this->stringify($key) |
| 1275 | 1275 | ); |
| 1276 | - throw $this->createException($message, self::INVALID_KEY_ISSET, $propertyPath, ['key' => $key]); |
|
| 1276 | + throw $this->createException($message, self::INVALID_KEY_ISSET, $propertyPath, [ 'key' => $key ]); |
|
| 1277 | 1277 | } |
| 1278 | 1278 | return $this; |
| 1279 | 1279 | } |
@@ -1289,12 +1289,12 @@ discard block |
||
| 1289 | 1289 | */ |
| 1290 | 1290 | public function notEmptyKey($key, $message = null, $propertyPath = null) |
| 1291 | 1291 | { |
| 1292 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1292 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1293 | 1293 | { |
| 1294 | 1294 | return $this; |
| 1295 | 1295 | } |
| 1296 | 1296 | $this->keyIsset($key, $message, $propertyPath); |
| 1297 | - (new Assert($this->value[$key]))->setExceptionClass($this->exceptionClass)->notEmpty($message, $propertyPath); |
|
| 1297 | + (new Assert($this->value[ $key ]))->setExceptionClass($this->exceptionClass)->notEmpty($message, $propertyPath); |
|
| 1298 | 1298 | return $this; |
| 1299 | 1299 | } |
| 1300 | 1300 | |
@@ -1308,11 +1308,11 @@ discard block |
||
| 1308 | 1308 | */ |
| 1309 | 1309 | public function notBlank($message = null, $propertyPath = null) |
| 1310 | 1310 | { |
| 1311 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1311 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1312 | 1312 | { |
| 1313 | 1313 | return $this; |
| 1314 | 1314 | } |
| 1315 | - if ( false === $this->value || ( empty( $this->value ) && '0' != $this->value ) ) |
|
| 1315 | + if (false === $this->value || (empty($this->value) && '0' != $this->value)) |
|
| 1316 | 1316 | { |
| 1317 | 1317 | $message = sprintf( |
| 1318 | 1318 | $message ?: 'Value "%s" is blank, but was expected to contain a value.', |
@@ -1334,18 +1334,18 @@ discard block |
||
| 1334 | 1334 | */ |
| 1335 | 1335 | public function isInstanceOf($className, $message = null, $propertyPath = null) |
| 1336 | 1336 | { |
| 1337 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1337 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1338 | 1338 | { |
| 1339 | 1339 | return $this; |
| 1340 | 1340 | } |
| 1341 | - if ( !( $this->value instanceof $className ) ) |
|
| 1341 | + if ( ! ($this->value instanceof $className)) |
|
| 1342 | 1342 | { |
| 1343 | 1343 | $message = sprintf( |
| 1344 | 1344 | $message ?: 'Class "%s" was expected to be instanceof of "%s" but is not.', |
| 1345 | 1345 | $this->stringify($this->value), |
| 1346 | 1346 | $className |
| 1347 | 1347 | ); |
| 1348 | - throw $this->createException($message, self::INVALID_INSTANCE_OF, $propertyPath, ['class' => $className]); |
|
| 1348 | + throw $this->createException($message, self::INVALID_INSTANCE_OF, $propertyPath, [ 'class' => $className ]); |
|
| 1349 | 1349 | } |
| 1350 | 1350 | return $this; |
| 1351 | 1351 | } |
@@ -1361,18 +1361,18 @@ discard block |
||
| 1361 | 1361 | */ |
| 1362 | 1362 | public function notIsInstanceOf($className, $message = null, $propertyPath = null) |
| 1363 | 1363 | { |
| 1364 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1364 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1365 | 1365 | { |
| 1366 | 1366 | return $this; |
| 1367 | 1367 | } |
| 1368 | - if ( $this->value instanceof $className ) |
|
| 1368 | + if ($this->value instanceof $className) |
|
| 1369 | 1369 | { |
| 1370 | 1370 | $message = sprintf( |
| 1371 | 1371 | $message ?: 'Class "%s" was not expected to be instanceof of "%s".', |
| 1372 | 1372 | $this->stringify($this->value), |
| 1373 | 1373 | $className |
| 1374 | 1374 | ); |
| 1375 | - throw $this->createException($message, self::INVALID_NOT_INSTANCE_OF, $propertyPath, ['class' => $className]); |
|
| 1375 | + throw $this->createException($message, self::INVALID_NOT_INSTANCE_OF, $propertyPath, [ 'class' => $className ]); |
|
| 1376 | 1376 | } |
| 1377 | 1377 | return $this; |
| 1378 | 1378 | } |
@@ -1388,18 +1388,18 @@ discard block |
||
| 1388 | 1388 | */ |
| 1389 | 1389 | public function subclassOf($className, $message = null, $propertyPath = null) |
| 1390 | 1390 | { |
| 1391 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1391 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1392 | 1392 | { |
| 1393 | 1393 | return $this; |
| 1394 | 1394 | } |
| 1395 | - if ( !is_subclass_of($this->value, $className) ) |
|
| 1395 | + if ( ! is_subclass_of($this->value, $className)) |
|
| 1396 | 1396 | { |
| 1397 | 1397 | $message = sprintf( |
| 1398 | 1398 | $message ?: 'Class "%s" was expected to be subclass of "%s".', |
| 1399 | 1399 | $this->stringify($this->value), |
| 1400 | 1400 | $className |
| 1401 | 1401 | ); |
| 1402 | - throw $this->createException($message, self::INVALID_SUBCLASS_OF, $propertyPath, ['class' => $className]); |
|
| 1402 | + throw $this->createException($message, self::INVALID_SUBCLASS_OF, $propertyPath, [ 'class' => $className ]); |
|
| 1403 | 1403 | } |
| 1404 | 1404 | return $this; |
| 1405 | 1405 | } |
@@ -1416,12 +1416,12 @@ discard block |
||
| 1416 | 1416 | */ |
| 1417 | 1417 | public function range($minValue, $maxValue, $message = null, $propertyPath = null) |
| 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 | } |
| 1423 | 1423 | $this->numeric($message, $propertyPath); |
| 1424 | - if ( $this->value < $minValue || $this->value > $maxValue ) |
|
| 1424 | + if ($this->value < $minValue || $this->value > $maxValue) |
|
| 1425 | 1425 | { |
| 1426 | 1426 | $message = sprintf( |
| 1427 | 1427 | $message ?: 'Number "%s" was expected to be at least "%d" and at most "%d".', |
@@ -1448,19 +1448,19 @@ discard block |
||
| 1448 | 1448 | */ |
| 1449 | 1449 | public function min($minValue, $message = null, $propertyPath = null) |
| 1450 | 1450 | { |
| 1451 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1451 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1452 | 1452 | { |
| 1453 | 1453 | return $this; |
| 1454 | 1454 | } |
| 1455 | 1455 | $this->numeric($message, $propertyPath); |
| 1456 | - if ( $this->value < $minValue ) |
|
| 1456 | + if ($this->value < $minValue) |
|
| 1457 | 1457 | { |
| 1458 | 1458 | $message = sprintf( |
| 1459 | 1459 | $message ?: 'Number "%s" was expected to be at least "%d".', |
| 1460 | 1460 | $this->stringify($this->value), |
| 1461 | 1461 | $this->stringify($minValue) |
| 1462 | 1462 | ); |
| 1463 | - throw $this->createException($message, self::INVALID_MIN, $propertyPath, ['min' => $minValue]); |
|
| 1463 | + throw $this->createException($message, self::INVALID_MIN, $propertyPath, [ 'min' => $minValue ]); |
|
| 1464 | 1464 | } |
| 1465 | 1465 | return $this; |
| 1466 | 1466 | } |
@@ -1476,19 +1476,19 @@ discard block |
||
| 1476 | 1476 | */ |
| 1477 | 1477 | public function max($maxValue, $message = null, $propertyPath = null) |
| 1478 | 1478 | { |
| 1479 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1479 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1480 | 1480 | { |
| 1481 | 1481 | return $this; |
| 1482 | 1482 | } |
| 1483 | 1483 | $this->numeric($message, $propertyPath); |
| 1484 | - if ( $this->value > $maxValue ) |
|
| 1484 | + if ($this->value > $maxValue) |
|
| 1485 | 1485 | { |
| 1486 | 1486 | $message = sprintf( |
| 1487 | 1487 | $message ?: 'Number "%s" was expected to be at most "%d".', |
| 1488 | 1488 | $this->stringify($this->value), |
| 1489 | 1489 | $this->stringify($maxValue) |
| 1490 | 1490 | ); |
| 1491 | - throw $this->createException($message, self::INVALID_MAX, $propertyPath, ['max' => $maxValue]); |
|
| 1491 | + throw $this->createException($message, self::INVALID_MAX, $propertyPath, [ 'max' => $maxValue ]); |
|
| 1492 | 1492 | } |
| 1493 | 1493 | return $this; |
| 1494 | 1494 | } |
@@ -1503,13 +1503,13 @@ discard block |
||
| 1503 | 1503 | */ |
| 1504 | 1504 | public function file($message = null, $propertyPath = null) |
| 1505 | 1505 | { |
| 1506 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1506 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1507 | 1507 | { |
| 1508 | 1508 | return $this; |
| 1509 | 1509 | } |
| 1510 | 1510 | $this->string($message, $propertyPath); |
| 1511 | 1511 | $this->notEmpty($message, $propertyPath); |
| 1512 | - if ( !is_file($this->value) ) |
|
| 1512 | + if ( ! is_file($this->value)) |
|
| 1513 | 1513 | { |
| 1514 | 1514 | $message = sprintf( |
| 1515 | 1515 | $message ?: 'File "%s" was expected to exist.', |
@@ -1528,13 +1528,13 @@ discard block |
||
| 1528 | 1528 | */ |
| 1529 | 1529 | public function fileExists($message = null, $propertyPath = null) |
| 1530 | 1530 | { |
| 1531 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1531 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1532 | 1532 | { |
| 1533 | 1533 | return $this; |
| 1534 | 1534 | } |
| 1535 | 1535 | $this->string($message, $propertyPath); |
| 1536 | 1536 | $this->notEmpty($message, $propertyPath); |
| 1537 | - if ( ! file_exists($this->value) ) |
|
| 1537 | + if ( ! file_exists($this->value)) |
|
| 1538 | 1538 | { |
| 1539 | 1539 | $message = sprintf( |
| 1540 | 1540 | $message ?: 'File or directory "%s" was expected to exist.', |
@@ -1555,12 +1555,12 @@ discard block |
||
| 1555 | 1555 | */ |
| 1556 | 1556 | public function directory($message = null, $propertyPath = null) |
| 1557 | 1557 | { |
| 1558 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1558 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1559 | 1559 | { |
| 1560 | 1560 | return $this; |
| 1561 | 1561 | } |
| 1562 | 1562 | $this->string($message, $propertyPath); |
| 1563 | - if ( !is_dir($this->value) ) |
|
| 1563 | + if ( ! is_dir($this->value)) |
|
| 1564 | 1564 | { |
| 1565 | 1565 | $message = sprintf( |
| 1566 | 1566 | $message ?: 'Path "%s" was expected to be a directory.', |
@@ -1581,12 +1581,12 @@ discard block |
||
| 1581 | 1581 | */ |
| 1582 | 1582 | public function readable($message = null, $propertyPath = null) |
| 1583 | 1583 | { |
| 1584 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1584 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1585 | 1585 | { |
| 1586 | 1586 | return $this; |
| 1587 | 1587 | } |
| 1588 | 1588 | $this->string($message, $propertyPath); |
| 1589 | - if ( !is_readable($this->value) ) |
|
| 1589 | + if ( ! is_readable($this->value)) |
|
| 1590 | 1590 | { |
| 1591 | 1591 | $message = sprintf( |
| 1592 | 1592 | $message ?: 'Path "%s" was expected to be readable.', |
@@ -1607,12 +1607,12 @@ discard block |
||
| 1607 | 1607 | */ |
| 1608 | 1608 | public function writeable($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 | 1614 | $this->string($message, $propertyPath); |
| 1615 | - if ( !is_writeable($this->value) ) |
|
| 1615 | + if ( ! is_writeable($this->value)) |
|
| 1616 | 1616 | { |
| 1617 | 1617 | $message = sprintf( |
| 1618 | 1618 | $message ?: 'Path "%s" was expected to be writeable.', |
@@ -1634,12 +1634,12 @@ discard block |
||
| 1634 | 1634 | */ |
| 1635 | 1635 | public function email($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 | 1641 | $this->string($message, $propertyPath); |
| 1642 | - if ( ! filter_var($this->value, FILTER_VALIDATE_EMAIL) ) |
|
| 1642 | + if ( ! filter_var($this->value, FILTER_VALIDATE_EMAIL)) |
|
| 1643 | 1643 | { |
| 1644 | 1644 | $message = sprintf( |
| 1645 | 1645 | $message ?: 'Value "%s" was expected to be a valid e-mail address.', |
@@ -1651,7 +1651,7 @@ discard block |
||
| 1651 | 1651 | { |
| 1652 | 1652 | $host = substr($this->value, strpos($this->value, '@') + 1); |
| 1653 | 1653 | // Likely not a FQDN, bug in PHP FILTER_VALIDATE_EMAIL prior to PHP 5.3.3 |
| 1654 | - if ( version_compare(PHP_VERSION, '5.3.3', '<') && strpos($host, '.') === false ) |
|
| 1654 | + if (version_compare(PHP_VERSION, '5.3.3', '<') && strpos($host, '.') === false) |
|
| 1655 | 1655 | { |
| 1656 | 1656 | $message = sprintf( |
| 1657 | 1657 | $message ?: 'Value "%s" was expected to be a valid e-mail address.', |
@@ -1665,7 +1665,7 @@ discard block |
||
| 1665 | 1665 | |
| 1666 | 1666 | public function emailPrefix($message = null, $propertyPath = null) |
| 1667 | 1667 | { |
| 1668 | - $this->value($this->value . '@example.com'); |
|
| 1668 | + $this->value($this->value.'@example.com'); |
|
| 1669 | 1669 | return $this->email($message, $propertyPath); |
| 1670 | 1670 | } |
| 1671 | 1671 | |
@@ -1685,12 +1685,12 @@ discard block |
||
| 1685 | 1685 | */ |
| 1686 | 1686 | public function url($message = null, $propertyPath = null) |
| 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->string($message, $propertyPath); |
| 1693 | - $protocols = ['http', 'https']; |
|
| 1693 | + $protocols = [ 'http', 'https' ]; |
|
| 1694 | 1694 | $pattern = '~^ |
| 1695 | 1695 | (%s):// # protocol |
| 1696 | 1696 | ( |
@@ -1705,8 +1705,8 @@ discard block |
||
| 1705 | 1705 | (:[0-9]+)? # a port (optional) |
| 1706 | 1706 | (/?|/\S+) # a /, nothing or a / with something |
| 1707 | 1707 | $~ixu'; |
| 1708 | - $pattern = sprintf($pattern, implode('|', $protocols)); |
|
| 1709 | - if ( !preg_match($pattern, $this->value) ) |
|
| 1708 | + $pattern = sprintf($pattern, implode('|', $protocols)); |
|
| 1709 | + if ( ! preg_match($pattern, $this->value)) |
|
| 1710 | 1710 | { |
| 1711 | 1711 | $message = sprintf( |
| 1712 | 1712 | $message ?: 'Value "%s" was expected to be a valid URL starting with http or https', |
@@ -1730,13 +1730,13 @@ discard block |
||
| 1730 | 1730 | */ |
| 1731 | 1731 | public function domainName($message = null, $propertyPath = null) |
| 1732 | 1732 | { |
| 1733 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1733 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1734 | 1734 | { |
| 1735 | 1735 | return $this; |
| 1736 | 1736 | } |
| 1737 | 1737 | $this->string($message, $propertyPath); |
| 1738 | - $pattern = '/^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}$/'; |
|
| 1739 | - if ( ! preg_match($pattern, $this->value) ) |
|
| 1738 | + $pattern = '/^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}$/'; |
|
| 1739 | + if ( ! preg_match($pattern, $this->value)) |
|
| 1740 | 1740 | { |
| 1741 | 1741 | $message = sprintf( |
| 1742 | 1742 | $message ?: 'Value "%s" was expected to be a valid domain name', |
@@ -1757,7 +1757,7 @@ discard block |
||
| 1757 | 1757 | */ |
| 1758 | 1758 | public function alnum($message = null, $propertyPath = null) |
| 1759 | 1759 | { |
| 1760 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1760 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1761 | 1761 | { |
| 1762 | 1762 | return $this; |
| 1763 | 1763 | } |
@@ -1787,11 +1787,11 @@ discard block |
||
| 1787 | 1787 | */ |
| 1788 | 1788 | public function true($message = null, $propertyPath = null) |
| 1789 | 1789 | { |
| 1790 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1790 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1791 | 1791 | { |
| 1792 | 1792 | return $this; |
| 1793 | 1793 | } |
| 1794 | - if ( $this->value !== true ) |
|
| 1794 | + if ($this->value !== true) |
|
| 1795 | 1795 | { |
| 1796 | 1796 | $message = sprintf( |
| 1797 | 1797 | $message ?: 'Value "%s" is not TRUE.', |
@@ -1812,11 +1812,11 @@ discard block |
||
| 1812 | 1812 | */ |
| 1813 | 1813 | public function truthy($message = null, $propertyPath = null) |
| 1814 | 1814 | { |
| 1815 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1815 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1816 | 1816 | { |
| 1817 | 1817 | return $this; |
| 1818 | 1818 | } |
| 1819 | - if ( ! $this->value ) |
|
| 1819 | + if ( ! $this->value) |
|
| 1820 | 1820 | { |
| 1821 | 1821 | $message = sprintf( |
| 1822 | 1822 | $message ?: 'Value "%s" is not truthy.', |
@@ -1837,11 +1837,11 @@ discard block |
||
| 1837 | 1837 | */ |
| 1838 | 1838 | public function false($message = null, $propertyPath = null) |
| 1839 | 1839 | { |
| 1840 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1840 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1841 | 1841 | { |
| 1842 | 1842 | return $this; |
| 1843 | 1843 | } |
| 1844 | - if ( $this->value !== false ) |
|
| 1844 | + if ($this->value !== false) |
|
| 1845 | 1845 | { |
| 1846 | 1846 | $message = sprintf( |
| 1847 | 1847 | $message ?: 'Value "%s" is not FALSE.', |
@@ -1862,11 +1862,11 @@ discard block |
||
| 1862 | 1862 | */ |
| 1863 | 1863 | public function notFalse($message = null, $propertyPath = null) |
| 1864 | 1864 | { |
| 1865 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1865 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1866 | 1866 | { |
| 1867 | 1867 | return $this; |
| 1868 | 1868 | } |
| 1869 | - if ( $this->value === false ) |
|
| 1869 | + if ($this->value === false) |
|
| 1870 | 1870 | { |
| 1871 | 1871 | $message = sprintf( |
| 1872 | 1872 | $message ?: 'Value "%s" is not FALSE.', |
@@ -1887,11 +1887,11 @@ discard block |
||
| 1887 | 1887 | */ |
| 1888 | 1888 | public function classExists($message = null, $propertyPath = null) |
| 1889 | 1889 | { |
| 1890 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1890 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1891 | 1891 | { |
| 1892 | 1892 | return $this; |
| 1893 | 1893 | } |
| 1894 | - if ( !class_exists($this->value) ) |
|
| 1894 | + if ( ! class_exists($this->value)) |
|
| 1895 | 1895 | { |
| 1896 | 1896 | $message = sprintf( |
| 1897 | 1897 | $message ?: 'Class "%s" does not exist.', |
@@ -1913,19 +1913,19 @@ discard block |
||
| 1913 | 1913 | */ |
| 1914 | 1914 | public function implementsInterface($interfaceName, $message = null, $propertyPath = null) |
| 1915 | 1915 | { |
| 1916 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1916 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1917 | 1917 | { |
| 1918 | 1918 | return $this; |
| 1919 | 1919 | } |
| 1920 | 1920 | $reflection = new \ReflectionClass($this->value); |
| 1921 | - if ( !$reflection->implementsInterface($interfaceName) ) |
|
| 1921 | + if ( ! $reflection->implementsInterface($interfaceName)) |
|
| 1922 | 1922 | { |
| 1923 | 1923 | $message = sprintf( |
| 1924 | 1924 | $message ?: 'Class "%s" does not implement interface "%s".', |
| 1925 | 1925 | $this->stringify($this->value), |
| 1926 | 1926 | $this->stringify($interfaceName) |
| 1927 | 1927 | ); |
| 1928 | - throw $this->createException($message, self::INTERFACE_NOT_IMPLEMENTED, $propertyPath, ['interface' => $interfaceName]); |
|
| 1928 | + throw $this->createException($message, self::INTERFACE_NOT_IMPLEMENTED, $propertyPath, [ 'interface' => $interfaceName ]); |
|
| 1929 | 1929 | } |
| 1930 | 1930 | return $this; |
| 1931 | 1931 | } |
@@ -1946,11 +1946,11 @@ discard block |
||
| 1946 | 1946 | */ |
| 1947 | 1947 | public function isJsonString($message = null, $propertyPath = null) |
| 1948 | 1948 | { |
| 1949 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1949 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1950 | 1950 | { |
| 1951 | 1951 | return $this; |
| 1952 | 1952 | } |
| 1953 | - if ( null === json_decode($this->value) && JSON_ERROR_NONE !== json_last_error() ) |
|
| 1953 | + if (null === json_decode($this->value) && JSON_ERROR_NONE !== json_last_error()) |
|
| 1954 | 1954 | { |
| 1955 | 1955 | $message = sprintf( |
| 1956 | 1956 | $message ?: 'Value "%s" is not a valid JSON string.', |
@@ -1973,16 +1973,16 @@ discard block |
||
| 1973 | 1973 | */ |
| 1974 | 1974 | public function uuid($message = null, $propertyPath = null) |
| 1975 | 1975 | { |
| 1976 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 1976 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 1977 | 1977 | { |
| 1978 | 1978 | return $this; |
| 1979 | 1979 | } |
| 1980 | - $this->value = str_replace(['urn:', 'uuid:', '{', '}'], '', $this->value); |
|
| 1981 | - if ( $this->value === '00000000-0000-0000-0000-000000000000' ) |
|
| 1980 | + $this->value = str_replace([ 'urn:', 'uuid:', '{', '}' ], '', $this->value); |
|
| 1981 | + if ($this->value === '00000000-0000-0000-0000-000000000000') |
|
| 1982 | 1982 | { |
| 1983 | 1983 | return $this; |
| 1984 | 1984 | } |
| 1985 | - 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) ) |
|
| 1985 | + 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)) |
|
| 1986 | 1986 | { |
| 1987 | 1987 | $message = sprintf( |
| 1988 | 1988 | $message ?: 'Value "%s" is not a valid UUID.', |
@@ -2004,34 +2004,34 @@ discard block |
||
| 2004 | 2004 | */ |
| 2005 | 2005 | public function count($count, $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 | - if ( $count !== count($this->value) ) |
|
| 2011 | + if ($count !== count($this->value)) |
|
| 2012 | 2012 | { |
| 2013 | 2013 | $message = sprintf( |
| 2014 | 2014 | $message ?: 'List does not contain exactly "%d" elements.', |
| 2015 | 2015 | $this->stringify($this->value), |
| 2016 | 2016 | $this->stringify($count) |
| 2017 | 2017 | ); |
| 2018 | - throw $this->createException($message, self::INVALID_COUNT, $propertyPath, ['count' => $count]); |
|
| 2018 | + throw $this->createException($message, self::INVALID_COUNT, $propertyPath, [ 'count' => $count ]); |
|
| 2019 | 2019 | } |
| 2020 | 2020 | return $this; |
| 2021 | 2021 | } |
| 2022 | 2022 | |
| 2023 | 2023 | protected function doAllOrNullOr($func, $args) |
| 2024 | 2024 | { |
| 2025 | - if ( $this->nullOr && is_null($this->value) ) |
|
| 2025 | + if ($this->nullOr && is_null($this->value)) |
|
| 2026 | 2026 | { |
| 2027 | 2027 | return true; |
| 2028 | 2028 | } |
| 2029 | - if ( $this->all && (new Assert($this->value))->setExceptionClass($this->exceptionClass)->isTraversable() ) |
|
| 2029 | + if ($this->all && (new Assert($this->value))->setExceptionClass($this->exceptionClass)->isTraversable()) |
|
| 2030 | 2030 | { |
| 2031 | - foreach ( $this->value as $idx => $value ) |
|
| 2031 | + foreach ($this->value as $idx => $value) |
|
| 2032 | 2032 | { |
| 2033 | 2033 | $object = (new Assert($value))->setExceptionClass($this->exceptionClass); |
| 2034 | - call_user_func_array([$object, $func], $args); |
|
| 2034 | + call_user_func_array([ $object, $func ], $args); |
|
| 2035 | 2035 | } |
| 2036 | 2036 | return true; |
| 2037 | 2037 | } |
@@ -2048,12 +2048,12 @@ discard block |
||
| 2048 | 2048 | */ |
| 2049 | 2049 | public function choicesNotEmpty(array $choices, $message = null, $propertyPath = null) |
| 2050 | 2050 | { |
| 2051 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 2051 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 2052 | 2052 | { |
| 2053 | 2053 | return $this; |
| 2054 | 2054 | } |
| 2055 | 2055 | $this->notEmpty($message, $propertyPath); |
| 2056 | - foreach ( $choices as $choice ) |
|
| 2056 | + foreach ($choices as $choice) |
|
| 2057 | 2057 | { |
| 2058 | 2058 | $this->notEmptyKey($choice, $message, $propertyPath); |
| 2059 | 2059 | } |
@@ -2071,12 +2071,12 @@ discard block |
||
| 2071 | 2071 | */ |
| 2072 | 2072 | public function methodExists($object, $message = null, $propertyPath = null) |
| 2073 | 2073 | { |
| 2074 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 2074 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 2075 | 2075 | { |
| 2076 | 2076 | return $this; |
| 2077 | 2077 | } |
| 2078 | 2078 | (new Assert($object))->setExceptionClass($this->exceptionClass)->isObject($message, $propertyPath); |
| 2079 | - if ( !method_exists($object, $this->value) ) |
|
| 2079 | + if ( ! method_exists($object, $this->value)) |
|
| 2080 | 2080 | { |
| 2081 | 2081 | $message = sprintf( |
| 2082 | 2082 | $message ?: 'Expected "%s" does not a exist in provided object.', |
@@ -2097,11 +2097,11 @@ discard block |
||
| 2097 | 2097 | */ |
| 2098 | 2098 | public function isObject($message = null, $propertyPath = null) |
| 2099 | 2099 | { |
| 2100 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
| 2100 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
| 2101 | 2101 | { |
| 2102 | 2102 | return $this; |
| 2103 | 2103 | } |
| 2104 | - if ( !is_object($this->value) ) |
|
| 2104 | + if ( ! is_object($this->value)) |
|
| 2105 | 2105 | { |
| 2106 | 2106 | $message = sprintf( |
| 2107 | 2107 | $message ?: 'Provided "%s" is not a valid object.', |
@@ -2120,32 +2120,32 @@ discard block |
||
| 2120 | 2120 | */ |
| 2121 | 2121 | private function stringify($value) |
| 2122 | 2122 | { |
| 2123 | - if ( is_bool($value) ) |
|
| 2123 | + if (is_bool($value)) |
|
| 2124 | 2124 | { |
| 2125 | 2125 | return $value ? '<TRUE>' : '<FALSE>'; |
| 2126 | 2126 | } |
| 2127 | - if ( is_scalar($value) ) |
|
| 2127 | + if (is_scalar($value)) |
|
| 2128 | 2128 | { |
| 2129 | 2129 | $val = (string)$value; |
| 2130 | - if ( strlen($val) > 100 ) |
|
| 2130 | + if (strlen($val) > 100) |
|
| 2131 | 2131 | { |
| 2132 | - $val = substr($val, 0, 97) . '...'; |
|
| 2132 | + $val = substr($val, 0, 97).'...'; |
|
| 2133 | 2133 | } |
| 2134 | 2134 | return $val; |
| 2135 | 2135 | } |
| 2136 | - if ( is_array($value) ) |
|
| 2136 | + if (is_array($value)) |
|
| 2137 | 2137 | { |
| 2138 | 2138 | return '<ARRAY>'; |
| 2139 | 2139 | } |
| 2140 | - if ( is_object($value) ) |
|
| 2140 | + if (is_object($value)) |
|
| 2141 | 2141 | { |
| 2142 | 2142 | return get_class($value); |
| 2143 | 2143 | } |
| 2144 | - if ( is_resource($value) ) |
|
| 2144 | + if (is_resource($value)) |
|
| 2145 | 2145 | { |
| 2146 | 2146 | return '<RESOURCE>'; |
| 2147 | 2147 | } |
| 2148 | - if ( $value === null ) |
|
| 2148 | + if ($value === null) |
|
| 2149 | 2149 | { |
| 2150 | 2150 | return '<NULL>'; |
| 2151 | 2151 | } |