@@ 933-943 (lines=11) @@ | ||
930 | * |
|
931 | * @throws InvalidArgumentException |
|
932 | */ |
|
933 | public static function range($value, $min, $max, $message = '') |
|
934 | { |
|
935 | if ($value < $min || $value > $max) { |
|
936 | static::reportInvalidArgument(\sprintf( |
|
937 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
938 | static::valueToString($value), |
|
939 | static::valueToString($min), |
|
940 | static::valueToString($max) |
|
941 | )); |
|
942 | } |
|
943 | } |
|
944 | ||
945 | /** |
|
946 | * A more human-readable alias of Assert::inArray(). |
|
@@ 1405-1417 (lines=13) @@ | ||
1402 | * |
|
1403 | * @throws InvalidArgumentException |
|
1404 | */ |
|
1405 | public static function lengthBetween($value, $min, $max, $message = '') |
|
1406 | { |
|
1407 | $length = static::strlen($value); |
|
1408 | ||
1409 | if ($length < $min || $length > $max) { |
|
1410 | static::reportInvalidArgument(\sprintf( |
|
1411 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
1412 | static::valueToString($value), |
|
1413 | $min, |
|
1414 | $max |
|
1415 | )); |
|
1416 | } |
|
1417 | } |
|
1418 | ||
1419 | /** |
|
1420 | * Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file. |