| @@ 974-984 (lines=11) @@ | ||
| 971 | * |
|
| 972 | * @throws InvalidArgumentException |
|
| 973 | */ |
|
| 974 | public static function range($value, $min, $max, $message = '') |
|
| 975 | { |
|
| 976 | if ($value < $min || $value > $max) { |
|
| 977 | static::reportInvalidArgument(\sprintf( |
|
| 978 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
| 979 | static::valueToString($value), |
|
| 980 | static::valueToString($min), |
|
| 981 | static::valueToString($max) |
|
| 982 | )); |
|
| 983 | } |
|
| 984 | } |
|
| 985 | ||
| 986 | /** |
|
| 987 | * A more human-readable alias of Assert::inArray(). |
|
| @@ 1446-1458 (lines=13) @@ | ||
| 1443 | * |
|
| 1444 | * @throws InvalidArgumentException |
|
| 1445 | */ |
|
| 1446 | public static function lengthBetween($value, $min, $max, $message = '') |
|
| 1447 | { |
|
| 1448 | $length = static::strlen($value); |
|
| 1449 | ||
| 1450 | if ($length < $min || $length > $max) { |
|
| 1451 | static::reportInvalidArgument(\sprintf( |
|
| 1452 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
| 1453 | static::valueToString($value), |
|
| 1454 | $min, |
|
| 1455 | $max |
|
| 1456 | )); |
|
| 1457 | } |
|
| 1458 | } |
|
| 1459 | ||
| 1460 | /** |
|
| 1461 | * Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file. |
|