| @@ 1097-1107 (lines=11) @@ | ||
| 1094 | * |
|
| 1095 | * @throws InvalidArgumentException |
|
| 1096 | */ |
|
| 1097 | public static function range($value, $min, $max, $message = '') |
|
| 1098 | { |
|
| 1099 | if ($value < $min || $value > $max) { |
|
| 1100 | static::reportInvalidArgument(\sprintf( |
|
| 1101 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
| 1102 | static::valueToString($value), |
|
| 1103 | static::valueToString($min), |
|
| 1104 | static::valueToString($max) |
|
| 1105 | )); |
|
| 1106 | } |
|
| 1107 | } |
|
| 1108 | ||
| 1109 | /** |
|
| 1110 | * A more human-readable alias of Assert::inArray(). |
|
| @@ 1569-1581 (lines=13) @@ | ||
| 1566 | * |
|
| 1567 | * @throws InvalidArgumentException |
|
| 1568 | */ |
|
| 1569 | public static function lengthBetween($value, $min, $max, $message = '') |
|
| 1570 | { |
|
| 1571 | $length = static::strlen($value); |
|
| 1572 | ||
| 1573 | if ($length < $min || $length > $max) { |
|
| 1574 | static::reportInvalidArgument(\sprintf( |
|
| 1575 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
| 1576 | static::valueToString($value), |
|
| 1577 | $min, |
|
| 1578 | $max |
|
| 1579 | )); |
|
| 1580 | } |
|
| 1581 | } |
|
| 1582 | ||
| 1583 | /** |
|
| 1584 | * Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file. |
|