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