| @@ 537-547 (lines=11) @@ | ||
| 534 | } |
|
| 535 | } |
|
| 536 | ||
| 537 | public static function range($value, $min, $max, $message = '') |
|
| 538 | { |
|
| 539 | if ($value < $min || $value > $max) { |
|
| 540 | static::reportInvalidArgument(sprintf( |
|
| 541 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
| 542 | static::valueToString($value), |
|
| 543 | static::valueToString($min), |
|
| 544 | static::valueToString($max) |
|
| 545 | )); |
|
| 546 | } |
|
| 547 | } |
|
| 548 | ||
| 549 | public static function oneOf($value, array $values, $message = '') |
|
| 550 | { |
|
| @@ 763-775 (lines=13) @@ | ||
| 760 | } |
|
| 761 | } |
|
| 762 | ||
| 763 | public static function lengthBetween($value, $min, $max, $message = '') |
|
| 764 | { |
|
| 765 | $length = static::strlen($value); |
|
| 766 | ||
| 767 | if ($length < $min || $length > $max) { |
|
| 768 | static::reportInvalidArgument(sprintf( |
|
| 769 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
| 770 | static::valueToString($value), |
|
| 771 | $min, |
|
| 772 | $max |
|
| 773 | )); |
|
| 774 | } |
|
| 775 | } |
|
| 776 | ||
| 777 | public static function fileExists($value, $message = '') |
|
| 778 | { |
|