| @@ 1117-1127 (lines=11) @@ | ||
| 1114 | * |
|
| 1115 | * @throws InvalidArgumentException |
|
| 1116 | */ |
|
| 1117 | public static function range($value, $min, $max, $message = '') |
|
| 1118 | { |
|
| 1119 | if ($value < $min || $value > $max) { |
|
| 1120 | static::reportInvalidArgument(\sprintf( |
|
| 1121 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
| 1122 | static::valueToString($value), |
|
| 1123 | static::valueToString($min), |
|
| 1124 | static::valueToString($max) |
|
| 1125 | )); |
|
| 1126 | } |
|
| 1127 | } |
|
| 1128 | ||
| 1129 | /** |
|
| 1130 | * A more human-readable alias of Assert::inArray(). |
|
| @@ 1589-1601 (lines=13) @@ | ||
| 1586 | * |
|
| 1587 | * @throws InvalidArgumentException |
|
| 1588 | */ |
|
| 1589 | public static function lengthBetween($value, $min, $max, $message = '') |
|
| 1590 | { |
|
| 1591 | $length = static::strlen($value); |
|
| 1592 | ||
| 1593 | if ($length < $min || $length > $max) { |
|
| 1594 | static::reportInvalidArgument(\sprintf( |
|
| 1595 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
| 1596 | static::valueToString($value), |
|
| 1597 | $min, |
|
| 1598 | $max |
|
| 1599 | )); |
|
| 1600 | } |
|
| 1601 | } |
|
| 1602 | ||
| 1603 | /** |
|
| 1604 | * Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file. |
|