@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * @param array $constraints |
176 | 176 | * @return AssertionFailedException |
177 | 177 | */ |
178 | - protected function createException($message, $code, $propertyPath, array $constraints = []) |
|
178 | + protected function createException($message, $code, $propertyPath, array $constraints = [ ]) |
|
179 | 179 | { |
180 | 180 | $exceptionClass = $this->exceptionClass; |
181 | 181 | $propertyPath = is_null($propertyPath) ? $this->propertyPath : $propertyPath; |
@@ -213,18 +213,18 @@ discard block |
||
213 | 213 | */ |
214 | 214 | public function eq($value2, $message = null, $propertyPath = null) |
215 | 215 | { |
216 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
216 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
217 | 217 | { |
218 | 218 | return $this; |
219 | 219 | } |
220 | - if ( $this->value != $value2 ) |
|
220 | + if ($this->value != $value2) |
|
221 | 221 | { |
222 | 222 | $message = sprintf( |
223 | 223 | $message ?: 'Value "%s" does not equal expected value "%s".', |
224 | 224 | $this->stringify($this->value), |
225 | 225 | $this->stringify($value2) |
226 | 226 | ); |
227 | - throw $this->createException($message, self::INVALID_EQ, $propertyPath, ['expected' => $value2]); |
|
227 | + throw $this->createException($message, self::INVALID_EQ, $propertyPath, [ 'expected' => $value2 ]); |
|
228 | 228 | } |
229 | 229 | return $this; |
230 | 230 | } |
@@ -239,18 +239,18 @@ discard block |
||
239 | 239 | */ |
240 | 240 | public function greaterThan($value2, $message = null, $propertyPath = null) |
241 | 241 | { |
242 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
242 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
243 | 243 | { |
244 | 244 | return $this; |
245 | 245 | } |
246 | - if ( ! ( $this->value > $value2 ) ) |
|
246 | + if ( ! ($this->value > $value2)) |
|
247 | 247 | { |
248 | 248 | $message = sprintf( |
249 | 249 | $message ?: 'Value "%s" does not greater then expected value "%s".', |
250 | 250 | $this->stringify($this->value), |
251 | 251 | $this->stringify($value2) |
252 | 252 | ); |
253 | - throw $this->createException($message, self::INVALID_EQ, $propertyPath, ['expected' => $value2]); |
|
253 | + throw $this->createException($message, self::INVALID_EQ, $propertyPath, [ 'expected' => $value2 ]); |
|
254 | 254 | } |
255 | 255 | return $this; |
256 | 256 | } |
@@ -265,18 +265,18 @@ discard block |
||
265 | 265 | */ |
266 | 266 | public function greaterThanOrEq($value2, $message = null, $propertyPath = null) |
267 | 267 | { |
268 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
268 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
269 | 269 | { |
270 | 270 | return $this; |
271 | 271 | } |
272 | - if ( ! ( $this->value >= $value2 ) ) |
|
272 | + if ( ! ($this->value >= $value2)) |
|
273 | 273 | { |
274 | 274 | $message = sprintf( |
275 | 275 | $message ?: 'Value "%s" does not greater than or equal to expected value "%s".', |
276 | 276 | $this->stringify($this->value), |
277 | 277 | $this->stringify($value2) |
278 | 278 | ); |
279 | - throw $this->createException($message, self::INVALID_EQ, $propertyPath, ['expected' => $value2]); |
|
279 | + throw $this->createException($message, self::INVALID_EQ, $propertyPath, [ 'expected' => $value2 ]); |
|
280 | 280 | } |
281 | 281 | return $this; |
282 | 282 | } |
@@ -291,18 +291,18 @@ discard block |
||
291 | 291 | */ |
292 | 292 | public function lessThan($value2, $message = null, $propertyPath = null) |
293 | 293 | { |
294 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
294 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
295 | 295 | { |
296 | 296 | return $this; |
297 | 297 | } |
298 | - if ( ! ( $this->value < $value2 ) ) |
|
298 | + if ( ! ($this->value < $value2)) |
|
299 | 299 | { |
300 | 300 | $message = sprintf( |
301 | 301 | $message ?: 'Value "%s" does not less then expected value "%s".', |
302 | 302 | $this->stringify($this->value), |
303 | 303 | $this->stringify($value2) |
304 | 304 | ); |
305 | - throw $this->createException($message, self::INVALID_LESS_THAN, $propertyPath, ['expected' => $value2]); |
|
305 | + throw $this->createException($message, self::INVALID_LESS_THAN, $propertyPath, [ 'expected' => $value2 ]); |
|
306 | 306 | } |
307 | 307 | return $this; |
308 | 308 | } |
@@ -317,18 +317,18 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public function lessThanOrEq($value2, $message = null, $propertyPath = null) |
319 | 319 | { |
320 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
320 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
321 | 321 | { |
322 | 322 | return $this; |
323 | 323 | } |
324 | - if ( ! ( $this->value <= $value2 ) ) |
|
324 | + if ( ! ($this->value <= $value2)) |
|
325 | 325 | { |
326 | 326 | $message = sprintf( |
327 | 327 | $message ?: 'Value "%s" does not less than or equal to expected value "%s".', |
328 | 328 | $this->stringify($this->value), |
329 | 329 | $this->stringify($value2) |
330 | 330 | ); |
331 | - throw $this->createException($message, self::INVALID_LESS_THAN_OR_EQ, $propertyPath, ['expected' => $value2]); |
|
331 | + throw $this->createException($message, self::INVALID_LESS_THAN_OR_EQ, $propertyPath, [ 'expected' => $value2 ]); |
|
332 | 332 | } |
333 | 333 | return $this; |
334 | 334 | } |
@@ -344,18 +344,18 @@ discard block |
||
344 | 344 | */ |
345 | 345 | public function same($value2, $message = null, $propertyPath = null) |
346 | 346 | { |
347 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
347 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
348 | 348 | { |
349 | 349 | return $this; |
350 | 350 | } |
351 | - if ( $this->value !== $value2 ) |
|
351 | + if ($this->value !== $value2) |
|
352 | 352 | { |
353 | 353 | $message = sprintf( |
354 | 354 | $message ?: 'Value "%s" is not the same as expected value "%s".', |
355 | 355 | $this->stringify($this->value), |
356 | 356 | $this->stringify($value2) |
357 | 357 | ); |
358 | - throw $this->createException($message, self::INVALID_SAME, $propertyPath, ['expected' => $value2]); |
|
358 | + throw $this->createException($message, self::INVALID_SAME, $propertyPath, [ 'expected' => $value2 ]); |
|
359 | 359 | } |
360 | 360 | return $this; |
361 | 361 | } |
@@ -371,18 +371,18 @@ discard block |
||
371 | 371 | */ |
372 | 372 | public function notEq($value2, $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 ( $this->value == $value2 ) |
|
378 | + if ($this->value == $value2) |
|
379 | 379 | { |
380 | 380 | $message = sprintf( |
381 | 381 | $message ?: 'Value "%s" is equal to expected value "%s".', |
382 | 382 | $this->stringify($this->value), |
383 | 383 | $this->stringify($value2) |
384 | 384 | ); |
385 | - throw $this->createException($message, self::INVALID_NOT_EQ, $propertyPath, ['expected' => $value2]); |
|
385 | + throw $this->createException($message, self::INVALID_NOT_EQ, $propertyPath, [ 'expected' => $value2 ]); |
|
386 | 386 | } |
387 | 387 | return $this; |
388 | 388 | } |
@@ -396,11 +396,11 @@ discard block |
||
396 | 396 | */ |
397 | 397 | public function isCallable($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_callable($this->value) ) |
|
403 | + if ( ! is_callable($this->value)) |
|
404 | 404 | { |
405 | 405 | $message = sprintf( |
406 | 406 | $message ?: 'Value "%s" is not callable.', |
@@ -422,18 +422,18 @@ discard block |
||
422 | 422 | */ |
423 | 423 | public function notSame($value2, $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 ( $this->value === $value2 ) |
|
429 | + if ($this->value === $value2) |
|
430 | 430 | { |
431 | 431 | $message = sprintf( |
432 | 432 | $message ?: 'Value "%s" is the same as expected value "%s".', |
433 | 433 | $this->stringify($this->value), |
434 | 434 | $this->stringify($value2) |
435 | 435 | ); |
436 | - throw $this->createException($message, self::INVALID_NOT_SAME, $propertyPath, ['expected' => $value2]); |
|
436 | + throw $this->createException($message, self::INVALID_NOT_SAME, $propertyPath, [ 'expected' => $value2 ]); |
|
437 | 437 | } |
438 | 438 | return $this; |
439 | 439 | } |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | public function status($message = null, $propertyPath = null) |
472 | 472 | { |
473 | 473 | $message = $message ?: 'Value "%s" is not a valid status.'; |
474 | - return $this->integer($message, $propertyPath)->inArray([-1, 0, 1]); |
|
474 | + return $this->integer($message, $propertyPath)->inArray([-1, 0, 1 ]); |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | /** |
@@ -515,11 +515,11 @@ discard block |
||
515 | 515 | */ |
516 | 516 | public function integer($message = null, $propertyPath = null) |
517 | 517 | { |
518 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
518 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
519 | 519 | { |
520 | 520 | return $this; |
521 | 521 | } |
522 | - if ( !is_int($this->value) ) |
|
522 | + if ( ! is_int($this->value)) |
|
523 | 523 | { |
524 | 524 | $message = sprintf( |
525 | 525 | $message ?: 'Value "%s" is not an integer.', |
@@ -540,11 +540,11 @@ discard block |
||
540 | 540 | */ |
541 | 541 | public function float($message = null, $propertyPath = null) |
542 | 542 | { |
543 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
543 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
544 | 544 | { |
545 | 545 | return $this; |
546 | 546 | } |
547 | - if ( !is_float($this->value) ) |
|
547 | + if ( ! is_float($this->value)) |
|
548 | 548 | { |
549 | 549 | $message = sprintf( |
550 | 550 | $message ?: 'Value "%s" is not a float.', |
@@ -565,11 +565,11 @@ discard block |
||
565 | 565 | */ |
566 | 566 | public function digit($message = null, $propertyPath = null) |
567 | 567 | { |
568 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
568 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
569 | 569 | { |
570 | 570 | return $this; |
571 | 571 | } |
572 | - if ( !ctype_digit((string)$this->value) ) |
|
572 | + if ( ! ctype_digit((string)$this->value)) |
|
573 | 573 | { |
574 | 574 | $message = sprintf( |
575 | 575 | $message ?: 'Value "%s" is not a digit.', |
@@ -590,12 +590,12 @@ discard block |
||
590 | 590 | */ |
591 | 591 | public function date($message = null, $propertyPath = null) |
592 | 592 | { |
593 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
593 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
594 | 594 | { |
595 | 595 | return $this; |
596 | 596 | } |
597 | 597 | $this->notEmpty($message, $propertyPath); |
598 | - if ( strtotime($this->value) === false ) |
|
598 | + if (strtotime($this->value) === false) |
|
599 | 599 | { |
600 | 600 | $message = sprintf( |
601 | 601 | $message ?: 'Value "%s" is not a date.', |
@@ -616,11 +616,11 @@ discard block |
||
616 | 616 | */ |
617 | 617 | public function integerish($message = null, $propertyPath = null) |
618 | 618 | { |
619 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
619 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
620 | 620 | { |
621 | 621 | return $this; |
622 | 622 | } |
623 | - if ( is_object($this->value) || strval(intval($this->value)) != $this->value || is_bool($this->value) || is_null($this->value) ) |
|
623 | + if (is_object($this->value) || strval(intval($this->value)) != $this->value || is_bool($this->value) || is_null($this->value)) |
|
624 | 624 | { |
625 | 625 | $message = sprintf( |
626 | 626 | $message ?: 'Value "%s" is not an integer or a number castable to integer.', |
@@ -641,11 +641,11 @@ discard block |
||
641 | 641 | */ |
642 | 642 | public function boolean($message = null, $propertyPath = null) |
643 | 643 | { |
644 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
644 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
645 | 645 | { |
646 | 646 | return $this; |
647 | 647 | } |
648 | - if ( !is_bool($this->value) ) |
|
648 | + if ( ! is_bool($this->value)) |
|
649 | 649 | { |
650 | 650 | $message = sprintf( |
651 | 651 | $message ?: 'Value "%s" is not a boolean.', |
@@ -666,11 +666,11 @@ discard block |
||
666 | 666 | */ |
667 | 667 | public function scalar($message = null, $propertyPath = null) |
668 | 668 | { |
669 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
669 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
670 | 670 | { |
671 | 671 | return $this; |
672 | 672 | } |
673 | - if ( !is_scalar($this->value) ) |
|
673 | + if ( ! is_scalar($this->value)) |
|
674 | 674 | { |
675 | 675 | $message = sprintf( |
676 | 676 | $message ?: 'Value "%s" is not a scalar.', |
@@ -691,11 +691,11 @@ discard block |
||
691 | 691 | */ |
692 | 692 | public function notEmpty($message = null, $propertyPath = null) |
693 | 693 | { |
694 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
694 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
695 | 695 | { |
696 | 696 | return $this; |
697 | 697 | } |
698 | - if ( ( is_object($this->value) && empty((array)$this->value) ) || empty($this->value) ) |
|
698 | + if ((is_object($this->value) && empty((array)$this->value)) || empty($this->value)) |
|
699 | 699 | { |
700 | 700 | $message = sprintf( |
701 | 701 | $message ?: 'Value "%s" is empty, but non empty value was expected.', |
@@ -716,11 +716,11 @@ discard block |
||
716 | 716 | */ |
717 | 717 | public function noContent($message = null, $propertyPath = null) |
718 | 718 | { |
719 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
719 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
720 | 720 | { |
721 | 721 | return $this; |
722 | 722 | } |
723 | - if ( !empty( $this->value ) ) |
|
723 | + if ( ! empty($this->value)) |
|
724 | 724 | { |
725 | 725 | $message = sprintf( |
726 | 726 | $message ?: 'Value "%s" is not empty, but empty value was expected.', |
@@ -741,11 +741,11 @@ discard block |
||
741 | 741 | */ |
742 | 742 | public function notNull($message = null, $propertyPath = null) |
743 | 743 | { |
744 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
744 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
745 | 745 | { |
746 | 746 | return $this; |
747 | 747 | } |
748 | - if ( $this->value === null ) |
|
748 | + if ($this->value === null) |
|
749 | 749 | { |
750 | 750 | $message = sprintf( |
751 | 751 | $message ?: 'Value "%s" is null, but non null value was expected.', |
@@ -766,11 +766,11 @@ discard block |
||
766 | 766 | */ |
767 | 767 | public function string($message = null, $propertyPath = null) |
768 | 768 | { |
769 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
769 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
770 | 770 | { |
771 | 771 | return $this; |
772 | 772 | } |
773 | - if ( !is_string($this->value) ) |
|
773 | + if ( ! is_string($this->value)) |
|
774 | 774 | { |
775 | 775 | $message = sprintf( |
776 | 776 | $message ?: 'Value "%s" expected to be string, type %s given.', |
@@ -793,18 +793,18 @@ discard block |
||
793 | 793 | */ |
794 | 794 | public function regex($pattern, $message = null, $propertyPath = null) |
795 | 795 | { |
796 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
796 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
797 | 797 | { |
798 | 798 | return $this; |
799 | 799 | } |
800 | 800 | $this->string($message, $propertyPath); |
801 | - if ( !preg_match($pattern, $this->value) ) |
|
801 | + if ( ! preg_match($pattern, $this->value)) |
|
802 | 802 | { |
803 | 803 | $message = sprintf( |
804 | 804 | $message ?: 'Value "%s" does not match expression.', |
805 | 805 | $this->stringify($this->value) |
806 | 806 | ); |
807 | - throw $this->createException($message, self::INVALID_REGEX, $propertyPath, ['pattern' => $pattern]); |
|
807 | + throw $this->createException($message, self::INVALID_REGEX, $propertyPath, [ 'pattern' => $pattern ]); |
|
808 | 808 | } |
809 | 809 | return $this; |
810 | 810 | } |
@@ -818,18 +818,18 @@ discard block |
||
818 | 818 | */ |
819 | 819 | public function notRegex($pattern, $message = null, $propertyPath = null) |
820 | 820 | { |
821 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
821 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
822 | 822 | { |
823 | 823 | return $this; |
824 | 824 | } |
825 | 825 | $this->string($message, $propertyPath); |
826 | - if ( preg_match($pattern, $this->value) ) |
|
826 | + if (preg_match($pattern, $this->value)) |
|
827 | 827 | { |
828 | 828 | $message = sprintf( |
829 | 829 | $message ?: 'Value "%s" does not match expression.', |
830 | 830 | $this->stringify($this->value) |
831 | 831 | ); |
832 | - throw $this->createException($message, self::INVALID_REGEX, $propertyPath, ['pattern' => $pattern]); |
|
832 | + throw $this->createException($message, self::INVALID_REGEX, $propertyPath, [ 'pattern' => $pattern ]); |
|
833 | 833 | } |
834 | 834 | return $this; |
835 | 835 | } |
@@ -846,20 +846,20 @@ discard block |
||
846 | 846 | */ |
847 | 847 | public function length($length, $message = null, $propertyPath = null, $encoding = 'utf8') |
848 | 848 | { |
849 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
849 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
850 | 850 | { |
851 | 851 | return $this; |
852 | 852 | } |
853 | 853 | $this->string($message, $propertyPath); |
854 | - if ( mb_strlen($this->value, $encoding) !== $length ) |
|
854 | + if (mb_strlen($this->value, $encoding) !== $length) |
|
855 | 855 | { |
856 | - $message = sprintf( |
|
856 | + $message = sprintf( |
|
857 | 857 | $message ?: 'Value "%s" has to be %d exactly characters long, but length is %d.', |
858 | 858 | $this->stringify($this->value), |
859 | 859 | $length, |
860 | 860 | mb_strlen($this->value, $encoding) |
861 | 861 | ); |
862 | - $constraints = ['length' => $length, 'encoding' => $encoding]; |
|
862 | + $constraints = [ 'length' => $length, 'encoding' => $encoding ]; |
|
863 | 863 | throw $this->createException($message, self::INVALID_LENGTH, $propertyPath, $constraints); |
864 | 864 | } |
865 | 865 | return $this; |
@@ -877,21 +877,21 @@ discard block |
||
877 | 877 | */ |
878 | 878 | public function minLength($minLength, $message = null, $propertyPath = null, $encoding = 'utf8') |
879 | 879 | { |
880 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
880 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
881 | 881 | { |
882 | 882 | return $this; |
883 | 883 | } |
884 | 884 | $this->string($message, $propertyPath); |
885 | - if ( mb_strlen($this->value, $encoding) < $minLength ) |
|
885 | + if (mb_strlen($this->value, $encoding) < $minLength) |
|
886 | 886 | { |
887 | - $message = sprintf( |
|
887 | + $message = sprintf( |
|
888 | 888 | $message |
889 | 889 | ?: 'Value "%s" is too short, it should have more than %d characters, but only has %d characters.', |
890 | 890 | $this->stringify($this->value), |
891 | 891 | $minLength, |
892 | 892 | mb_strlen($this->value, $encoding) |
893 | 893 | ); |
894 | - $constraints = ['min_length' => $minLength, 'encoding' => $encoding]; |
|
894 | + $constraints = [ 'min_length' => $minLength, 'encoding' => $encoding ]; |
|
895 | 895 | throw $this->createException($message, self::INVALID_MIN_LENGTH, $propertyPath, $constraints); |
896 | 896 | } |
897 | 897 | return $this; |
@@ -909,20 +909,20 @@ discard block |
||
909 | 909 | */ |
910 | 910 | public function maxLength($maxLength, $message = null, $propertyPath = null, $encoding = 'utf8') |
911 | 911 | { |
912 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
912 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
913 | 913 | { |
914 | 914 | return $this; |
915 | 915 | } |
916 | 916 | $this->string($message, $propertyPath); |
917 | - if ( mb_strlen($this->value, $encoding) > $maxLength ) |
|
917 | + if (mb_strlen($this->value, $encoding) > $maxLength) |
|
918 | 918 | { |
919 | - $message = sprintf( |
|
919 | + $message = sprintf( |
|
920 | 920 | $message ?: 'Value "%s" is too long, it should have no more than %d characters, but has %d characters.', |
921 | 921 | $this->stringify($this->value), |
922 | 922 | $maxLength, |
923 | 923 | mb_strlen($this->value, $encoding) |
924 | 924 | ); |
925 | - $constraints = ['max_length' => $maxLength, 'encoding' => $encoding]; |
|
925 | + $constraints = [ 'max_length' => $maxLength, 'encoding' => $encoding ]; |
|
926 | 926 | throw $this->createException($message, self::INVALID_MAX_LENGTH, $propertyPath, $constraints); |
927 | 927 | } |
928 | 928 | return $this; |
@@ -941,32 +941,32 @@ discard block |
||
941 | 941 | */ |
942 | 942 | public function betweenLength($minLength, $maxLength, $message = null, $propertyPath = null, $encoding = 'utf8') |
943 | 943 | { |
944 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
944 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
945 | 945 | { |
946 | 946 | return $this; |
947 | 947 | } |
948 | 948 | $this->string($message, $propertyPath); |
949 | - if ( mb_strlen($this->value, $encoding) < $minLength ) |
|
949 | + if (mb_strlen($this->value, $encoding) < $minLength) |
|
950 | 950 | { |
951 | - $message = sprintf( |
|
951 | + $message = sprintf( |
|
952 | 952 | $message |
953 | 953 | ?: 'Value "%s" is too short, it should have more than %d characters, but only has %d characters.', |
954 | 954 | $this->stringify($this->value), |
955 | 955 | $minLength, |
956 | 956 | mb_strlen($this->value, $encoding) |
957 | 957 | ); |
958 | - $constraints = ['min_length' => $minLength, 'encoding' => $encoding]; |
|
958 | + $constraints = [ 'min_length' => $minLength, 'encoding' => $encoding ]; |
|
959 | 959 | throw $this->createException($message, self::INVALID_MIN_LENGTH, $propertyPath, $constraints); |
960 | 960 | } |
961 | - if ( mb_strlen($this->value, $encoding) > $maxLength ) |
|
961 | + if (mb_strlen($this->value, $encoding) > $maxLength) |
|
962 | 962 | { |
963 | - $message = sprintf( |
|
963 | + $message = sprintf( |
|
964 | 964 | $message ?: 'Value "%s" is too long, it should have no more than %d characters, but has %d characters.', |
965 | 965 | $this->stringify($this->value), |
966 | 966 | $maxLength, |
967 | 967 | mb_strlen($this->value, $encoding) |
968 | 968 | ); |
969 | - $constraints = ['max_length' => $maxLength, 'encoding' => $encoding]; |
|
969 | + $constraints = [ 'max_length' => $maxLength, 'encoding' => $encoding ]; |
|
970 | 970 | throw $this->createException($message, self::INVALID_MAX_LENGTH, $propertyPath, $constraints); |
971 | 971 | } |
972 | 972 | return $this; |
@@ -984,19 +984,19 @@ discard block |
||
984 | 984 | */ |
985 | 985 | public function startsWith($needle, $message = null, $propertyPath = null, $encoding = 'utf8') |
986 | 986 | { |
987 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
987 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
988 | 988 | { |
989 | 989 | return $this; |
990 | 990 | } |
991 | 991 | $this->string($message, $propertyPath); |
992 | - if ( mb_strpos($this->value, $needle, null, $encoding) !== 0 ) |
|
992 | + if (mb_strpos($this->value, $needle, null, $encoding) !== 0) |
|
993 | 993 | { |
994 | - $message = sprintf( |
|
994 | + $message = sprintf( |
|
995 | 995 | $message ?: 'Value "%s" does not start with "%s".', |
996 | 996 | $this->stringify($this->value), |
997 | 997 | $this->stringify($needle) |
998 | 998 | ); |
999 | - $constraints = ['needle' => $needle, 'encoding' => $encoding]; |
|
999 | + $constraints = [ 'needle' => $needle, 'encoding' => $encoding ]; |
|
1000 | 1000 | throw $this->createException($message, self::INVALID_STRING_START, $propertyPath, $constraints); |
1001 | 1001 | } |
1002 | 1002 | return $this; |
@@ -1014,20 +1014,20 @@ discard block |
||
1014 | 1014 | */ |
1015 | 1015 | public function endsWith($needle, $message = null, $propertyPath = null, $encoding = 'utf8') |
1016 | 1016 | { |
1017 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1017 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1018 | 1018 | { |
1019 | 1019 | return $this; |
1020 | 1020 | } |
1021 | 1021 | $this->string($message, $propertyPath); |
1022 | 1022 | $stringPosition = mb_strlen($this->value, $encoding) - mb_strlen($needle, $encoding); |
1023 | - if ( mb_strripos($this->value, $needle, null, $encoding) !== $stringPosition ) |
|
1023 | + if (mb_strripos($this->value, $needle, null, $encoding) !== $stringPosition) |
|
1024 | 1024 | { |
1025 | - $message = sprintf( |
|
1025 | + $message = sprintf( |
|
1026 | 1026 | $message ?: 'Value "%s" does not end with "%s".', |
1027 | 1027 | $this->stringify($this->value), |
1028 | 1028 | $this->stringify($needle) |
1029 | 1029 | ); |
1030 | - $constraints = ['needle' => $needle, 'encoding' => $encoding]; |
|
1030 | + $constraints = [ 'needle' => $needle, 'encoding' => $encoding ]; |
|
1031 | 1031 | throw $this->createException($message, self::INVALID_STRING_END, $propertyPath, $constraints); |
1032 | 1032 | } |
1033 | 1033 | return $this; |
@@ -1045,19 +1045,19 @@ discard block |
||
1045 | 1045 | */ |
1046 | 1046 | public function contains($needle, $message = null, $propertyPath = null, $encoding = 'utf8') |
1047 | 1047 | { |
1048 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1048 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1049 | 1049 | { |
1050 | 1050 | return $this; |
1051 | 1051 | } |
1052 | 1052 | $this->string($message, $propertyPath); |
1053 | - if ( mb_strpos($this->value, $needle, null, $encoding) === false ) |
|
1053 | + if (mb_strpos($this->value, $needle, null, $encoding) === false) |
|
1054 | 1054 | { |
1055 | - $message = sprintf( |
|
1055 | + $message = sprintf( |
|
1056 | 1056 | $message ?: 'Value "%s" does not contain "%s".', |
1057 | 1057 | $this->stringify($this->value), |
1058 | 1058 | $this->stringify($needle) |
1059 | 1059 | ); |
1060 | - $constraints = ['needle' => $needle, 'encoding' => $encoding]; |
|
1060 | + $constraints = [ 'needle' => $needle, 'encoding' => $encoding ]; |
|
1061 | 1061 | throw $this->createException($message, self::INVALID_STRING_CONTAINS, $propertyPath, $constraints); |
1062 | 1062 | } |
1063 | 1063 | return $this; |
@@ -1074,18 +1074,18 @@ discard block |
||
1074 | 1074 | */ |
1075 | 1075 | public function choice(array $choices, $message = null, $propertyPath = null) |
1076 | 1076 | { |
1077 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1077 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1078 | 1078 | { |
1079 | 1079 | return $this; |
1080 | 1080 | } |
1081 | - if ( !in_array($this->value, $choices, true) ) |
|
1081 | + if ( ! in_array($this->value, $choices, true)) |
|
1082 | 1082 | { |
1083 | 1083 | $message = sprintf( |
1084 | 1084 | $message ?: 'Value "%s" is not an element of the valid values: %s', |
1085 | 1085 | $this->stringify($this->value), |
1086 | 1086 | implode(", ", array_map('Terah\Assert\Assert::stringify', $choices)) |
1087 | 1087 | ); |
1088 | - throw $this->createException($message, self::INVALID_CHOICE, $propertyPath, ['choices' => $choices]); |
|
1088 | + throw $this->createException($message, self::INVALID_CHOICE, $propertyPath, [ 'choices' => $choices ]); |
|
1089 | 1089 | } |
1090 | 1090 | return $this; |
1091 | 1091 | } |
@@ -1102,7 +1102,7 @@ discard block |
||
1102 | 1102 | */ |
1103 | 1103 | public function inArray(array $choices, $message = null, $propertyPath = null) |
1104 | 1104 | { |
1105 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1105 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1106 | 1106 | { |
1107 | 1107 | return $this; |
1108 | 1108 | } |
@@ -1120,11 +1120,11 @@ discard block |
||
1120 | 1120 | */ |
1121 | 1121 | public function numeric($message = null, $propertyPath = null) |
1122 | 1122 | { |
1123 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1123 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1124 | 1124 | { |
1125 | 1125 | return $this; |
1126 | 1126 | } |
1127 | - if ( ! is_numeric($this->value) ) |
|
1127 | + if ( ! is_numeric($this->value)) |
|
1128 | 1128 | { |
1129 | 1129 | $message = sprintf( |
1130 | 1130 | $message ?: 'Value "%s" is not numeric.', |
@@ -1181,11 +1181,11 @@ discard block |
||
1181 | 1181 | */ |
1182 | 1182 | public function isArray($message = null, $propertyPath = null) |
1183 | 1183 | { |
1184 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1184 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1185 | 1185 | { |
1186 | 1186 | return $this; |
1187 | 1187 | } |
1188 | - if ( !is_array($this->value) ) |
|
1188 | + if ( ! is_array($this->value)) |
|
1189 | 1189 | { |
1190 | 1190 | $message = sprintf( |
1191 | 1191 | $message ?: 'Value "%s" is not an array.', |
@@ -1206,11 +1206,11 @@ discard block |
||
1206 | 1206 | */ |
1207 | 1207 | public function isTraversable($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 | - if ( !is_array($this->value) && !$this->value instanceof \Traversable ) |
|
1213 | + if ( ! is_array($this->value) && ! $this->value instanceof \Traversable) |
|
1214 | 1214 | { |
1215 | 1215 | $message = sprintf( |
1216 | 1216 | $message ?: 'Value "%s" is not an array and does not implement Traversable.', |
@@ -1231,11 +1231,11 @@ discard block |
||
1231 | 1231 | */ |
1232 | 1232 | public function isArrayAccessible($message = null, $propertyPath = null) |
1233 | 1233 | { |
1234 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1234 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1235 | 1235 | { |
1236 | 1236 | return $this; |
1237 | 1237 | } |
1238 | - if ( !is_array($this->value) && !$this->value instanceof \ArrayAccess ) |
|
1238 | + if ( ! is_array($this->value) && ! $this->value instanceof \ArrayAccess) |
|
1239 | 1239 | { |
1240 | 1240 | $message = sprintf( |
1241 | 1241 | $message ?: 'Value "%s" is not an array and does not implement ArrayAccess.', |
@@ -1257,18 +1257,18 @@ discard block |
||
1257 | 1257 | */ |
1258 | 1258 | public function keyExists($key, $message = null, $propertyPath = null) |
1259 | 1259 | { |
1260 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1260 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1261 | 1261 | { |
1262 | 1262 | return $this; |
1263 | 1263 | } |
1264 | 1264 | $this->isArray($message, $propertyPath); |
1265 | - if ( !array_key_exists($key, $this->value) ) |
|
1265 | + if ( ! array_key_exists($key, $this->value)) |
|
1266 | 1266 | { |
1267 | 1267 | $message = sprintf( |
1268 | 1268 | $message ?: 'Array does not contain an element with key "%s"', |
1269 | 1269 | $this->stringify($key) |
1270 | 1270 | ); |
1271 | - throw $this->createException($message, self::INVALID_KEY_EXISTS, $propertyPath, ['key' => $key]); |
|
1271 | + throw $this->createException($message, self::INVALID_KEY_EXISTS, $propertyPath, [ 'key' => $key ]); |
|
1272 | 1272 | } |
1273 | 1273 | return $this; |
1274 | 1274 | } |
@@ -1284,21 +1284,21 @@ discard block |
||
1284 | 1284 | */ |
1285 | 1285 | public function keysExist($keys, $message = null, $propertyPath = null) |
1286 | 1286 | { |
1287 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1287 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1288 | 1288 | { |
1289 | 1289 | return $this; |
1290 | 1290 | } |
1291 | 1291 | $this->isArray($message, $propertyPath); |
1292 | - foreach ( $keys as $key ) |
|
1292 | + foreach ($keys as $key) |
|
1293 | 1293 | { |
1294 | - if ( !array_key_exists($key, $this->value) ) |
|
1294 | + if ( ! array_key_exists($key, $this->value)) |
|
1295 | 1295 | { |
1296 | 1296 | $message = $message |
1297 | 1297 | ?: sprintf( |
1298 | 1298 | 'Array does not contain an element with key "%s"', |
1299 | 1299 | $this->stringify($key) |
1300 | 1300 | ); |
1301 | - throw $this->createException($message, self::INVALID_KEYS_EXIST, $propertyPath, ['key' => $key]); |
|
1301 | + throw $this->createException($message, self::INVALID_KEYS_EXIST, $propertyPath, [ 'key' => $key ]); |
|
1302 | 1302 | } |
1303 | 1303 | } |
1304 | 1304 | return $this; |
@@ -1315,19 +1315,19 @@ discard block |
||
1315 | 1315 | */ |
1316 | 1316 | public function propertyExists($key, $message = null, $propertyPath = null) |
1317 | 1317 | { |
1318 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1318 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1319 | 1319 | { |
1320 | 1320 | return $this; |
1321 | 1321 | } |
1322 | 1322 | $this->isObject($message, $propertyPath); |
1323 | - if ( !property_exists($this->value, $key) && !isset( $this->value->{$key} ) ) |
|
1323 | + if ( ! property_exists($this->value, $key) && ! isset($this->value->{$key} )) |
|
1324 | 1324 | { |
1325 | 1325 | $message = $message |
1326 | 1326 | ?: sprintf( |
1327 | 1327 | 'Object does not contain a property with key "%s"', |
1328 | 1328 | $this->stringify($key) |
1329 | 1329 | ); |
1330 | - throw $this->createException($message, self::INVALID_PROPERTY_EXISTS, $propertyPath, ['key' => $key]); |
|
1330 | + throw $this->createException($message, self::INVALID_PROPERTY_EXISTS, $propertyPath, [ 'key' => $key ]); |
|
1331 | 1331 | } |
1332 | 1332 | return $this; |
1333 | 1333 | } |
@@ -1343,22 +1343,22 @@ discard block |
||
1343 | 1343 | */ |
1344 | 1344 | public function propertiesExist(array $keys, $message = null, $propertyPath = null) |
1345 | 1345 | { |
1346 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1346 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1347 | 1347 | { |
1348 | 1348 | return $this; |
1349 | 1349 | } |
1350 | 1350 | $this->isObject($message, $propertyPath); |
1351 | - foreach ( $keys as $key ) |
|
1351 | + foreach ($keys as $key) |
|
1352 | 1352 | { |
1353 | 1353 | // Using isset to allow resolution of magically defined properties |
1354 | - if ( !property_exists($this->value, $key) && !isset( $this->value->{$key} ) ) |
|
1354 | + if ( ! property_exists($this->value, $key) && ! isset($this->value->{$key} )) |
|
1355 | 1355 | { |
1356 | 1356 | $message = $message |
1357 | 1357 | ?: sprintf( |
1358 | 1358 | 'Object does not contain a property with key "%s"', |
1359 | 1359 | $this->stringify($key) |
1360 | 1360 | ); |
1361 | - throw $this->createException($message, self::INVALID_PROPERTIES_EXIST, $propertyPath, ['key' => $key]); |
|
1361 | + throw $this->createException($message, self::INVALID_PROPERTIES_EXIST, $propertyPath, [ 'key' => $key ]); |
|
1362 | 1362 | } |
1363 | 1363 | } |
1364 | 1364 | return $this; |
@@ -1374,12 +1374,12 @@ discard block |
||
1374 | 1374 | */ |
1375 | 1375 | public function utf8($message = null, $propertyPath = null) |
1376 | 1376 | { |
1377 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1377 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1378 | 1378 | { |
1379 | 1379 | return $this; |
1380 | 1380 | } |
1381 | 1381 | $this->string($message, $propertyPath); |
1382 | - if ( mb_detect_encoding($this->value, 'UTF-8', true) !== 'UTF-8' ) |
|
1382 | + if (mb_detect_encoding($this->value, 'UTF-8', true) !== 'UTF-8') |
|
1383 | 1383 | { |
1384 | 1384 | $message = $message |
1385 | 1385 | ?: sprintf( |
@@ -1402,12 +1402,12 @@ discard block |
||
1402 | 1402 | */ |
1403 | 1403 | public function ascii($message = null, $propertyPath = null) |
1404 | 1404 | { |
1405 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1405 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1406 | 1406 | { |
1407 | 1407 | return $this; |
1408 | 1408 | } |
1409 | 1409 | $this->string($message, $propertyPath); |
1410 | - if ( ! preg_match('/^[ -~]+$/', $this->value) ) |
|
1410 | + if ( ! preg_match('/^[ -~]+$/', $this->value)) |
|
1411 | 1411 | { |
1412 | 1412 | $message = $message |
1413 | 1413 | ?: sprintf( |
@@ -1430,18 +1430,18 @@ discard block |
||
1430 | 1430 | */ |
1431 | 1431 | public function keyIsset($key, $message = null, $propertyPath = null) |
1432 | 1432 | { |
1433 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1433 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1434 | 1434 | { |
1435 | 1435 | return $this; |
1436 | 1436 | } |
1437 | 1437 | $this->isArrayAccessible($message, $propertyPath); |
1438 | - if ( !isset( $this->value[$key] ) ) |
|
1438 | + if ( ! isset($this->value[ $key ])) |
|
1439 | 1439 | { |
1440 | 1440 | $message = sprintf( |
1441 | 1441 | $message ?: 'The element with key "%s" was not found', |
1442 | 1442 | $this->stringify($key) |
1443 | 1443 | ); |
1444 | - throw $this->createException($message, self::INVALID_KEY_ISSET, $propertyPath, ['key' => $key]); |
|
1444 | + throw $this->createException($message, self::INVALID_KEY_ISSET, $propertyPath, [ 'key' => $key ]); |
|
1445 | 1445 | } |
1446 | 1446 | return $this; |
1447 | 1447 | } |
@@ -1457,12 +1457,12 @@ discard block |
||
1457 | 1457 | */ |
1458 | 1458 | public function notEmptyKey($key, $message = null, $propertyPath = null) |
1459 | 1459 | { |
1460 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1460 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1461 | 1461 | { |
1462 | 1462 | return $this; |
1463 | 1463 | } |
1464 | 1464 | $this->keyIsset($key, $message, $propertyPath); |
1465 | - (new Assert($this->value[$key]))->setExceptionClass($this->exceptionClass)->notEmpty($message, $propertyPath); |
|
1465 | + (new Assert($this->value[ $key ]))->setExceptionClass($this->exceptionClass)->notEmpty($message, $propertyPath); |
|
1466 | 1466 | return $this; |
1467 | 1467 | } |
1468 | 1468 | |
@@ -1476,11 +1476,11 @@ discard block |
||
1476 | 1476 | */ |
1477 | 1477 | public function notBlank($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 | - if ( false === $this->value || ( empty( $this->value ) && '0' != $this->value ) ) |
|
1483 | + if (false === $this->value || (empty($this->value) && '0' != $this->value)) |
|
1484 | 1484 | { |
1485 | 1485 | $message = sprintf( |
1486 | 1486 | $message ?: 'Value "%s" is blank, but was expected to contain a value.', |
@@ -1502,18 +1502,18 @@ discard block |
||
1502 | 1502 | */ |
1503 | 1503 | public function isInstanceOf($className, $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 | - if ( !( $this->value instanceof $className ) ) |
|
1509 | + if ( ! ($this->value instanceof $className)) |
|
1510 | 1510 | { |
1511 | 1511 | $message = sprintf( |
1512 | 1512 | $message ?: 'Class "%s" was expected to be instanceof of "%s" but is not.', |
1513 | 1513 | $this->stringify($this->value), |
1514 | 1514 | $className |
1515 | 1515 | ); |
1516 | - throw $this->createException($message, self::INVALID_INSTANCE_OF, $propertyPath, ['class' => $className]); |
|
1516 | + throw $this->createException($message, self::INVALID_INSTANCE_OF, $propertyPath, [ 'class' => $className ]); |
|
1517 | 1517 | } |
1518 | 1518 | return $this; |
1519 | 1519 | } |
@@ -1529,18 +1529,18 @@ discard block |
||
1529 | 1529 | */ |
1530 | 1530 | public function notIsInstanceOf($className, $message = null, $propertyPath = null) |
1531 | 1531 | { |
1532 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1532 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1533 | 1533 | { |
1534 | 1534 | return $this; |
1535 | 1535 | } |
1536 | - if ( $this->value instanceof $className ) |
|
1536 | + if ($this->value instanceof $className) |
|
1537 | 1537 | { |
1538 | 1538 | $message = sprintf( |
1539 | 1539 | $message ?: 'Class "%s" was not expected to be instanceof of "%s".', |
1540 | 1540 | $this->stringify($this->value), |
1541 | 1541 | $className |
1542 | 1542 | ); |
1543 | - throw $this->createException($message, self::INVALID_NOT_INSTANCE_OF, $propertyPath, ['class' => $className]); |
|
1543 | + throw $this->createException($message, self::INVALID_NOT_INSTANCE_OF, $propertyPath, [ 'class' => $className ]); |
|
1544 | 1544 | } |
1545 | 1545 | return $this; |
1546 | 1546 | } |
@@ -1556,18 +1556,18 @@ discard block |
||
1556 | 1556 | */ |
1557 | 1557 | public function subclassOf($className, $message = null, $propertyPath = null) |
1558 | 1558 | { |
1559 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1559 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1560 | 1560 | { |
1561 | 1561 | return $this; |
1562 | 1562 | } |
1563 | - if ( !is_subclass_of($this->value, $className) ) |
|
1563 | + if ( ! is_subclass_of($this->value, $className)) |
|
1564 | 1564 | { |
1565 | 1565 | $message = sprintf( |
1566 | 1566 | $message ?: 'Class "%s" was expected to be subclass of "%s".', |
1567 | 1567 | $this->stringify($this->value), |
1568 | 1568 | $className |
1569 | 1569 | ); |
1570 | - throw $this->createException($message, self::INVALID_SUBCLASS_OF, $propertyPath, ['class' => $className]); |
|
1570 | + throw $this->createException($message, self::INVALID_SUBCLASS_OF, $propertyPath, [ 'class' => $className ]); |
|
1571 | 1571 | } |
1572 | 1572 | return $this; |
1573 | 1573 | } |
@@ -1584,12 +1584,12 @@ discard block |
||
1584 | 1584 | */ |
1585 | 1585 | public function range($minValue, $maxValue, $message = null, $propertyPath = null) |
1586 | 1586 | { |
1587 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1587 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1588 | 1588 | { |
1589 | 1589 | return $this; |
1590 | 1590 | } |
1591 | 1591 | $this->numeric($message, $propertyPath); |
1592 | - if ( $this->value < $minValue || $this->value > $maxValue ) |
|
1592 | + if ($this->value < $minValue || $this->value > $maxValue) |
|
1593 | 1593 | { |
1594 | 1594 | $message = sprintf( |
1595 | 1595 | $message ?: 'Number "%s" was expected to be at least "%d" and at most "%d".', |
@@ -1616,19 +1616,19 @@ discard block |
||
1616 | 1616 | */ |
1617 | 1617 | public function min($minValue, $message = null, $propertyPath = null) |
1618 | 1618 | { |
1619 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1619 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1620 | 1620 | { |
1621 | 1621 | return $this; |
1622 | 1622 | } |
1623 | 1623 | $this->numeric($message, $propertyPath); |
1624 | - if ( $this->value < $minValue ) |
|
1624 | + if ($this->value < $minValue) |
|
1625 | 1625 | { |
1626 | 1626 | $message = sprintf( |
1627 | 1627 | $message ?: 'Number "%s" was expected to be at least "%d".', |
1628 | 1628 | $this->stringify($this->value), |
1629 | 1629 | $this->stringify($minValue) |
1630 | 1630 | ); |
1631 | - throw $this->createException($message, self::INVALID_MIN, $propertyPath, ['min' => $minValue]); |
|
1631 | + throw $this->createException($message, self::INVALID_MIN, $propertyPath, [ 'min' => $minValue ]); |
|
1632 | 1632 | } |
1633 | 1633 | return $this; |
1634 | 1634 | } |
@@ -1644,19 +1644,19 @@ discard block |
||
1644 | 1644 | */ |
1645 | 1645 | public function max($maxValue, $message = null, $propertyPath = null) |
1646 | 1646 | { |
1647 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1647 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1648 | 1648 | { |
1649 | 1649 | return $this; |
1650 | 1650 | } |
1651 | 1651 | $this->numeric($message, $propertyPath); |
1652 | - if ( $this->value > $maxValue ) |
|
1652 | + if ($this->value > $maxValue) |
|
1653 | 1653 | { |
1654 | 1654 | $message = sprintf( |
1655 | 1655 | $message ?: 'Number "%s" was expected to be at most "%d".', |
1656 | 1656 | $this->stringify($this->value), |
1657 | 1657 | $this->stringify($maxValue) |
1658 | 1658 | ); |
1659 | - throw $this->createException($message, self::INVALID_MAX, $propertyPath, ['max' => $maxValue]); |
|
1659 | + throw $this->createException($message, self::INVALID_MAX, $propertyPath, [ 'max' => $maxValue ]); |
|
1660 | 1660 | } |
1661 | 1661 | return $this; |
1662 | 1662 | } |
@@ -1671,13 +1671,13 @@ discard block |
||
1671 | 1671 | */ |
1672 | 1672 | public function file($message = null, $propertyPath = null) |
1673 | 1673 | { |
1674 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1674 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1675 | 1675 | { |
1676 | 1676 | return $this; |
1677 | 1677 | } |
1678 | 1678 | $this->string($message, $propertyPath); |
1679 | 1679 | $this->notEmpty($message, $propertyPath); |
1680 | - if ( !is_file($this->value) ) |
|
1680 | + if ( ! is_file($this->value)) |
|
1681 | 1681 | { |
1682 | 1682 | $message = sprintf( |
1683 | 1683 | $message ?: 'File "%s" was expected to exist.', |
@@ -1696,13 +1696,13 @@ discard block |
||
1696 | 1696 | */ |
1697 | 1697 | public function fileExists($message = null, $propertyPath = null) |
1698 | 1698 | { |
1699 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1699 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1700 | 1700 | { |
1701 | 1701 | return $this; |
1702 | 1702 | } |
1703 | 1703 | $this->string($message, $propertyPath); |
1704 | 1704 | $this->notEmpty($message, $propertyPath); |
1705 | - if ( ! file_exists($this->value) ) |
|
1705 | + if ( ! file_exists($this->value)) |
|
1706 | 1706 | { |
1707 | 1707 | $message = sprintf( |
1708 | 1708 | $message ?: 'File or directory "%s" was expected to exist.', |
@@ -1723,12 +1723,12 @@ discard block |
||
1723 | 1723 | */ |
1724 | 1724 | public function directory($message = null, $propertyPath = null) |
1725 | 1725 | { |
1726 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1726 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1727 | 1727 | { |
1728 | 1728 | return $this; |
1729 | 1729 | } |
1730 | 1730 | $this->string($message, $propertyPath); |
1731 | - if ( !is_dir($this->value) ) |
|
1731 | + if ( ! is_dir($this->value)) |
|
1732 | 1732 | { |
1733 | 1733 | $message = sprintf( |
1734 | 1734 | $message ?: 'Path "%s" was expected to be a directory.', |
@@ -1749,12 +1749,12 @@ discard block |
||
1749 | 1749 | */ |
1750 | 1750 | public function readable($message = null, $propertyPath = null) |
1751 | 1751 | { |
1752 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1752 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1753 | 1753 | { |
1754 | 1754 | return $this; |
1755 | 1755 | } |
1756 | 1756 | $this->string($message, $propertyPath); |
1757 | - if ( !is_readable($this->value) ) |
|
1757 | + if ( ! is_readable($this->value)) |
|
1758 | 1758 | { |
1759 | 1759 | $message = sprintf( |
1760 | 1760 | $message ?: 'Path "%s" was expected to be readable.', |
@@ -1775,12 +1775,12 @@ discard block |
||
1775 | 1775 | */ |
1776 | 1776 | public function writeable($message = null, $propertyPath = null) |
1777 | 1777 | { |
1778 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1778 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1779 | 1779 | { |
1780 | 1780 | return $this; |
1781 | 1781 | } |
1782 | 1782 | $this->string($message, $propertyPath); |
1783 | - if ( !is_writeable($this->value) ) |
|
1783 | + if ( ! is_writeable($this->value)) |
|
1784 | 1784 | { |
1785 | 1785 | $message = sprintf( |
1786 | 1786 | $message ?: 'Path "%s" was expected to be writeable.', |
@@ -1802,12 +1802,12 @@ discard block |
||
1802 | 1802 | */ |
1803 | 1803 | public function email($message = null, $propertyPath = null) |
1804 | 1804 | { |
1805 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1805 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1806 | 1806 | { |
1807 | 1807 | return $this; |
1808 | 1808 | } |
1809 | 1809 | $this->string($message, $propertyPath); |
1810 | - if ( ! filter_var($this->value, FILTER_VALIDATE_EMAIL) ) |
|
1810 | + if ( ! filter_var($this->value, FILTER_VALIDATE_EMAIL)) |
|
1811 | 1811 | { |
1812 | 1812 | $message = sprintf( |
1813 | 1813 | $message ?: 'Value "%s" was expected to be a valid e-mail address.', |
@@ -1819,7 +1819,7 @@ discard block |
||
1819 | 1819 | { |
1820 | 1820 | $host = substr($this->value, strpos($this->value, '@') + 1); |
1821 | 1821 | // Likely not a FQDN, bug in PHP FILTER_VALIDATE_EMAIL prior to PHP 5.3.3 |
1822 | - if ( version_compare(PHP_VERSION, '5.3.3', '<') && strpos($host, '.') === false ) |
|
1822 | + if (version_compare(PHP_VERSION, '5.3.3', '<') && strpos($host, '.') === false) |
|
1823 | 1823 | { |
1824 | 1824 | $message = sprintf( |
1825 | 1825 | $message ?: 'Value "%s" was expected to be a valid e-mail address.', |
@@ -1839,7 +1839,7 @@ discard block |
||
1839 | 1839 | */ |
1840 | 1840 | public function emailPrefix($message = null, $propertyPath = null) |
1841 | 1841 | { |
1842 | - $this->value($this->value . '@example.com'); |
|
1842 | + $this->value($this->value.'@example.com'); |
|
1843 | 1843 | return $this->email($message, $propertyPath); |
1844 | 1844 | } |
1845 | 1845 | |
@@ -1859,12 +1859,12 @@ discard block |
||
1859 | 1859 | */ |
1860 | 1860 | public function url($message = null, $propertyPath = null) |
1861 | 1861 | { |
1862 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1862 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1863 | 1863 | { |
1864 | 1864 | return $this; |
1865 | 1865 | } |
1866 | 1866 | $this->string($message, $propertyPath); |
1867 | - $protocols = ['http', 'https']; |
|
1867 | + $protocols = [ 'http', 'https' ]; |
|
1868 | 1868 | $pattern = '~^ |
1869 | 1869 | (%s):// # protocol |
1870 | 1870 | ( |
@@ -1879,8 +1879,8 @@ discard block |
||
1879 | 1879 | (:[0-9]+)? # a port (optional) |
1880 | 1880 | (/?|/\S+) # a /, nothing or a / with something |
1881 | 1881 | $~ixu'; |
1882 | - $pattern = sprintf($pattern, implode('|', $protocols)); |
|
1883 | - if ( !preg_match($pattern, $this->value) ) |
|
1882 | + $pattern = sprintf($pattern, implode('|', $protocols)); |
|
1883 | + if ( ! preg_match($pattern, $this->value)) |
|
1884 | 1884 | { |
1885 | 1885 | $message = sprintf( |
1886 | 1886 | $message ?: 'Value "%s" was expected to be a valid URL starting with http or https', |
@@ -1904,13 +1904,13 @@ discard block |
||
1904 | 1904 | */ |
1905 | 1905 | public function domainName($message = null, $propertyPath = null) |
1906 | 1906 | { |
1907 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1907 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1908 | 1908 | { |
1909 | 1909 | return $this; |
1910 | 1910 | } |
1911 | 1911 | $this->string($message, $propertyPath); |
1912 | - $pattern = '/^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}$/'; |
|
1913 | - if ( ! preg_match($pattern, $this->value) ) |
|
1912 | + $pattern = '/^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}$/'; |
|
1913 | + if ( ! preg_match($pattern, $this->value)) |
|
1914 | 1914 | { |
1915 | 1915 | $message = sprintf( |
1916 | 1916 | $message ?: 'Value "%s" was expected to be a valid domain name', |
@@ -1931,7 +1931,7 @@ discard block |
||
1931 | 1931 | */ |
1932 | 1932 | public function alnum($message = null, $propertyPath = null) |
1933 | 1933 | { |
1934 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1934 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1935 | 1935 | { |
1936 | 1936 | return $this; |
1937 | 1937 | } |
@@ -1961,11 +1961,11 @@ discard block |
||
1961 | 1961 | */ |
1962 | 1962 | public function true($message = null, $propertyPath = null) |
1963 | 1963 | { |
1964 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1964 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1965 | 1965 | { |
1966 | 1966 | return $this; |
1967 | 1967 | } |
1968 | - if ( $this->value !== true ) |
|
1968 | + if ($this->value !== true) |
|
1969 | 1969 | { |
1970 | 1970 | $message = sprintf( |
1971 | 1971 | $message ?: 'Value "%s" is not TRUE.', |
@@ -1986,11 +1986,11 @@ discard block |
||
1986 | 1986 | */ |
1987 | 1987 | public function truthy($message = null, $propertyPath = null) |
1988 | 1988 | { |
1989 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1989 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
1990 | 1990 | { |
1991 | 1991 | return $this; |
1992 | 1992 | } |
1993 | - if ( ! $this->value ) |
|
1993 | + if ( ! $this->value) |
|
1994 | 1994 | { |
1995 | 1995 | $message = sprintf( |
1996 | 1996 | $message ?: 'Value "%s" is not truthy.', |
@@ -2011,11 +2011,11 @@ discard block |
||
2011 | 2011 | */ |
2012 | 2012 | public function false($message = null, $propertyPath = null) |
2013 | 2013 | { |
2014 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
2014 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
2015 | 2015 | { |
2016 | 2016 | return $this; |
2017 | 2017 | } |
2018 | - if ( $this->value !== false ) |
|
2018 | + if ($this->value !== false) |
|
2019 | 2019 | { |
2020 | 2020 | $message = sprintf( |
2021 | 2021 | $message ?: 'Value "%s" is not FALSE.', |
@@ -2036,11 +2036,11 @@ discard block |
||
2036 | 2036 | */ |
2037 | 2037 | public function notFalse($message = null, $propertyPath = null) |
2038 | 2038 | { |
2039 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
2039 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
2040 | 2040 | { |
2041 | 2041 | return $this; |
2042 | 2042 | } |
2043 | - if ( $this->value === false ) |
|
2043 | + if ($this->value === false) |
|
2044 | 2044 | { |
2045 | 2045 | $message = sprintf( |
2046 | 2046 | $message ?: 'Value "%s" is not FALSE.', |
@@ -2061,11 +2061,11 @@ discard block |
||
2061 | 2061 | */ |
2062 | 2062 | public function classExists($message = null, $propertyPath = null) |
2063 | 2063 | { |
2064 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
2064 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
2065 | 2065 | { |
2066 | 2066 | return $this; |
2067 | 2067 | } |
2068 | - if ( !class_exists($this->value) ) |
|
2068 | + if ( ! class_exists($this->value)) |
|
2069 | 2069 | { |
2070 | 2070 | $message = sprintf( |
2071 | 2071 | $message ?: 'Class "%s" does not exist.', |
@@ -2087,19 +2087,19 @@ discard block |
||
2087 | 2087 | */ |
2088 | 2088 | public function implementsInterface($interfaceName, $message = null, $propertyPath = null) |
2089 | 2089 | { |
2090 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
2090 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
2091 | 2091 | { |
2092 | 2092 | return $this; |
2093 | 2093 | } |
2094 | 2094 | $reflection = new \ReflectionClass($this->value); |
2095 | - if ( !$reflection->implementsInterface($interfaceName) ) |
|
2095 | + if ( ! $reflection->implementsInterface($interfaceName)) |
|
2096 | 2096 | { |
2097 | 2097 | $message = sprintf( |
2098 | 2098 | $message ?: 'Class "%s" does not implement interface "%s".', |
2099 | 2099 | $this->stringify($this->value), |
2100 | 2100 | $this->stringify($interfaceName) |
2101 | 2101 | ); |
2102 | - throw $this->createException($message, self::INTERFACE_NOT_IMPLEMENTED, $propertyPath, ['interface' => $interfaceName]); |
|
2102 | + throw $this->createException($message, self::INTERFACE_NOT_IMPLEMENTED, $propertyPath, [ 'interface' => $interfaceName ]); |
|
2103 | 2103 | } |
2104 | 2104 | return $this; |
2105 | 2105 | } |
@@ -2120,11 +2120,11 @@ discard block |
||
2120 | 2120 | */ |
2121 | 2121 | public function isJsonString($message = null, $propertyPath = null) |
2122 | 2122 | { |
2123 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
2123 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
2124 | 2124 | { |
2125 | 2125 | return $this; |
2126 | 2126 | } |
2127 | - if ( null === json_decode($this->value) && JSON_ERROR_NONE !== json_last_error() ) |
|
2127 | + if (null === json_decode($this->value) && JSON_ERROR_NONE !== json_last_error()) |
|
2128 | 2128 | { |
2129 | 2129 | $message = sprintf( |
2130 | 2130 | $message ?: 'Value "%s" is not a valid JSON string.', |
@@ -2147,16 +2147,16 @@ discard block |
||
2147 | 2147 | */ |
2148 | 2148 | public function uuid($message = null, $propertyPath = null) |
2149 | 2149 | { |
2150 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
2150 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
2151 | 2151 | { |
2152 | 2152 | return $this; |
2153 | 2153 | } |
2154 | - $this->value = str_replace(['urn:', 'uuid:', '{', '}'], '', $this->value); |
|
2155 | - if ( $this->value === '00000000-0000-0000-0000-000000000000' ) |
|
2154 | + $this->value = str_replace([ 'urn:', 'uuid:', '{', '}' ], '', $this->value); |
|
2155 | + if ($this->value === '00000000-0000-0000-0000-000000000000') |
|
2156 | 2156 | { |
2157 | 2157 | return $this; |
2158 | 2158 | } |
2159 | - 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) ) |
|
2159 | + 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)) |
|
2160 | 2160 | { |
2161 | 2161 | $message = sprintf( |
2162 | 2162 | $message ?: 'Value "%s" is not a valid UUID.', |
@@ -2178,18 +2178,18 @@ discard block |
||
2178 | 2178 | */ |
2179 | 2179 | public function count($count, $message = null, $propertyPath = null) |
2180 | 2180 | { |
2181 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
2181 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
2182 | 2182 | { |
2183 | 2183 | return $this; |
2184 | 2184 | } |
2185 | - if ( $count !== count($this->value) ) |
|
2185 | + if ($count !== count($this->value)) |
|
2186 | 2186 | { |
2187 | 2187 | $message = sprintf( |
2188 | 2188 | $message ?: 'List does not contain exactly "%d" elements.', |
2189 | 2189 | $this->stringify($this->value), |
2190 | 2190 | $this->stringify($count) |
2191 | 2191 | ); |
2192 | - throw $this->createException($message, self::INVALID_COUNT, $propertyPath, ['count' => $count]); |
|
2192 | + throw $this->createException($message, self::INVALID_COUNT, $propertyPath, [ 'count' => $count ]); |
|
2193 | 2193 | } |
2194 | 2194 | return $this; |
2195 | 2195 | } |
@@ -2202,16 +2202,16 @@ discard block |
||
2202 | 2202 | */ |
2203 | 2203 | protected function doAllOrNullOr($func, $args) |
2204 | 2204 | { |
2205 | - if ( $this->nullOr && is_null($this->value) ) |
|
2205 | + if ($this->nullOr && is_null($this->value)) |
|
2206 | 2206 | { |
2207 | 2207 | return true; |
2208 | 2208 | } |
2209 | - if ( $this->all && (new Assert($this->value))->setExceptionClass($this->exceptionClass)->isTraversable() ) |
|
2209 | + if ($this->all && (new Assert($this->value))->setExceptionClass($this->exceptionClass)->isTraversable()) |
|
2210 | 2210 | { |
2211 | - foreach ( $this->value as $idx => $value ) |
|
2211 | + foreach ($this->value as $idx => $value) |
|
2212 | 2212 | { |
2213 | 2213 | $object = (new Assert($value))->setExceptionClass($this->exceptionClass); |
2214 | - call_user_func_array([$object, $func], $args); |
|
2214 | + call_user_func_array([ $object, $func ], $args); |
|
2215 | 2215 | } |
2216 | 2216 | return true; |
2217 | 2217 | } |
@@ -2228,12 +2228,12 @@ discard block |
||
2228 | 2228 | */ |
2229 | 2229 | public function choicesNotEmpty(array $choices, $message = null, $propertyPath = null) |
2230 | 2230 | { |
2231 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
2231 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
2232 | 2232 | { |
2233 | 2233 | return $this; |
2234 | 2234 | } |
2235 | 2235 | $this->notEmpty($message, $propertyPath); |
2236 | - foreach ( $choices as $choice ) |
|
2236 | + foreach ($choices as $choice) |
|
2237 | 2237 | { |
2238 | 2238 | $this->notEmptyKey($choice, $message, $propertyPath); |
2239 | 2239 | } |
@@ -2251,12 +2251,12 @@ discard block |
||
2251 | 2251 | */ |
2252 | 2252 | public function methodExists($object, $message = null, $propertyPath = null) |
2253 | 2253 | { |
2254 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
2254 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
2255 | 2255 | { |
2256 | 2256 | return $this; |
2257 | 2257 | } |
2258 | 2258 | (new Assert($object))->setExceptionClass($this->exceptionClass)->isObject($message, $propertyPath); |
2259 | - if ( !method_exists($object, $this->value) ) |
|
2259 | + if ( ! method_exists($object, $this->value)) |
|
2260 | 2260 | { |
2261 | 2261 | $message = sprintf( |
2262 | 2262 | $message ?: 'Expected "%s" does not a exist in provided object.', |
@@ -2277,11 +2277,11 @@ discard block |
||
2277 | 2277 | */ |
2278 | 2278 | public function isObject($message = null, $propertyPath = null) |
2279 | 2279 | { |
2280 | - if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
2280 | + if ($this->doAllOrNullOr(__FUNCTION__, func_get_args())) |
|
2281 | 2281 | { |
2282 | 2282 | return $this; |
2283 | 2283 | } |
2284 | - if ( !is_object($this->value) ) |
|
2284 | + if ( ! is_object($this->value)) |
|
2285 | 2285 | { |
2286 | 2286 | $message = sprintf( |
2287 | 2287 | $message ?: 'Provided "%s" is not a valid object.', |
@@ -2300,32 +2300,32 @@ discard block |
||
2300 | 2300 | */ |
2301 | 2301 | private function stringify($value) |
2302 | 2302 | { |
2303 | - if ( is_bool($value) ) |
|
2303 | + if (is_bool($value)) |
|
2304 | 2304 | { |
2305 | 2305 | return $value ? '<TRUE>' : '<FALSE>'; |
2306 | 2306 | } |
2307 | - if ( is_scalar($value) ) |
|
2307 | + if (is_scalar($value)) |
|
2308 | 2308 | { |
2309 | 2309 | $val = (string)$value; |
2310 | - if ( strlen($val) > 100 ) |
|
2310 | + if (strlen($val) > 100) |
|
2311 | 2311 | { |
2312 | - $val = substr($val, 0, 97) . '...'; |
|
2312 | + $val = substr($val, 0, 97).'...'; |
|
2313 | 2313 | } |
2314 | 2314 | return $val; |
2315 | 2315 | } |
2316 | - if ( is_array($value) ) |
|
2316 | + if (is_array($value)) |
|
2317 | 2317 | { |
2318 | 2318 | return '<ARRAY>'; |
2319 | 2319 | } |
2320 | - if ( is_object($value) ) |
|
2320 | + if (is_object($value)) |
|
2321 | 2321 | { |
2322 | 2322 | return get_class($value); |
2323 | 2323 | } |
2324 | - if ( is_resource($value) ) |
|
2324 | + if (is_resource($value)) |
|
2325 | 2325 | { |
2326 | 2326 | return '<RESOURCE>'; |
2327 | 2327 | } |
2328 | - if ( $value === null ) |
|
2328 | + if ($value === null) |
|
2329 | 2329 | { |
2330 | 2330 | return '<NULL>'; |
2331 | 2331 | } |