@@ 975-985 (lines=11) @@ | ||
972 | * |
|
973 | * @throws InvalidArgumentException |
|
974 | */ |
|
975 | public static function range($value, $min, $max, $message = '') |
|
976 | { |
|
977 | if ($value < $min || $value > $max) { |
|
978 | static::reportInvalidArgument(\sprintf( |
|
979 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
980 | static::valueToString($value), |
|
981 | static::valueToString($min), |
|
982 | static::valueToString($max) |
|
983 | )); |
|
984 | } |
|
985 | } |
|
986 | ||
987 | /** |
|
988 | * A more human-readable alias of Assert::inArray(). |
|
@@ 1447-1459 (lines=13) @@ | ||
1444 | * |
|
1445 | * @throws InvalidArgumentException |
|
1446 | */ |
|
1447 | public static function lengthBetween($value, $min, $max, $message = '') |
|
1448 | { |
|
1449 | $length = static::strlen($value); |
|
1450 | ||
1451 | if ($length < $min || $length > $max) { |
|
1452 | static::reportInvalidArgument(\sprintf( |
|
1453 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
1454 | static::valueToString($value), |
|
1455 | $min, |
|
1456 | $max |
|
1457 | )); |
|
1458 | } |
|
1459 | } |
|
1460 | ||
1461 | /** |
|
1462 | * Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file. |