| @@ 489-499 (lines=11) @@ | ||
| 486 | } |
|
| 487 | } |
|
| 488 | ||
| 489 | public static function range($value, $min, $max, $message = '') |
|
| 490 | { |
|
| 491 | if ($value < $min || $value > $max) { |
|
| 492 | static::reportInvalidArgument(sprintf( |
|
| 493 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
| 494 | static::valueToString($value), |
|
| 495 | static::valueToString($min), |
|
| 496 | static::valueToString($max) |
|
| 497 | )); |
|
| 498 | } |
|
| 499 | } |
|
| 500 | ||
| 501 | public static function oneOf($value, array $values, $message = '') |
|
| 502 | { |
|
| @@ 682-694 (lines=13) @@ | ||
| 679 | } |
|
| 680 | } |
|
| 681 | ||
| 682 | public static function lengthBetween($value, $min, $max, $message = '') |
|
| 683 | { |
|
| 684 | $length = static::strlen($value); |
|
| 685 | ||
| 686 | if ($length < $min || $length > $max) { |
|
| 687 | static::reportInvalidArgument(sprintf( |
|
| 688 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
| 689 | static::valueToString($value), |
|
| 690 | $min, |
|
| 691 | $max |
|
| 692 | )); |
|
| 693 | } |
|
| 694 | } |
|
| 695 | ||
| 696 | public static function fileExists($value, $message = '') |
|
| 697 | { |
|