| @@ 503-513 (lines=11) @@ | ||
| 500 | } |
|
| 501 | } |
|
| 502 | ||
| 503 | public static function range($value, $min, $max, $message = '') |
|
| 504 | { |
|
| 505 | if ($value < $min || $value > $max) { |
|
| 506 | static::reportInvalidArgument(sprintf( |
|
| 507 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
| 508 | static::valueToString($value), |
|
| 509 | static::valueToString($min), |
|
| 510 | static::valueToString($max) |
|
| 511 | )); |
|
| 512 | } |
|
| 513 | } |
|
| 514 | ||
| 515 | public static function oneOf($value, array $values, $message = '') |
|
| 516 | { |
|
| @@ 717-729 (lines=13) @@ | ||
| 714 | } |
|
| 715 | } |
|
| 716 | ||
| 717 | public static function lengthBetween($value, $min, $max, $message = '') |
|
| 718 | { |
|
| 719 | $length = static::strlen($value); |
|
| 720 | ||
| 721 | if ($length < $min || $length > $max) { |
|
| 722 | static::reportInvalidArgument(sprintf( |
|
| 723 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
| 724 | static::valueToString($value), |
|
| 725 | $min, |
|
| 726 | $max |
|
| 727 | )); |
|
| 728 | } |
|
| 729 | } |
|
| 730 | ||
| 731 | public static function fileExists($value, $message = '') |
|
| 732 | { |
|