@@ 953-963 (lines=11) @@ | ||
950 | * |
|
951 | * @throws InvalidArgumentException |
|
952 | */ |
|
953 | public static function range($value, $min, $max, $message = '') |
|
954 | { |
|
955 | if ($value < $min || $value > $max) { |
|
956 | static::reportInvalidArgument(\sprintf( |
|
957 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
958 | static::valueToString($value), |
|
959 | static::valueToString($min), |
|
960 | static::valueToString($max) |
|
961 | )); |
|
962 | } |
|
963 | } |
|
964 | ||
965 | /** |
|
966 | * A more human-readable alias of Assert::inArray(). |
|
@@ 1425-1437 (lines=13) @@ | ||
1422 | * |
|
1423 | * @throws InvalidArgumentException |
|
1424 | */ |
|
1425 | public static function lengthBetween($value, $min, $max, $message = '') |
|
1426 | { |
|
1427 | $length = static::strlen($value); |
|
1428 | ||
1429 | if ($length < $min || $length > $max) { |
|
1430 | static::reportInvalidArgument(\sprintf( |
|
1431 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
1432 | static::valueToString($value), |
|
1433 | $min, |
|
1434 | $max |
|
1435 | )); |
|
1436 | } |
|
1437 | } |
|
1438 | ||
1439 | /** |
|
1440 | * Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file. |