| @@ 571-581 (lines=11) @@ | ||
| 568 | } |
|
| 569 | } |
|
| 570 | ||
| 571 | public static function range($value, $min, $max, $message = '') |
|
| 572 | { |
|
| 573 | if ($value < $min || $value > $max) { |
|
| 574 | static::reportInvalidArgument(sprintf( |
|
| 575 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
| 576 | static::valueToString($value), |
|
| 577 | static::valueToString($min), |
|
| 578 | static::valueToString($max) |
|
| 579 | )); |
|
| 580 | } |
|
| 581 | } |
|
| 582 | ||
| 583 | public static function oneOf($value, array $values, $message = '') |
|
| 584 | { |
|
| @@ 797-809 (lines=13) @@ | ||
| 794 | } |
|
| 795 | } |
|
| 796 | ||
| 797 | public static function lengthBetween($value, $min, $max, $message = '') |
|
| 798 | { |
|
| 799 | $length = static::strlen($value); |
|
| 800 | ||
| 801 | if ($length < $min || $length > $max) { |
|
| 802 | static::reportInvalidArgument(sprintf( |
|
| 803 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
| 804 | static::valueToString($value), |
|
| 805 | $min, |
|
| 806 | $max |
|
| 807 | )); |
|
| 808 | } |
|
| 809 | } |
|
| 810 | ||
| 811 | public static function fileExists($value, $message = '') |
|
| 812 | { |
|