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