| @@ 915-925 (lines=11) @@ | ||
| 912 | * |
|
| 913 | * @throws InvalidArgumentException |
|
| 914 | */ |
|
| 915 | public static function range($value, $min, $max, $message = '') |
|
| 916 | { |
|
| 917 | if ($value < $min || $value > $max) { |
|
| 918 | static::reportInvalidArgument(\sprintf( |
|
| 919 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
| 920 | static::valueToString($value), |
|
| 921 | static::valueToString($min), |
|
| 922 | static::valueToString($max) |
|
| 923 | )); |
|
| 924 | } |
|
| 925 | } |
|
| 926 | ||
| 927 | /** |
|
| 928 | * A more human-readable alias of Assert::inArray(). |
|
| @@ 1387-1399 (lines=13) @@ | ||
| 1384 | * |
|
| 1385 | * @throws InvalidArgumentException |
|
| 1386 | */ |
|
| 1387 | public static function lengthBetween($value, $min, $max, $message = '') |
|
| 1388 | { |
|
| 1389 | $length = static::strlen($value); |
|
| 1390 | ||
| 1391 | if ($length < $min || $length > $max) { |
|
| 1392 | static::reportInvalidArgument(\sprintf( |
|
| 1393 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
| 1394 | static::valueToString($value), |
|
| 1395 | $min, |
|
| 1396 | $max |
|
| 1397 | )); |
|
| 1398 | } |
|
| 1399 | } |
|
| 1400 | ||
| 1401 | /** |
|
| 1402 | * Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file. |
|