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