| @@ 501-511 (lines=11) @@ | ||
| 498 | } |
|
| 499 | } |
|
| 500 | ||
| 501 | public static function range($value, $min, $max, $message = '') |
|
| 502 | { |
|
| 503 | if ($value < $min || $value > $max) { |
|
| 504 | static::reportInvalidArgument(sprintf( |
|
| 505 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
| 506 | static::valueToString($value), |
|
| 507 | static::valueToString($min), |
|
| 508 | static::valueToString($max) |
|
| 509 | )); |
|
| 510 | } |
|
| 511 | } |
|
| 512 | ||
| 513 | public static function oneOf($value, array $values, $message = '') |
|
| 514 | { |
|
| @@ 704-716 (lines=13) @@ | ||
| 701 | } |
|
| 702 | } |
|
| 703 | ||
| 704 | public static function lengthBetween($value, $min, $max, $message = '') |
|
| 705 | { |
|
| 706 | $length = static::strlen($value); |
|
| 707 | ||
| 708 | if ($length < $min || $length > $max) { |
|
| 709 | static::reportInvalidArgument(sprintf( |
|
| 710 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
| 711 | static::valueToString($value), |
|
| 712 | $min, |
|
| 713 | $max |
|
| 714 | )); |
|
| 715 | } |
|
| 716 | } |
|
| 717 | ||
| 718 | public static function fileExists($value, $message = '') |
|
| 719 | { |
|