@@ 644-654 (lines=11) @@ | ||
641 | } |
|
642 | } |
|
643 | ||
644 | public static function range($value, $min, $max, $message = '') |
|
645 | { |
|
646 | if ($value < $min || $value > $max) { |
|
647 | static::reportInvalidArgument(sprintf( |
|
648 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
649 | static::valueToString($value), |
|
650 | static::valueToString($min), |
|
651 | static::valueToString($max) |
|
652 | )); |
|
653 | } |
|
654 | } |
|
655 | ||
656 | public static function oneOf($value, array $values, $message = '') |
|
657 | { |
|
@@ 870-882 (lines=13) @@ | ||
867 | } |
|
868 | } |
|
869 | ||
870 | public static function lengthBetween($value, $min, $max, $message = '') |
|
871 | { |
|
872 | $length = static::strlen($value); |
|
873 | ||
874 | if ($length < $min || $length > $max) { |
|
875 | static::reportInvalidArgument(sprintf( |
|
876 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
877 | static::valueToString($value), |
|
878 | $min, |
|
879 | $max |
|
880 | )); |
|
881 | } |
|
882 | } |
|
883 | ||
884 | public static function fileExists($value, $message = '') |
|
885 | { |