| @@ 929-939 (lines=11) @@ | ||
| 926 | * |
|
| 927 | * @throws InvalidArgumentException |
|
| 928 | */ |
|
| 929 | public static function range($value, $min, $max, $message = '') |
|
| 930 | { |
|
| 931 | if ($value < $min || $value > $max) { |
|
| 932 | static::reportInvalidArgument(\sprintf( |
|
| 933 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
| 934 | static::valueToString($value), |
|
| 935 | static::valueToString($min), |
|
| 936 | static::valueToString($max) |
|
| 937 | )); |
|
| 938 | } |
|
| 939 | } |
|
| 940 | ||
| 941 | /** |
|
| 942 | * A more human-readable alias of Assert::inArray(). |
|
| @@ 1401-1413 (lines=13) @@ | ||
| 1398 | * |
|
| 1399 | * @throws InvalidArgumentException |
|
| 1400 | */ |
|
| 1401 | public static function lengthBetween($value, $min, $max, $message = '') |
|
| 1402 | { |
|
| 1403 | $length = static::strlen($value); |
|
| 1404 | ||
| 1405 | if ($length < $min || $length > $max) { |
|
| 1406 | static::reportInvalidArgument(\sprintf( |
|
| 1407 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
| 1408 | static::valueToString($value), |
|
| 1409 | $min, |
|
| 1410 | $max |
|
| 1411 | )); |
|
| 1412 | } |
|
| 1413 | } |
|
| 1414 | ||
| 1415 | /** |
|
| 1416 | * Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file. |
|