@@ 513-522 (lines=10) @@ | ||
510 | } |
|
511 | } |
|
512 | ||
513 | public static function endsWith($value, $suffix, $message = '') |
|
514 | { |
|
515 | if ($suffix !== substr($value, -static::strlen($suffix))) { |
|
516 | throw static::createInvalidArgumentException(sprintf( |
|
517 | $message ?: 'Expected a value to end with %2$s. Got: %s', |
|
518 | static::valueToString($value), |
|
519 | static::valueToString($suffix) |
|
520 | )); |
|
521 | } |
|
522 | } |
|
523 | ||
524 | public static function regex($value, $pattern, $message = '') |
|
525 | { |
|
@@ 668-678 (lines=11) @@ | ||
665 | } |
|
666 | } |
|
667 | ||
668 | public static function file($value, $message = '') |
|
669 | { |
|
670 | static::fileExists($value, $message); |
|
671 | ||
672 | if (!is_file($value)) { |
|
673 | throw static::createInvalidArgumentException(sprintf( |
|
674 | $message ?: 'The path %s is not a file.', |
|
675 | static::valueToString($value) |
|
676 | )); |
|
677 | } |
|
678 | } |
|
679 | ||
680 | public static function directory($value, $message = '') |
|
681 | { |
|
@@ 680-690 (lines=11) @@ | ||
677 | } |
|
678 | } |
|
679 | ||
680 | public static function directory($value, $message = '') |
|
681 | { |
|
682 | static::fileExists($value, $message); |
|
683 | ||
684 | if (!is_dir($value)) { |
|
685 | throw static::createInvalidArgumentException(sprintf( |
|
686 | $message ?: 'The path %s is no directory.', |
|
687 | static::valueToString($value) |
|
688 | )); |
|
689 | } |
|
690 | } |
|
691 | ||
692 | public static function readable($value, $message = '') |
|
693 | { |
|
@@ 733-742 (lines=10) @@ | ||
730 | } |
|
731 | } |
|
732 | ||
733 | public static function implementsInterface($value, $interface, $message = '') |
|
734 | { |
|
735 | if (!in_array($interface, class_implements($value))) { |
|
736 | throw static::createInvalidArgumentException(sprintf( |
|
737 | $message ?: 'Expected an implementation of %2$s. Got: %s', |
|
738 | static::valueToString($value), |
|
739 | static::valueToString($interface) |
|
740 | )); |
|
741 | } |
|
742 | } |
|
743 | ||
744 | public static function propertyExists($classOrObject, $property, $message = '') |
|
745 | { |