@@ 453-463 (lines=11) @@ | ||
450 | } |
|
451 | } |
|
452 | ||
453 | public static function range($value, $min, $max, $message = '') |
|
454 | { |
|
455 | if ($value < $min || $value > $max) { |
|
456 | throw new InvalidArgumentException(sprintf( |
|
457 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
458 | static::valueToString($value), |
|
459 | static::valueToString($min), |
|
460 | static::valueToString($max) |
|
461 | )); |
|
462 | } |
|
463 | } |
|
464 | ||
465 | public static function oneOf($value, array $values, $message = '') |
|
466 | { |
|
@@ 646-658 (lines=13) @@ | ||
643 | } |
|
644 | } |
|
645 | ||
646 | public static function lengthBetween($value, $min, $max, $message = '') |
|
647 | { |
|
648 | $length = static::strlen($value); |
|
649 | ||
650 | if ($length < $min || $length > $max) { |
|
651 | throw new InvalidArgumentException(sprintf( |
|
652 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
653 | static::valueToString($value), |
|
654 | $min, |
|
655 | $max |
|
656 | )); |
|
657 | } |
|
658 | } |
|
659 | ||
660 | public static function fileExists($value, $message = '') |
|
661 | { |