| @@ 454-464 (lines=11) @@ | ||
| 451 | } |
|
| 452 | } |
|
| 453 | ||
| 454 | public static function range($value, $min, $max, $message = '') |
|
| 455 | { |
|
| 456 | if ($value < $min || $value > $max) { |
|
| 457 | static::reportInvalidArgument(sprintf( |
|
| 458 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
| 459 | static::valueToString($value), |
|
| 460 | static::valueToString($min), |
|
| 461 | static::valueToString($max) |
|
| 462 | )); |
|
| 463 | } |
|
| 464 | } |
|
| 465 | ||
| 466 | public static function oneOf($value, array $values, $message = '') |
|
| 467 | { |
|
| @@ 658-670 (lines=13) @@ | ||
| 655 | } |
|
| 656 | } |
|
| 657 | ||
| 658 | public static function lengthBetween($value, $min, $max, $message = '') |
|
| 659 | { |
|
| 660 | $length = static::strlen($value); |
|
| 661 | ||
| 662 | if ($length < $min || $length > $max) { |
|
| 663 | static::reportInvalidArgument(sprintf( |
|
| 664 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
| 665 | static::valueToString($value), |
|
| 666 | $min, |
|
| 667 | $max |
|
| 668 | )); |
|
| 669 | } |
|
| 670 | } |
|
| 671 | ||
| 672 | public static function fileExists($value, $message = '') |
|
| 673 | { |
|