@@ 1027-1037 (lines=11) @@ | ||
1024 | * |
|
1025 | * @throws InvalidArgumentException |
|
1026 | */ |
|
1027 | public static function range($value, $min, $max, $message = '') |
|
1028 | { |
|
1029 | if ($value < $min || $value > $max) { |
|
1030 | static::reportInvalidArgument(\sprintf( |
|
1031 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
1032 | static::valueToString($value), |
|
1033 | static::valueToString($min), |
|
1034 | static::valueToString($max) |
|
1035 | )); |
|
1036 | } |
|
1037 | } |
|
1038 | ||
1039 | /** |
|
1040 | * Does strict comparison, so Assert::oneOf(3, ['3']) does not pass the assertion. |
|
@@ 1403-1415 (lines=13) @@ | ||
1400 | * |
|
1401 | * @throws InvalidArgumentException |
|
1402 | */ |
|
1403 | public static function lengthBetween($value, $min, $max, $message = '') |
|
1404 | { |
|
1405 | $length = static::strlen($value); |
|
1406 | ||
1407 | if ($length < $min || $length > $max) { |
|
1408 | static::reportInvalidArgument(\sprintf( |
|
1409 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
1410 | static::valueToString($value), |
|
1411 | $min, |
|
1412 | $max |
|
1413 | )); |
|
1414 | } |
|
1415 | } |
|
1416 | ||
1417 | /** |
|
1418 | * Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file. |