@@ -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 | } |
@@ -286,11 +286,11 @@ discard block |
||
286 | 286 | */ |
287 | 287 | public function isCallable($message = null, $propertyPath = null) |
288 | 288 | { |
289 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
289 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
290 | 290 | { |
291 | 291 | return $this; |
292 | 292 | } |
293 | - if ( !is_callable($this->value) ) |
|
293 | + if ( ! is_callable($this->value)) |
|
294 | 294 | { |
295 | 295 | $message = sprintf( |
296 | 296 | $message ?: 'Value "%s" is not callable.', |
@@ -312,18 +312,18 @@ discard block |
||
312 | 312 | */ |
313 | 313 | public function notSame($value2, $message = null, $propertyPath = null) |
314 | 314 | { |
315 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
315 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
316 | 316 | { |
317 | 317 | return $this; |
318 | 318 | } |
319 | - if ( $this->value === $value2 ) |
|
319 | + if ($this->value === $value2) |
|
320 | 320 | { |
321 | 321 | $message = sprintf( |
322 | 322 | $message ?: 'Value "%s" is the same as expected value "%s".', |
323 | 323 | $this->stringify($this->value), |
324 | 324 | $this->stringify($value2) |
325 | 325 | ); |
326 | - throw $this->createException($message, self::INVALID_NOT_SAME, $propertyPath, ['expected' => $value2]); |
|
326 | + throw $this->createException($message, self::INVALID_NOT_SAME, $propertyPath, [ 'expected' => $value2 ]); |
|
327 | 327 | } |
328 | 328 | return $this; |
329 | 329 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | public function status($message = null, $propertyPath = null) |
344 | 344 | { |
345 | 345 | $message = $message ?: 'Value "%s" is not a valid status.'; |
346 | - return $this->integer($message, $propertyPath)->inArray([-1, 0, 1]); |
|
346 | + return $this->integer($message, $propertyPath)->inArray([-1, 0, 1 ]); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | public function nullOrId($message = null, $propertyPath = null) |
@@ -371,11 +371,11 @@ discard block |
||
371 | 371 | */ |
372 | 372 | public function integer($message = null, $propertyPath = null) |
373 | 373 | { |
374 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
374 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
375 | 375 | { |
376 | 376 | return $this; |
377 | 377 | } |
378 | - if ( !is_int($this->value) ) |
|
378 | + if ( ! is_int($this->value)) |
|
379 | 379 | { |
380 | 380 | $message = sprintf( |
381 | 381 | $message ?: 'Value "%s" is not an integer.', |
@@ -396,11 +396,11 @@ discard block |
||
396 | 396 | */ |
397 | 397 | public function float($message = null, $propertyPath = null) |
398 | 398 | { |
399 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
399 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
400 | 400 | { |
401 | 401 | return $this; |
402 | 402 | } |
403 | - if ( !is_float($this->value) ) |
|
403 | + if ( ! is_float($this->value)) |
|
404 | 404 | { |
405 | 405 | $message = sprintf( |
406 | 406 | $message ?: 'Value "%s" is not a float.', |
@@ -421,11 +421,11 @@ discard block |
||
421 | 421 | */ |
422 | 422 | public function digit($message = null, $propertyPath = null) |
423 | 423 | { |
424 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
424 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
425 | 425 | { |
426 | 426 | return $this; |
427 | 427 | } |
428 | - if ( !ctype_digit((string)$this->value) ) |
|
428 | + if ( ! ctype_digit((string)$this->value)) |
|
429 | 429 | { |
430 | 430 | $message = sprintf( |
431 | 431 | $message ?: 'Value "%s" is not a digit.', |
@@ -446,12 +446,12 @@ discard block |
||
446 | 446 | */ |
447 | 447 | public function date($message = null, $propertyPath = null) |
448 | 448 | { |
449 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
449 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
450 | 450 | { |
451 | 451 | return $this; |
452 | 452 | } |
453 | 453 | $this->notEmpty($message, $propertyPath); |
454 | - if ( strtotime($this->value) === false ) |
|
454 | + if (strtotime($this->value) === false) |
|
455 | 455 | { |
456 | 456 | $message = sprintf( |
457 | 457 | $message ?: 'Value "%s" is not a date.', |
@@ -472,11 +472,11 @@ discard block |
||
472 | 472 | */ |
473 | 473 | public function integerish($message = null, $propertyPath = null) |
474 | 474 | { |
475 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
475 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
476 | 476 | { |
477 | 477 | return $this; |
478 | 478 | } |
479 | - if ( is_object($this->value) || strval(intval($this->value)) != $this->value || is_bool($this->value) || is_null($this->value) ) |
|
479 | + if (is_object($this->value) || strval(intval($this->value)) != $this->value || is_bool($this->value) || is_null($this->value)) |
|
480 | 480 | { |
481 | 481 | $message = sprintf( |
482 | 482 | $message ?: 'Value "%s" is not an integer or a number castable to integer.', |
@@ -497,11 +497,11 @@ discard block |
||
497 | 497 | */ |
498 | 498 | public function boolean($message = null, $propertyPath = null) |
499 | 499 | { |
500 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
500 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
501 | 501 | { |
502 | 502 | return $this; |
503 | 503 | } |
504 | - if ( !is_bool($this->value) ) |
|
504 | + if ( ! is_bool($this->value)) |
|
505 | 505 | { |
506 | 506 | $message = sprintf( |
507 | 507 | $message ?: 'Value "%s" is not a boolean.', |
@@ -522,11 +522,11 @@ discard block |
||
522 | 522 | */ |
523 | 523 | public function scalar($message = null, $propertyPath = null) |
524 | 524 | { |
525 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
525 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
526 | 526 | { |
527 | 527 | return $this; |
528 | 528 | } |
529 | - if ( !is_scalar($this->value) ) |
|
529 | + if ( ! is_scalar($this->value)) |
|
530 | 530 | { |
531 | 531 | $message = sprintf( |
532 | 532 | $message ?: 'Value "%s" is not a scalar.', |
@@ -547,11 +547,11 @@ discard block |
||
547 | 547 | */ |
548 | 548 | public function notEmpty($message = null, $propertyPath = null) |
549 | 549 | { |
550 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
550 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
551 | 551 | { |
552 | 552 | return $this; |
553 | 553 | } |
554 | - if ( ( is_object($this->value) && empty((array)$this->value) ) || empty($this->value) ) |
|
554 | + if ((is_object($this->value) && empty((array)$this->value)) || empty($this->value)) |
|
555 | 555 | { |
556 | 556 | $message = sprintf( |
557 | 557 | $message ?: 'Value "%s" is empty, but non empty value was expected.', |
@@ -572,11 +572,11 @@ discard block |
||
572 | 572 | */ |
573 | 573 | public function noContent($message = null, $propertyPath = null) |
574 | 574 | { |
575 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
575 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
576 | 576 | { |
577 | 577 | return $this; |
578 | 578 | } |
579 | - if ( !empty( $this->value ) ) |
|
579 | + if ( ! empty($this->value)) |
|
580 | 580 | { |
581 | 581 | $message = sprintf( |
582 | 582 | $message ?: 'Value "%s" is not empty, but empty value was expected.', |
@@ -597,11 +597,11 @@ discard block |
||
597 | 597 | */ |
598 | 598 | public function notNull($message = null, $propertyPath = null) |
599 | 599 | { |
600 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
600 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
601 | 601 | { |
602 | 602 | return $this; |
603 | 603 | } |
604 | - if ( $this->value === null ) |
|
604 | + if ($this->value === null) |
|
605 | 605 | { |
606 | 606 | $message = sprintf( |
607 | 607 | $message ?: 'Value "%s" is null, but non null value was expected.', |
@@ -622,11 +622,11 @@ discard block |
||
622 | 622 | */ |
623 | 623 | public function string($message = null, $propertyPath = null) |
624 | 624 | { |
625 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
625 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
626 | 626 | { |
627 | 627 | return $this; |
628 | 628 | } |
629 | - if ( !is_string($this->value) ) |
|
629 | + if ( ! is_string($this->value)) |
|
630 | 630 | { |
631 | 631 | $message = sprintf( |
632 | 632 | $message ?: 'Value "%s" expected to be string, type %s given.', |
@@ -649,36 +649,36 @@ discard block |
||
649 | 649 | */ |
650 | 650 | public function regex($pattern, $message = null, $propertyPath = null) |
651 | 651 | { |
652 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
652 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
653 | 653 | { |
654 | 654 | return $this; |
655 | 655 | } |
656 | 656 | $this->string($message, $propertyPath); |
657 | - if ( !preg_match($pattern, $this->value) ) |
|
657 | + if ( ! preg_match($pattern, $this->value)) |
|
658 | 658 | { |
659 | 659 | $message = sprintf( |
660 | 660 | $message ?: 'Value "%s" does not match expression.', |
661 | 661 | $this->stringify($this->value) |
662 | 662 | ); |
663 | - throw $this->createException($message, self::INVALID_REGEX, $propertyPath, ['pattern' => $pattern]); |
|
663 | + throw $this->createException($message, self::INVALID_REGEX, $propertyPath, [ 'pattern' => $pattern ]); |
|
664 | 664 | } |
665 | 665 | return $this; |
666 | 666 | } |
667 | 667 | |
668 | 668 | public function notRegex($pattern, $message = null, $propertyPath = null) |
669 | 669 | { |
670 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
670 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
671 | 671 | { |
672 | 672 | return $this; |
673 | 673 | } |
674 | 674 | $this->string($message, $propertyPath); |
675 | - if ( preg_match($pattern, $this->value) ) |
|
675 | + if (preg_match($pattern, $this->value)) |
|
676 | 676 | { |
677 | 677 | $message = sprintf( |
678 | 678 | $message ?: 'Value "%s" does not match expression.', |
679 | 679 | $this->stringify($this->value) |
680 | 680 | ); |
681 | - throw $this->createException($message, self::INVALID_REGEX, $propertyPath, ['pattern' => $pattern]); |
|
681 | + throw $this->createException($message, self::INVALID_REGEX, $propertyPath, [ 'pattern' => $pattern ]); |
|
682 | 682 | } |
683 | 683 | return $this; |
684 | 684 | } |
@@ -695,20 +695,20 @@ discard block |
||
695 | 695 | */ |
696 | 696 | public function length($length, $message = null, $propertyPath = null, $encoding = 'utf8') |
697 | 697 | { |
698 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
698 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
699 | 699 | { |
700 | 700 | return $this; |
701 | 701 | } |
702 | 702 | $this->string($message, $propertyPath); |
703 | - if ( mb_strlen($this->value, $encoding) !== $length ) |
|
703 | + if (mb_strlen($this->value, $encoding) !== $length) |
|
704 | 704 | { |
705 | - $message = sprintf( |
|
705 | + $message = sprintf( |
|
706 | 706 | $message ?: 'Value "%s" has to be %d exactly characters long, but length is %d.', |
707 | 707 | $this->stringify($this->value), |
708 | 708 | $length, |
709 | 709 | mb_strlen($this->value, $encoding) |
710 | 710 | ); |
711 | - $constraints = ['length' => $length, 'encoding' => $encoding]; |
|
711 | + $constraints = [ 'length' => $length, 'encoding' => $encoding ]; |
|
712 | 712 | throw $this->createException($message, self::INVALID_LENGTH, $propertyPath, $constraints); |
713 | 713 | } |
714 | 714 | return $this; |
@@ -726,21 +726,21 @@ discard block |
||
726 | 726 | */ |
727 | 727 | public function minLength($minLength, $message = null, $propertyPath = null, $encoding = 'utf8') |
728 | 728 | { |
729 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
729 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
730 | 730 | { |
731 | 731 | return $this; |
732 | 732 | } |
733 | 733 | $this->string($message, $propertyPath); |
734 | - if ( mb_strlen($this->value, $encoding) < $minLength ) |
|
734 | + if (mb_strlen($this->value, $encoding) < $minLength) |
|
735 | 735 | { |
736 | - $message = sprintf( |
|
736 | + $message = sprintf( |
|
737 | 737 | $message |
738 | 738 | ?: 'Value "%s" is too short, it should have more than %d characters, but only has %d characters.', |
739 | 739 | $this->stringify($this->value), |
740 | 740 | $minLength, |
741 | 741 | mb_strlen($this->value, $encoding) |
742 | 742 | ); |
743 | - $constraints = ['min_length' => $minLength, 'encoding' => $encoding]; |
|
743 | + $constraints = [ 'min_length' => $minLength, 'encoding' => $encoding ]; |
|
744 | 744 | throw $this->createException($message, self::INVALID_MIN_LENGTH, $propertyPath, $constraints); |
745 | 745 | } |
746 | 746 | return $this; |
@@ -758,20 +758,20 @@ discard block |
||
758 | 758 | */ |
759 | 759 | public function maxLength($maxLength, $message = null, $propertyPath = null, $encoding = 'utf8') |
760 | 760 | { |
761 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
761 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
762 | 762 | { |
763 | 763 | return $this; |
764 | 764 | } |
765 | 765 | $this->string($message, $propertyPath); |
766 | - if ( mb_strlen($this->value, $encoding) > $maxLength ) |
|
766 | + if (mb_strlen($this->value, $encoding) > $maxLength) |
|
767 | 767 | { |
768 | - $message = sprintf( |
|
768 | + $message = sprintf( |
|
769 | 769 | $message ?: 'Value "%s" is too long, it should have no more than %d characters, but has %d characters.', |
770 | 770 | $this->stringify($this->value), |
771 | 771 | $maxLength, |
772 | 772 | mb_strlen($this->value, $encoding) |
773 | 773 | ); |
774 | - $constraints = ['max_length' => $maxLength, 'encoding' => $encoding]; |
|
774 | + $constraints = [ 'max_length' => $maxLength, 'encoding' => $encoding ]; |
|
775 | 775 | throw $this->createException($message, self::INVALID_MAX_LENGTH, $propertyPath, $constraints); |
776 | 776 | } |
777 | 777 | return $this; |
@@ -790,32 +790,32 @@ discard block |
||
790 | 790 | */ |
791 | 791 | public function betweenLength($minLength, $maxLength, $message = null, $propertyPath = null, $encoding = 'utf8') |
792 | 792 | { |
793 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
793 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
794 | 794 | { |
795 | 795 | return $this; |
796 | 796 | } |
797 | 797 | $this->string($message, $propertyPath); |
798 | - if ( mb_strlen($this->value, $encoding) < $minLength ) |
|
798 | + if (mb_strlen($this->value, $encoding) < $minLength) |
|
799 | 799 | { |
800 | - $message = sprintf( |
|
800 | + $message = sprintf( |
|
801 | 801 | $message |
802 | 802 | ?: 'Value "%s" is too short, it should have more than %d characters, but only has %d characters.', |
803 | 803 | $this->stringify($this->value), |
804 | 804 | $minLength, |
805 | 805 | mb_strlen($this->value, $encoding) |
806 | 806 | ); |
807 | - $constraints = ['min_length' => $minLength, 'encoding' => $encoding]; |
|
807 | + $constraints = [ 'min_length' => $minLength, 'encoding' => $encoding ]; |
|
808 | 808 | throw $this->createException($message, self::INVALID_MIN_LENGTH, $propertyPath, $constraints); |
809 | 809 | } |
810 | - if ( mb_strlen($this->value, $encoding) > $maxLength ) |
|
810 | + if (mb_strlen($this->value, $encoding) > $maxLength) |
|
811 | 811 | { |
812 | - $message = sprintf( |
|
812 | + $message = sprintf( |
|
813 | 813 | $message ?: 'Value "%s" is too long, it should have no more than %d characters, but has %d characters.', |
814 | 814 | $this->stringify($this->value), |
815 | 815 | $maxLength, |
816 | 816 | mb_strlen($this->value, $encoding) |
817 | 817 | ); |
818 | - $constraints = ['max_length' => $maxLength, 'encoding' => $encoding]; |
|
818 | + $constraints = [ 'max_length' => $maxLength, 'encoding' => $encoding ]; |
|
819 | 819 | throw $this->createException($message, self::INVALID_MAX_LENGTH, $propertyPath, $constraints); |
820 | 820 | } |
821 | 821 | return $this; |
@@ -833,19 +833,19 @@ discard block |
||
833 | 833 | */ |
834 | 834 | public function startsWith($needle, $message = null, $propertyPath = null, $encoding = 'utf8') |
835 | 835 | { |
836 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
836 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
837 | 837 | { |
838 | 838 | return $this; |
839 | 839 | } |
840 | 840 | $this->string($message, $propertyPath); |
841 | - if ( mb_strpos($this->value, $needle, null, $encoding) !== 0 ) |
|
841 | + if (mb_strpos($this->value, $needle, null, $encoding) !== 0) |
|
842 | 842 | { |
843 | - $message = sprintf( |
|
843 | + $message = sprintf( |
|
844 | 844 | $message ?: 'Value "%s" does not start with "%s".', |
845 | 845 | $this->stringify($this->value), |
846 | 846 | $this->stringify($needle) |
847 | 847 | ); |
848 | - $constraints = ['needle' => $needle, 'encoding' => $encoding]; |
|
848 | + $constraints = [ 'needle' => $needle, 'encoding' => $encoding ]; |
|
849 | 849 | throw $this->createException($message, self::INVALID_STRING_START, $propertyPath, $constraints); |
850 | 850 | } |
851 | 851 | return $this; |
@@ -863,20 +863,20 @@ discard block |
||
863 | 863 | */ |
864 | 864 | public function endsWith($needle, $message = null, $propertyPath = null, $encoding = 'utf8') |
865 | 865 | { |
866 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
866 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
867 | 867 | { |
868 | 868 | return $this; |
869 | 869 | } |
870 | 870 | $this->string($message, $propertyPath); |
871 | 871 | $stringPosition = mb_strlen($this->value, $encoding) - mb_strlen($needle, $encoding); |
872 | - if ( mb_strripos($this->value, $needle, null, $encoding) !== $stringPosition ) |
|
872 | + if (mb_strripos($this->value, $needle, null, $encoding) !== $stringPosition) |
|
873 | 873 | { |
874 | - $message = sprintf( |
|
874 | + $message = sprintf( |
|
875 | 875 | $message ?: 'Value "%s" does not end with "%s".', |
876 | 876 | $this->stringify($this->value), |
877 | 877 | $this->stringify($needle) |
878 | 878 | ); |
879 | - $constraints = ['needle' => $needle, 'encoding' => $encoding]; |
|
879 | + $constraints = [ 'needle' => $needle, 'encoding' => $encoding ]; |
|
880 | 880 | throw $this->createException($message, self::INVALID_STRING_END, $propertyPath, $constraints); |
881 | 881 | } |
882 | 882 | return $this; |
@@ -894,19 +894,19 @@ discard block |
||
894 | 894 | */ |
895 | 895 | public function contains($needle, $message = null, $propertyPath = null, $encoding = 'utf8') |
896 | 896 | { |
897 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
897 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
898 | 898 | { |
899 | 899 | return $this; |
900 | 900 | } |
901 | 901 | $this->string($message, $propertyPath); |
902 | - if ( mb_strpos($this->value, $needle, null, $encoding) === false ) |
|
902 | + if (mb_strpos($this->value, $needle, null, $encoding) === false) |
|
903 | 903 | { |
904 | - $message = sprintf( |
|
904 | + $message = sprintf( |
|
905 | 905 | $message ?: 'Value "%s" does not contain "%s".', |
906 | 906 | $this->stringify($this->value), |
907 | 907 | $this->stringify($needle) |
908 | 908 | ); |
909 | - $constraints = ['needle' => $needle, 'encoding' => $encoding]; |
|
909 | + $constraints = [ 'needle' => $needle, 'encoding' => $encoding ]; |
|
910 | 910 | throw $this->createException($message, self::INVALID_STRING_CONTAINS, $propertyPath, $constraints); |
911 | 911 | } |
912 | 912 | return $this; |
@@ -923,18 +923,18 @@ discard block |
||
923 | 923 | */ |
924 | 924 | public function choice(array $choices, $message = null, $propertyPath = null) |
925 | 925 | { |
926 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
926 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
927 | 927 | { |
928 | 928 | return $this; |
929 | 929 | } |
930 | - if ( !in_array($this->value, $choices, true) ) |
|
930 | + if ( ! in_array($this->value, $choices, true)) |
|
931 | 931 | { |
932 | 932 | $message = sprintf( |
933 | 933 | $message ?: 'Value "%s" is not an element of the valid values: %s', |
934 | 934 | $this->stringify($this->value), |
935 | 935 | implode(", ", array_map('Terah\Assert\Assert::stringify', $choices)) |
936 | 936 | ); |
937 | - throw $this->createException($message, self::INVALID_CHOICE, $propertyPath, ['choices' => $choices]); |
|
937 | + throw $this->createException($message, self::INVALID_CHOICE, $propertyPath, [ 'choices' => $choices ]); |
|
938 | 938 | } |
939 | 939 | return $this; |
940 | 940 | } |
@@ -951,7 +951,7 @@ discard block |
||
951 | 951 | */ |
952 | 952 | public function inArray(array $choices, $message = null, $propertyPath = null) |
953 | 953 | { |
954 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
954 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
955 | 955 | { |
956 | 956 | return $this; |
957 | 957 | } |
@@ -969,11 +969,11 @@ discard block |
||
969 | 969 | */ |
970 | 970 | public function numeric($message = null, $propertyPath = null) |
971 | 971 | { |
972 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
972 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
973 | 973 | { |
974 | 974 | return $this; |
975 | 975 | } |
976 | - if ( ! is_numeric($this->value) ) |
|
976 | + if ( ! is_numeric($this->value)) |
|
977 | 977 | { |
978 | 978 | $message = sprintf( |
979 | 979 | $message ?: 'Value "%s" is not numeric.', |
@@ -1012,11 +1012,11 @@ discard block |
||
1012 | 1012 | */ |
1013 | 1013 | public function isArray($message = null, $propertyPath = null) |
1014 | 1014 | { |
1015 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1015 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1016 | 1016 | { |
1017 | 1017 | return $this; |
1018 | 1018 | } |
1019 | - if ( !is_array($this->value) ) |
|
1019 | + if ( ! is_array($this->value)) |
|
1020 | 1020 | { |
1021 | 1021 | $message = sprintf( |
1022 | 1022 | $message ?: 'Value "%s" is not an array.', |
@@ -1037,11 +1037,11 @@ discard block |
||
1037 | 1037 | */ |
1038 | 1038 | public function isTraversable($message = null, $propertyPath = null) |
1039 | 1039 | { |
1040 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1040 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1041 | 1041 | { |
1042 | 1042 | return $this; |
1043 | 1043 | } |
1044 | - if ( !is_array($this->value) && !$this->value instanceof \Traversable ) |
|
1044 | + if ( ! is_array($this->value) && ! $this->value instanceof \Traversable) |
|
1045 | 1045 | { |
1046 | 1046 | $message = sprintf( |
1047 | 1047 | $message ?: 'Value "%s" is not an array and does not implement Traversable.', |
@@ -1062,11 +1062,11 @@ discard block |
||
1062 | 1062 | */ |
1063 | 1063 | public function isArrayAccessible($message = null, $propertyPath = null) |
1064 | 1064 | { |
1065 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1065 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1066 | 1066 | { |
1067 | 1067 | return $this; |
1068 | 1068 | } |
1069 | - if ( !is_array($this->value) && !$this->value instanceof \ArrayAccess ) |
|
1069 | + if ( ! is_array($this->value) && ! $this->value instanceof \ArrayAccess) |
|
1070 | 1070 | { |
1071 | 1071 | $message = sprintf( |
1072 | 1072 | $message ?: 'Value "%s" is not an array and does not implement ArrayAccess.', |
@@ -1088,18 +1088,18 @@ discard block |
||
1088 | 1088 | */ |
1089 | 1089 | public function keyExists($key, $message = null, $propertyPath = null) |
1090 | 1090 | { |
1091 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1091 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1092 | 1092 | { |
1093 | 1093 | return $this; |
1094 | 1094 | } |
1095 | 1095 | $this->isArray($message, $propertyPath); |
1096 | - if ( !array_key_exists($key, $this->value) ) |
|
1096 | + if ( ! array_key_exists($key, $this->value)) |
|
1097 | 1097 | { |
1098 | 1098 | $message = sprintf( |
1099 | 1099 | $message ?: 'Array does not contain an element with key "%s"', |
1100 | 1100 | $this->stringify($key) |
1101 | 1101 | ); |
1102 | - throw $this->createException($message, self::INVALID_KEY_EXISTS, $propertyPath, ['key' => $key]); |
|
1102 | + throw $this->createException($message, self::INVALID_KEY_EXISTS, $propertyPath, [ 'key' => $key ]); |
|
1103 | 1103 | } |
1104 | 1104 | return $this; |
1105 | 1105 | } |
@@ -1115,21 +1115,21 @@ discard block |
||
1115 | 1115 | */ |
1116 | 1116 | public function keysExist($keys, $message = null, $propertyPath = null) |
1117 | 1117 | { |
1118 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1118 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1119 | 1119 | { |
1120 | 1120 | return $this; |
1121 | 1121 | } |
1122 | 1122 | $this->isArray($message, $propertyPath); |
1123 | - foreach ( $keys as $key ) |
|
1123 | + foreach ($keys as $key) |
|
1124 | 1124 | { |
1125 | - if ( !array_key_exists($key, $this->value) ) |
|
1125 | + if ( ! array_key_exists($key, $this->value)) |
|
1126 | 1126 | { |
1127 | 1127 | $message = $message |
1128 | 1128 | ?: sprintf( |
1129 | 1129 | 'Array does not contain an element with key "%s"', |
1130 | 1130 | $this->stringify($key) |
1131 | 1131 | ); |
1132 | - throw $this->createException($message, self::INVALID_KEYS_EXIST, $propertyPath, ['key' => $key]); |
|
1132 | + throw $this->createException($message, self::INVALID_KEYS_EXIST, $propertyPath, [ 'key' => $key ]); |
|
1133 | 1133 | } |
1134 | 1134 | } |
1135 | 1135 | return $this; |
@@ -1146,19 +1146,19 @@ discard block |
||
1146 | 1146 | */ |
1147 | 1147 | public function propertyExists($key, $message = null, $propertyPath = null) |
1148 | 1148 | { |
1149 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1149 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1150 | 1150 | { |
1151 | 1151 | return $this; |
1152 | 1152 | } |
1153 | 1153 | $this->isObject($message, $propertyPath); |
1154 | - if ( !property_exists($this->value, $key) && !isset( $this->value->$key ) ) |
|
1154 | + if ( ! property_exists($this->value, $key) && ! isset($this->value->$key)) |
|
1155 | 1155 | { |
1156 | 1156 | $message = $message |
1157 | 1157 | ?: sprintf( |
1158 | 1158 | 'Object does not contain a property with key "%s"', |
1159 | 1159 | $this->stringify($key) |
1160 | 1160 | ); |
1161 | - throw $this->createException($message, self::INVALID_PROPERTY_EXISTS, $propertyPath, ['key' => $key]); |
|
1161 | + throw $this->createException($message, self::INVALID_PROPERTY_EXISTS, $propertyPath, [ 'key' => $key ]); |
|
1162 | 1162 | } |
1163 | 1163 | return $this; |
1164 | 1164 | } |
@@ -1174,22 +1174,22 @@ discard block |
||
1174 | 1174 | */ |
1175 | 1175 | public function propertiesExist(array $keys, $message = null, $propertyPath = null) |
1176 | 1176 | { |
1177 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1177 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1178 | 1178 | { |
1179 | 1179 | return $this; |
1180 | 1180 | } |
1181 | 1181 | $this->isObject($message, $propertyPath); |
1182 | - foreach ( $keys as $key ) |
|
1182 | + foreach ($keys as $key) |
|
1183 | 1183 | { |
1184 | 1184 | // Using isset to allow resolution of magically defined properties |
1185 | - if ( !property_exists($this->value, $key) && !isset( $this->value->$key ) ) |
|
1185 | + if ( ! property_exists($this->value, $key) && ! isset($this->value->$key)) |
|
1186 | 1186 | { |
1187 | 1187 | $message = $message |
1188 | 1188 | ?: sprintf( |
1189 | 1189 | 'Object does not contain a property with key "%s"', |
1190 | 1190 | $this->stringify($key) |
1191 | 1191 | ); |
1192 | - throw $this->createException($message, self::INVALID_PROPERTIES_EXIST, $propertyPath, ['key' => $key]); |
|
1192 | + throw $this->createException($message, self::INVALID_PROPERTIES_EXIST, $propertyPath, [ 'key' => $key ]); |
|
1193 | 1193 | } |
1194 | 1194 | } |
1195 | 1195 | return $this; |
@@ -1205,12 +1205,12 @@ discard block |
||
1205 | 1205 | */ |
1206 | 1206 | public function utf8($message = null, $propertyPath = null) |
1207 | 1207 | { |
1208 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1208 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1209 | 1209 | { |
1210 | 1210 | return $this; |
1211 | 1211 | } |
1212 | 1212 | $this->string($message, $propertyPath); |
1213 | - if ( mb_detect_encoding($this->value, 'UTF-8', true) !== 'UTF-8' ) |
|
1213 | + if (mb_detect_encoding($this->value, 'UTF-8', true) !== 'UTF-8') |
|
1214 | 1214 | { |
1215 | 1215 | $message = $message |
1216 | 1216 | ?: sprintf( |
@@ -1233,12 +1233,12 @@ discard block |
||
1233 | 1233 | */ |
1234 | 1234 | public function ascii($message = null, $propertyPath = null) |
1235 | 1235 | { |
1236 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1236 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1237 | 1237 | { |
1238 | 1238 | return $this; |
1239 | 1239 | } |
1240 | 1240 | $this->string($message, $propertyPath); |
1241 | - if ( ! preg_match('/^[ -~]+$/', $this->value) ) |
|
1241 | + if ( ! preg_match('/^[ -~]+$/', $this->value)) |
|
1242 | 1242 | { |
1243 | 1243 | $message = $message |
1244 | 1244 | ?: sprintf( |
@@ -1261,18 +1261,18 @@ discard block |
||
1261 | 1261 | */ |
1262 | 1262 | public function keyIsset($key, $message = null, $propertyPath = null) |
1263 | 1263 | { |
1264 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1264 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1265 | 1265 | { |
1266 | 1266 | return $this; |
1267 | 1267 | } |
1268 | 1268 | $this->isArrayAccessible($message, $propertyPath); |
1269 | - if ( !isset( $this->value[$key] ) ) |
|
1269 | + if ( ! isset($this->value[ $key ])) |
|
1270 | 1270 | { |
1271 | 1271 | $message = sprintf( |
1272 | 1272 | $message ?: 'The element with key "%s" was not found', |
1273 | 1273 | $this->stringify($key) |
1274 | 1274 | ); |
1275 | - throw $this->createException($message, self::INVALID_KEY_ISSET, $propertyPath, ['key' => $key]); |
|
1275 | + throw $this->createException($message, self::INVALID_KEY_ISSET, $propertyPath, [ 'key' => $key ]); |
|
1276 | 1276 | } |
1277 | 1277 | return $this; |
1278 | 1278 | } |
@@ -1288,12 +1288,12 @@ discard block |
||
1288 | 1288 | */ |
1289 | 1289 | public function notEmptyKey($key, $message = null, $propertyPath = null) |
1290 | 1290 | { |
1291 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1291 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1292 | 1292 | { |
1293 | 1293 | return $this; |
1294 | 1294 | } |
1295 | 1295 | $this->keyIsset($key, $message, $propertyPath); |
1296 | - Assert($this->value[$key])->notEmpty($message, $propertyPath); |
|
1296 | + Assert($this->value[ $key ])->notEmpty($message, $propertyPath); |
|
1297 | 1297 | return $this; |
1298 | 1298 | } |
1299 | 1299 | |
@@ -1307,11 +1307,11 @@ discard block |
||
1307 | 1307 | */ |
1308 | 1308 | public function notBlank($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 ( false === $this->value || ( empty( $this->value ) && '0' != $this->value ) ) |
|
1314 | + if (false === $this->value || (empty($this->value) && '0' != $this->value)) |
|
1315 | 1315 | { |
1316 | 1316 | $message = sprintf( |
1317 | 1317 | $message ?: 'Value "%s" is blank, but was expected to contain a value.', |
@@ -1333,18 +1333,18 @@ discard block |
||
1333 | 1333 | */ |
1334 | 1334 | public function isInstanceOf($className, $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 ( !( $this->value instanceof $className ) ) |
|
1340 | + if ( ! ($this->value instanceof $className)) |
|
1341 | 1341 | { |
1342 | 1342 | $message = sprintf( |
1343 | 1343 | $message ?: 'Class "%s" was expected to be instanceof of "%s" but is not.', |
1344 | 1344 | $this->stringify($this->value), |
1345 | 1345 | $className |
1346 | 1346 | ); |
1347 | - throw $this->createException($message, self::INVALID_INSTANCE_OF, $propertyPath, ['class' => $className]); |
|
1347 | + throw $this->createException($message, self::INVALID_INSTANCE_OF, $propertyPath, [ 'class' => $className ]); |
|
1348 | 1348 | } |
1349 | 1349 | return $this; |
1350 | 1350 | } |
@@ -1360,18 +1360,18 @@ discard block |
||
1360 | 1360 | */ |
1361 | 1361 | public function notIsInstanceOf($className, $message = null, $propertyPath = null) |
1362 | 1362 | { |
1363 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1363 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1364 | 1364 | { |
1365 | 1365 | return $this; |
1366 | 1366 | } |
1367 | - if ( $this->value instanceof $className ) |
|
1367 | + if ($this->value instanceof $className) |
|
1368 | 1368 | { |
1369 | 1369 | $message = sprintf( |
1370 | 1370 | $message ?: 'Class "%s" was not expected to be instanceof of "%s".', |
1371 | 1371 | $this->stringify($this->value), |
1372 | 1372 | $className |
1373 | 1373 | ); |
1374 | - throw $this->createException($message, self::INVALID_NOT_INSTANCE_OF, $propertyPath, ['class' => $className]); |
|
1374 | + throw $this->createException($message, self::INVALID_NOT_INSTANCE_OF, $propertyPath, [ 'class' => $className ]); |
|
1375 | 1375 | } |
1376 | 1376 | return $this; |
1377 | 1377 | } |
@@ -1387,18 +1387,18 @@ discard block |
||
1387 | 1387 | */ |
1388 | 1388 | public function subclassOf($className, $message = null, $propertyPath = null) |
1389 | 1389 | { |
1390 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1390 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1391 | 1391 | { |
1392 | 1392 | return $this; |
1393 | 1393 | } |
1394 | - if ( !is_subclass_of($this->value, $className) ) |
|
1394 | + if ( ! is_subclass_of($this->value, $className)) |
|
1395 | 1395 | { |
1396 | 1396 | $message = sprintf( |
1397 | 1397 | $message ?: 'Class "%s" was expected to be subclass of "%s".', |
1398 | 1398 | $this->stringify($this->value), |
1399 | 1399 | $className |
1400 | 1400 | ); |
1401 | - throw $this->createException($message, self::INVALID_SUBCLASS_OF, $propertyPath, ['class' => $className]); |
|
1401 | + throw $this->createException($message, self::INVALID_SUBCLASS_OF, $propertyPath, [ 'class' => $className ]); |
|
1402 | 1402 | } |
1403 | 1403 | return $this; |
1404 | 1404 | } |
@@ -1415,12 +1415,12 @@ discard block |
||
1415 | 1415 | */ |
1416 | 1416 | public function range($minValue, $maxValue, $message = null, $propertyPath = null) |
1417 | 1417 | { |
1418 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1418 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1419 | 1419 | { |
1420 | 1420 | return $this; |
1421 | 1421 | } |
1422 | 1422 | $this->numeric($message, $propertyPath); |
1423 | - if ( $this->value < $minValue || $this->value > $maxValue ) |
|
1423 | + if ($this->value < $minValue || $this->value > $maxValue) |
|
1424 | 1424 | { |
1425 | 1425 | $message = sprintf( |
1426 | 1426 | $message ?: 'Number "%s" was expected to be at least "%d" and at most "%d".', |
@@ -1447,19 +1447,19 @@ discard block |
||
1447 | 1447 | */ |
1448 | 1448 | public function min($minValue, $message = null, $propertyPath = null) |
1449 | 1449 | { |
1450 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1450 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1451 | 1451 | { |
1452 | 1452 | return $this; |
1453 | 1453 | } |
1454 | 1454 | $this->numeric($message, $propertyPath); |
1455 | - if ( $this->value < $minValue ) |
|
1455 | + if ($this->value < $minValue) |
|
1456 | 1456 | { |
1457 | 1457 | $message = sprintf( |
1458 | 1458 | $message ?: 'Number "%s" was expected to be at least "%d".', |
1459 | 1459 | $this->stringify($this->value), |
1460 | 1460 | $this->stringify($minValue) |
1461 | 1461 | ); |
1462 | - throw $this->createException($message, self::INVALID_MIN, $propertyPath, ['min' => $minValue]); |
|
1462 | + throw $this->createException($message, self::INVALID_MIN, $propertyPath, [ 'min' => $minValue ]); |
|
1463 | 1463 | } |
1464 | 1464 | return $this; |
1465 | 1465 | } |
@@ -1475,19 +1475,19 @@ discard block |
||
1475 | 1475 | */ |
1476 | 1476 | public function max($maxValue, $message = null, $propertyPath = null) |
1477 | 1477 | { |
1478 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1478 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1479 | 1479 | { |
1480 | 1480 | return $this; |
1481 | 1481 | } |
1482 | 1482 | $this->numeric($message, $propertyPath); |
1483 | - if ( $this->value > $maxValue ) |
|
1483 | + if ($this->value > $maxValue) |
|
1484 | 1484 | { |
1485 | 1485 | $message = sprintf( |
1486 | 1486 | $message ?: 'Number "%s" was expected to be at most "%d".', |
1487 | 1487 | $this->stringify($this->value), |
1488 | 1488 | $this->stringify($maxValue) |
1489 | 1489 | ); |
1490 | - throw $this->createException($message, self::INVALID_MAX, $propertyPath, ['max' => $maxValue]); |
|
1490 | + throw $this->createException($message, self::INVALID_MAX, $propertyPath, [ 'max' => $maxValue ]); |
|
1491 | 1491 | } |
1492 | 1492 | return $this; |
1493 | 1493 | } |
@@ -1502,13 +1502,13 @@ discard block |
||
1502 | 1502 | */ |
1503 | 1503 | public function file($message = null, $propertyPath = null) |
1504 | 1504 | { |
1505 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1505 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1506 | 1506 | { |
1507 | 1507 | return $this; |
1508 | 1508 | } |
1509 | 1509 | $this->string($message, $propertyPath); |
1510 | 1510 | $this->notEmpty($message, $propertyPath); |
1511 | - if ( !is_file($this->value) ) |
|
1511 | + if ( ! is_file($this->value)) |
|
1512 | 1512 | { |
1513 | 1513 | $message = sprintf( |
1514 | 1514 | $message ?: 'File "%s" was expected to exist.', |
@@ -1526,13 +1526,13 @@ discard block |
||
1526 | 1526 | */ |
1527 | 1527 | public function fileExists($message = null, $propertyPath = null) |
1528 | 1528 | { |
1529 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1529 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1530 | 1530 | { |
1531 | 1531 | return $this; |
1532 | 1532 | } |
1533 | 1533 | $this->string($message, $propertyPath); |
1534 | 1534 | $this->notEmpty($message, $propertyPath); |
1535 | - if ( ! file_exists($this->value) ) |
|
1535 | + if ( ! file_exists($this->value)) |
|
1536 | 1536 | { |
1537 | 1537 | $message = sprintf( |
1538 | 1538 | $message ?: 'File or directory "%s" was expected to exist.', |
@@ -1553,12 +1553,12 @@ discard block |
||
1553 | 1553 | */ |
1554 | 1554 | public function directory($message = null, $propertyPath = null) |
1555 | 1555 | { |
1556 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1556 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1557 | 1557 | { |
1558 | 1558 | return $this; |
1559 | 1559 | } |
1560 | 1560 | $this->string($message, $propertyPath); |
1561 | - if ( !is_dir($this->value) ) |
|
1561 | + if ( ! is_dir($this->value)) |
|
1562 | 1562 | { |
1563 | 1563 | $message = sprintf( |
1564 | 1564 | $message ?: 'Path "%s" was expected to be a directory.', |
@@ -1579,12 +1579,12 @@ discard block |
||
1579 | 1579 | */ |
1580 | 1580 | public function readable($message = null, $propertyPath = null) |
1581 | 1581 | { |
1582 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1582 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1583 | 1583 | { |
1584 | 1584 | return $this; |
1585 | 1585 | } |
1586 | 1586 | $this->string($message, $propertyPath); |
1587 | - if ( !is_readable($this->value) ) |
|
1587 | + if ( ! is_readable($this->value)) |
|
1588 | 1588 | { |
1589 | 1589 | $message = sprintf( |
1590 | 1590 | $message ?: 'Path "%s" was expected to be readable.', |
@@ -1605,12 +1605,12 @@ discard block |
||
1605 | 1605 | */ |
1606 | 1606 | public function writeable($message = null, $propertyPath = null) |
1607 | 1607 | { |
1608 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1608 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1609 | 1609 | { |
1610 | 1610 | return $this; |
1611 | 1611 | } |
1612 | 1612 | $this->string($message, $propertyPath); |
1613 | - if ( !is_writeable($this->value) ) |
|
1613 | + if ( ! is_writeable($this->value)) |
|
1614 | 1614 | { |
1615 | 1615 | $message = sprintf( |
1616 | 1616 | $message ?: 'Path "%s" was expected to be writeable.', |
@@ -1632,12 +1632,12 @@ discard block |
||
1632 | 1632 | */ |
1633 | 1633 | public function email($message = null, $propertyPath = null) |
1634 | 1634 | { |
1635 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1635 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1636 | 1636 | { |
1637 | 1637 | return $this; |
1638 | 1638 | } |
1639 | 1639 | $this->string($message, $propertyPath); |
1640 | - if ( ! filter_var($this->value, FILTER_VALIDATE_EMAIL) ) |
|
1640 | + if ( ! filter_var($this->value, FILTER_VALIDATE_EMAIL)) |
|
1641 | 1641 | { |
1642 | 1642 | $message = sprintf( |
1643 | 1643 | $message ?: 'Value "%s" was expected to be a valid e-mail address.', |
@@ -1649,7 +1649,7 @@ discard block |
||
1649 | 1649 | { |
1650 | 1650 | $host = substr($this->value, strpos($this->value, '@') + 1); |
1651 | 1651 | // Likely not a FQDN, bug in PHP FILTER_VALIDATE_EMAIL prior to PHP 5.3.3 |
1652 | - if ( version_compare(PHP_VERSION, '5.3.3', '<') && strpos($host, '.') === false ) |
|
1652 | + if (version_compare(PHP_VERSION, '5.3.3', '<') && strpos($host, '.') === false) |
|
1653 | 1653 | { |
1654 | 1654 | $message = sprintf( |
1655 | 1655 | $message ?: 'Value "%s" was expected to be a valid e-mail address.', |
@@ -1663,7 +1663,7 @@ discard block |
||
1663 | 1663 | |
1664 | 1664 | public function emailPrefix($message = null, $propertyPath = null) |
1665 | 1665 | { |
1666 | - $this->value($this->value . '@example.com'); |
|
1666 | + $this->value($this->value.'@example.com'); |
|
1667 | 1667 | return $this->email($message, $propertyPath); |
1668 | 1668 | } |
1669 | 1669 | |
@@ -1683,12 +1683,12 @@ discard block |
||
1683 | 1683 | */ |
1684 | 1684 | public function url($message = null, $propertyPath = null) |
1685 | 1685 | { |
1686 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1686 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1687 | 1687 | { |
1688 | 1688 | return $this; |
1689 | 1689 | } |
1690 | 1690 | $this->string($message, $propertyPath); |
1691 | - $protocols = ['http', 'https']; |
|
1691 | + $protocols = [ 'http', 'https' ]; |
|
1692 | 1692 | $pattern = '~^ |
1693 | 1693 | (%s):// # protocol |
1694 | 1694 | ( |
@@ -1703,8 +1703,8 @@ discard block |
||
1703 | 1703 | (:[0-9]+)? # a port (optional) |
1704 | 1704 | (/?|/\S+) # a /, nothing or a / with something |
1705 | 1705 | $~ixu'; |
1706 | - $pattern = sprintf($pattern, implode('|', $protocols)); |
|
1707 | - if ( !preg_match($pattern, $this->value) ) |
|
1706 | + $pattern = sprintf($pattern, implode('|', $protocols)); |
|
1707 | + if ( ! preg_match($pattern, $this->value)) |
|
1708 | 1708 | { |
1709 | 1709 | $message = sprintf( |
1710 | 1710 | $message ?: 'Value "%s" was expected to be a valid URL starting with http or https', |
@@ -1728,13 +1728,13 @@ discard block |
||
1728 | 1728 | */ |
1729 | 1729 | public function domainName($message = null, $propertyPath = null) |
1730 | 1730 | { |
1731 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1731 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1732 | 1732 | { |
1733 | 1733 | return $this; |
1734 | 1734 | } |
1735 | 1735 | $this->string($message, $propertyPath); |
1736 | - $pattern = '/^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}$/'; |
|
1737 | - if ( ! preg_match($pattern, $this->value) ) |
|
1736 | + $pattern = '/^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}$/'; |
|
1737 | + if ( ! preg_match($pattern, $this->value)) |
|
1738 | 1738 | { |
1739 | 1739 | $message = sprintf( |
1740 | 1740 | $message ?: 'Value "%s" was expected to be a valid domain name', |
@@ -1755,7 +1755,7 @@ discard block |
||
1755 | 1755 | */ |
1756 | 1756 | public function alnum($message = null, $propertyPath = null) |
1757 | 1757 | { |
1758 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1758 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1759 | 1759 | { |
1760 | 1760 | return $this; |
1761 | 1761 | } |
@@ -1785,11 +1785,11 @@ discard block |
||
1785 | 1785 | */ |
1786 | 1786 | public function true($message = null, $propertyPath = null) |
1787 | 1787 | { |
1788 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1788 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1789 | 1789 | { |
1790 | 1790 | return $this; |
1791 | 1791 | } |
1792 | - if ( $this->value !== true ) |
|
1792 | + if ($this->value !== true) |
|
1793 | 1793 | { |
1794 | 1794 | $message = sprintf( |
1795 | 1795 | $message ?: 'Value "%s" is not TRUE.', |
@@ -1810,11 +1810,11 @@ discard block |
||
1810 | 1810 | */ |
1811 | 1811 | public function truthy($message = null, $propertyPath = null) |
1812 | 1812 | { |
1813 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1813 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1814 | 1814 | { |
1815 | 1815 | return $this; |
1816 | 1816 | } |
1817 | - if ( ! $this->value ) |
|
1817 | + if ( ! $this->value) |
|
1818 | 1818 | { |
1819 | 1819 | $message = sprintf( |
1820 | 1820 | $message ?: 'Value "%s" is not truthy.', |
@@ -1835,11 +1835,11 @@ discard block |
||
1835 | 1835 | */ |
1836 | 1836 | public function false($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 | - if ( $this->value !== false ) |
|
1842 | + if ($this->value !== false) |
|
1843 | 1843 | { |
1844 | 1844 | $message = sprintf( |
1845 | 1845 | $message ?: 'Value "%s" is not FALSE.', |
@@ -1860,11 +1860,11 @@ discard block |
||
1860 | 1860 | */ |
1861 | 1861 | public function notFalse($message = null, $propertyPath = null) |
1862 | 1862 | { |
1863 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1863 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1864 | 1864 | { |
1865 | 1865 | return $this; |
1866 | 1866 | } |
1867 | - if ( $this->value === false ) |
|
1867 | + if ($this->value === false) |
|
1868 | 1868 | { |
1869 | 1869 | $message = sprintf( |
1870 | 1870 | $message ?: 'Value "%s" is not FALSE.', |
@@ -1885,11 +1885,11 @@ discard block |
||
1885 | 1885 | */ |
1886 | 1886 | public function classExists($message = null, $propertyPath = null) |
1887 | 1887 | { |
1888 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1888 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1889 | 1889 | { |
1890 | 1890 | return $this; |
1891 | 1891 | } |
1892 | - if ( !class_exists($this->value) ) |
|
1892 | + if ( ! class_exists($this->value)) |
|
1893 | 1893 | { |
1894 | 1894 | $message = sprintf( |
1895 | 1895 | $message ?: 'Class "%s" does not exist.', |
@@ -1911,19 +1911,19 @@ discard block |
||
1911 | 1911 | */ |
1912 | 1912 | public function implementsInterface($interfaceName, $message = null, $propertyPath = null) |
1913 | 1913 | { |
1914 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1914 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1915 | 1915 | { |
1916 | 1916 | return $this; |
1917 | 1917 | } |
1918 | 1918 | $reflection = new \ReflectionClass($this->value); |
1919 | - if ( !$reflection->implementsInterface($interfaceName) ) |
|
1919 | + if ( ! $reflection->implementsInterface($interfaceName)) |
|
1920 | 1920 | { |
1921 | 1921 | $message = sprintf( |
1922 | 1922 | $message ?: 'Class "%s" does not implement interface "%s".', |
1923 | 1923 | $this->stringify($this->value), |
1924 | 1924 | $this->stringify($interfaceName) |
1925 | 1925 | ); |
1926 | - throw $this->createException($message, self::INTERFACE_NOT_IMPLEMENTED, $propertyPath, ['interface' => $interfaceName]); |
|
1926 | + throw $this->createException($message, self::INTERFACE_NOT_IMPLEMENTED, $propertyPath, [ 'interface' => $interfaceName ]); |
|
1927 | 1927 | } |
1928 | 1928 | return $this; |
1929 | 1929 | } |
@@ -1944,11 +1944,11 @@ discard block |
||
1944 | 1944 | */ |
1945 | 1945 | public function isJsonString($message = null, $propertyPath = null) |
1946 | 1946 | { |
1947 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1947 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1948 | 1948 | { |
1949 | 1949 | return $this; |
1950 | 1950 | } |
1951 | - if ( null === json_decode($this->value) && JSON_ERROR_NONE !== json_last_error() ) |
|
1951 | + if (null === json_decode($this->value) && JSON_ERROR_NONE !== json_last_error()) |
|
1952 | 1952 | { |
1953 | 1953 | $message = sprintf( |
1954 | 1954 | $message ?: 'Value "%s" is not a valid JSON string.', |
@@ -1971,16 +1971,16 @@ discard block |
||
1971 | 1971 | */ |
1972 | 1972 | public function uuid($message = null, $propertyPath = null) |
1973 | 1973 | { |
1974 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1974 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1975 | 1975 | { |
1976 | 1976 | return $this; |
1977 | 1977 | } |
1978 | - $this->value = str_replace(['urn:', 'uuid:', '{', '}'], '', $this->value); |
|
1979 | - if ( $this->value === '00000000-0000-0000-0000-000000000000' ) |
|
1978 | + $this->value = str_replace([ 'urn:', 'uuid:', '{', '}' ], '', $this->value); |
|
1979 | + if ($this->value === '00000000-0000-0000-0000-000000000000') |
|
1980 | 1980 | { |
1981 | 1981 | return $this; |
1982 | 1982 | } |
1983 | - 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) ) |
|
1983 | + 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)) |
|
1984 | 1984 | { |
1985 | 1985 | $message = sprintf( |
1986 | 1986 | $message ?: 'Value "%s" is not a valid UUID.', |
@@ -2002,34 +2002,34 @@ discard block |
||
2002 | 2002 | */ |
2003 | 2003 | public function count($count, $message = null, $propertyPath = null) |
2004 | 2004 | { |
2005 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
2005 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
2006 | 2006 | { |
2007 | 2007 | return $this; |
2008 | 2008 | } |
2009 | - if ( $count !== count($this->value) ) |
|
2009 | + if ($count !== count($this->value)) |
|
2010 | 2010 | { |
2011 | 2011 | $message = sprintf( |
2012 | 2012 | $message ?: 'List does not contain exactly "%d" elements.', |
2013 | 2013 | $this->stringify($this->value), |
2014 | 2014 | $this->stringify($count) |
2015 | 2015 | ); |
2016 | - throw $this->createException($message, self::INVALID_COUNT, $propertyPath, ['count' => $count]); |
|
2016 | + throw $this->createException($message, self::INVALID_COUNT, $propertyPath, [ 'count' => $count ]); |
|
2017 | 2017 | } |
2018 | 2018 | return $this; |
2019 | 2019 | } |
2020 | 2020 | |
2021 | 2021 | protected function doAllOrNullOr($func, $args) |
2022 | 2022 | { |
2023 | - if ( $this->nullOr && is_null($this->value) ) |
|
2023 | + if ($this->nullOr && is_null($this->value)) |
|
2024 | 2024 | { |
2025 | 2025 | return true; |
2026 | 2026 | } |
2027 | - if ( $this->all && Assert($this->value)->isTraversable() ) |
|
2027 | + if ($this->all && Assert($this->value)->isTraversable()) |
|
2028 | 2028 | { |
2029 | - foreach ( $this->value as $idx => $value ) |
|
2029 | + foreach ($this->value as $idx => $value) |
|
2030 | 2030 | { |
2031 | 2031 | $object = Assert($value); |
2032 | - call_user_func_array([$object, $func], $args); |
|
2032 | + call_user_func_array([ $object, $func ], $args); |
|
2033 | 2033 | } |
2034 | 2034 | return true; |
2035 | 2035 | } |
@@ -2046,12 +2046,12 @@ discard block |
||
2046 | 2046 | */ |
2047 | 2047 | public function choicesNotEmpty(array $choices, $message = null, $propertyPath = null) |
2048 | 2048 | { |
2049 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
2049 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
2050 | 2050 | { |
2051 | 2051 | return $this; |
2052 | 2052 | } |
2053 | 2053 | $this->notEmpty($message, $propertyPath); |
2054 | - foreach ( $choices as $choice ) |
|
2054 | + foreach ($choices as $choice) |
|
2055 | 2055 | { |
2056 | 2056 | $this->notEmptyKey($choice, $message, $propertyPath); |
2057 | 2057 | } |
@@ -2069,12 +2069,12 @@ discard block |
||
2069 | 2069 | */ |
2070 | 2070 | public function methodExists($object, $message = null, $propertyPath = null) |
2071 | 2071 | { |
2072 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
2072 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
2073 | 2073 | { |
2074 | 2074 | return $this; |
2075 | 2075 | } |
2076 | 2076 | Assert($object)->isObject($message, $propertyPath); |
2077 | - if ( !method_exists($object, $this->value) ) |
|
2077 | + if ( ! method_exists($object, $this->value)) |
|
2078 | 2078 | { |
2079 | 2079 | $message = sprintf( |
2080 | 2080 | $message ?: 'Expected "%s" does not a exist in provided object.', |
@@ -2094,11 +2094,11 @@ discard block |
||
2094 | 2094 | */ |
2095 | 2095 | public function isObject($message = null, $propertyPath = null) |
2096 | 2096 | { |
2097 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
2097 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
2098 | 2098 | { |
2099 | 2099 | return $this; |
2100 | 2100 | } |
2101 | - if ( !is_object($this->value) ) |
|
2101 | + if ( ! is_object($this->value)) |
|
2102 | 2102 | { |
2103 | 2103 | $message = sprintf( |
2104 | 2104 | $message ?: 'Provided "%s" is not a valid object.', |
@@ -2117,32 +2117,32 @@ discard block |
||
2117 | 2117 | */ |
2118 | 2118 | private function stringify($value) |
2119 | 2119 | { |
2120 | - if ( is_bool($value) ) |
|
2120 | + if (is_bool($value)) |
|
2121 | 2121 | { |
2122 | 2122 | return $value ? '<TRUE>' : '<FALSE>'; |
2123 | 2123 | } |
2124 | - if ( is_scalar($value) ) |
|
2124 | + if (is_scalar($value)) |
|
2125 | 2125 | { |
2126 | 2126 | $val = (string)$value; |
2127 | - if ( strlen($val) > 100 ) |
|
2127 | + if (strlen($val) > 100) |
|
2128 | 2128 | { |
2129 | - $val = substr($val, 0, 97) . '...'; |
|
2129 | + $val = substr($val, 0, 97).'...'; |
|
2130 | 2130 | } |
2131 | 2131 | return $val; |
2132 | 2132 | } |
2133 | - if ( is_array($value) ) |
|
2133 | + if (is_array($value)) |
|
2134 | 2134 | { |
2135 | 2135 | return '<ARRAY>'; |
2136 | 2136 | } |
2137 | - if ( is_object($value) ) |
|
2137 | + if (is_object($value)) |
|
2138 | 2138 | { |
2139 | 2139 | return get_class($value); |
2140 | 2140 | } |
2141 | - if ( is_resource($value) ) |
|
2141 | + if (is_resource($value)) |
|
2142 | 2142 | { |
2143 | 2143 | return '<RESOURCE>'; |
2144 | 2144 | } |
2145 | - if ( $value === null ) |
|
2145 | + if ($value === null) |
|
2146 | 2146 | { |
2147 | 2147 | return '<NULL>'; |
2148 | 2148 | } |