| @@ 1088-1098 (lines=11) @@ | ||
| 1085 | * |
|
| 1086 | * @throws InvalidArgumentException |
|
| 1087 | */ |
|
| 1088 | public static function range($value, $min, $max, $message = '') |
|
| 1089 | { |
|
| 1090 | if ($value < $min || $value > $max) { |
|
| 1091 | static::reportInvalidArgument(\sprintf( |
|
| 1092 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
| 1093 | static::valueToString($value), |
|
| 1094 | static::valueToString($min), |
|
| 1095 | static::valueToString($max) |
|
| 1096 | )); |
|
| 1097 | } |
|
| 1098 | } |
|
| 1099 | ||
| 1100 | /** |
|
| 1101 | * A more human-readable alias of Assert::inArray(). |
|
| @@ 1520-1532 (lines=13) @@ | ||
| 1517 | * |
|
| 1518 | * @throws InvalidArgumentException |
|
| 1519 | */ |
|
| 1520 | public static function lengthBetween($value, $min, $max, $message = '') |
|
| 1521 | { |
|
| 1522 | $length = static::strlen($value); |
|
| 1523 | ||
| 1524 | if ($length < $min || $length > $max) { |
|
| 1525 | static::reportInvalidArgument(\sprintf( |
|
| 1526 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
| 1527 | static::valueToString($value), |
|
| 1528 | $min, |
|
| 1529 | $max |
|
| 1530 | )); |
|
| 1531 | } |
|
| 1532 | } |
|
| 1533 | ||
| 1534 | /** |
|
| 1535 | * Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file. |
|