| @@ 445-455 (lines=11) @@ | ||
| 442 | } |
|
| 443 | } |
|
| 444 | ||
| 445 | public static function range($value, $min, $max, $message = '') |
|
| 446 | { |
|
| 447 | if ($value < $min || $value > $max) { |
|
| 448 | throw new InvalidArgumentException(sprintf( |
|
| 449 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
| 450 | self::valueToString($value), |
|
| 451 | self::valueToString($min), |
|
| 452 | self::valueToString($max) |
|
| 453 | )); |
|
| 454 | } |
|
| 455 | } |
|
| 456 | ||
| 457 | public static function oneOf($value, array $values, $message = '') |
|
| 458 | { |
|
| @@ 638-650 (lines=13) @@ | ||
| 635 | } |
|
| 636 | } |
|
| 637 | ||
| 638 | public static function lengthBetween($value, $min, $max, $message = '') |
|
| 639 | { |
|
| 640 | $length = self::strlen($value); |
|
| 641 | ||
| 642 | if ($length < $min || $length > $max) { |
|
| 643 | throw new InvalidArgumentException(sprintf( |
|
| 644 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
| 645 | self::valueToString($value), |
|
| 646 | $min, |
|
| 647 | $max |
|
| 648 | )); |
|
| 649 | } |
|
| 650 | } |
|
| 651 | ||
| 652 | public static function fileExists($value, $message = '') |
|
| 653 | { |
|