@@ 471-481 (lines=11) @@ | ||
468 | } |
|
469 | } |
|
470 | ||
471 | public static function range($value, $min, $max, $message = '') |
|
472 | { |
|
473 | if ($value < $min || $value > $max) { |
|
474 | static::reportInvalidArgument(sprintf( |
|
475 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
476 | static::valueToString($value), |
|
477 | static::valueToString($min), |
|
478 | static::valueToString($max) |
|
479 | )); |
|
480 | } |
|
481 | } |
|
482 | ||
483 | public static function oneOf($value, array $values, $message = '') |
|
484 | { |
|
@@ 664-676 (lines=13) @@ | ||
661 | } |
|
662 | } |
|
663 | ||
664 | public static function lengthBetween($value, $min, $max, $message = '') |
|
665 | { |
|
666 | $length = static::strlen($value); |
|
667 | ||
668 | if ($length < $min || $length > $max) { |
|
669 | static::reportInvalidArgument(sprintf( |
|
670 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
671 | static::valueToString($value), |
|
672 | $min, |
|
673 | $max |
|
674 | )); |
|
675 | } |
|
676 | } |
|
677 | ||
678 | public static function fileExists($value, $message = '') |
|
679 | { |