| @@ 1137-1147 (lines=11) @@ | ||
| 1134 | * | |
| 1135 | * @throws InvalidArgumentException | |
| 1136 | */ | |
| 1137 | public static function range($value, $min, $max, $message = '') | |
| 1138 |     { | |
| 1139 |         if ($value < $min || $value > $max) { | |
| 1140 | static::reportInvalidArgument(\sprintf( | |
| 1141 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', | |
| 1142 | static::valueToString($value), | |
| 1143 | static::valueToString($min), | |
| 1144 | static::valueToString($max) | |
| 1145 | )); | |
| 1146 | } | |
| 1147 | } | |
| 1148 | ||
| 1149 | /** | |
| 1150 | * A more human-readable alias of Assert::inArray(). | |
| @@ 1609-1621 (lines=13) @@ | ||
| 1606 | * | |
| 1607 | * @throws InvalidArgumentException | |
| 1608 | */ | |
| 1609 | public static function lengthBetween($value, $min, $max, $message = '') | |
| 1610 |     { | |
| 1611 | $length = static::strlen($value); | |
| 1612 | ||
| 1613 |         if ($length < $min || $length > $max) { | |
| 1614 | static::reportInvalidArgument(\sprintf( | |
| 1615 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', | |
| 1616 | static::valueToString($value), | |
| 1617 | $min, | |
| 1618 | $max | |
| 1619 | )); | |
| 1620 | } | |
| 1621 | } | |
| 1622 | ||
| 1623 | /** | |
| 1624 | * Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file. | |