| @@ 653-663 (lines=11) @@ | ||
| 650 | } |
|
| 651 | } |
|
| 652 | ||
| 653 | public static function range($value, $min, $max, $message = '') |
|
| 654 | { |
|
| 655 | if ($value < $min || $value > $max) { |
|
| 656 | static::reportInvalidArgument(sprintf( |
|
| 657 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
| 658 | static::valueToString($value), |
|
| 659 | static::valueToString($min), |
|
| 660 | static::valueToString($max) |
|
| 661 | )); |
|
| 662 | } |
|
| 663 | } |
|
| 664 | ||
| 665 | public static function oneOf($value, array $values, $message = '') |
|
| 666 | { |
|
| @@ 879-891 (lines=13) @@ | ||
| 876 | } |
|
| 877 | } |
|
| 878 | ||
| 879 | public static function lengthBetween($value, $min, $max, $message = '') |
|
| 880 | { |
|
| 881 | $length = static::strlen($value); |
|
| 882 | ||
| 883 | if ($length < $min || $length > $max) { |
|
| 884 | static::reportInvalidArgument(sprintf( |
|
| 885 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
| 886 | static::valueToString($value), |
|
| 887 | $min, |
|
| 888 | $max |
|
| 889 | )); |
|
| 890 | } |
|
| 891 | } |
|
| 892 | ||
| 893 | public static function fileExists($value, $message = '') |
|
| 894 | { |
|