| @@ 609-619 (lines=11) @@ | ||
| 606 | } |
|
| 607 | } |
|
| 608 | ||
| 609 | public static function range($value, $min, $max, $message = '') |
|
| 610 | { |
|
| 611 | if ($value < $min || $value > $max) { |
|
| 612 | static::reportInvalidArgument(sprintf( |
|
| 613 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
| 614 | static::valueToString($value), |
|
| 615 | static::valueToString($min), |
|
| 616 | static::valueToString($max) |
|
| 617 | )); |
|
| 618 | } |
|
| 619 | } |
|
| 620 | ||
| 621 | public static function oneOf($value, array $values, $message = '') |
|
| 622 | { |
|
| @@ 835-847 (lines=13) @@ | ||
| 832 | } |
|
| 833 | } |
|
| 834 | ||
| 835 | public static function lengthBetween($value, $min, $max, $message = '') |
|
| 836 | { |
|
| 837 | $length = static::strlen($value); |
|
| 838 | ||
| 839 | if ($length < $min || $length > $max) { |
|
| 840 | static::reportInvalidArgument(sprintf( |
|
| 841 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
| 842 | static::valueToString($value), |
|
| 843 | $min, |
|
| 844 | $max |
|
| 845 | )); |
|
| 846 | } |
|
| 847 | } |
|
| 848 | ||
| 849 | public static function fileExists($value, $message = '') |
|
| 850 | { |
|