@@ 1088-1098 (lines=11) @@ | ||
1085 | * |
|
1086 | * @throws InvalidArgumentException |
|
1087 | */ |
|
1088 | public static function range($value, $min, $max, $message = '') |
|
1089 | { |
|
1090 | if ($value < $min || $value > $max) { |
|
1091 | static::reportInvalidArgument(\sprintf( |
|
1092 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
1093 | static::valueToString($value), |
|
1094 | static::valueToString($min), |
|
1095 | static::valueToString($max) |
|
1096 | )); |
|
1097 | } |
|
1098 | } |
|
1099 | ||
1100 | /** |
|
1101 | * Does strict comparison, so Assert::oneOf(3, ['3']) does not pass the assertion. |
|
@@ 1504-1516 (lines=13) @@ | ||
1501 | * |
|
1502 | * @throws InvalidArgumentException |
|
1503 | */ |
|
1504 | public static function lengthBetween($value, $min, $max, $message = '') |
|
1505 | { |
|
1506 | $length = static::strlen($value); |
|
1507 | ||
1508 | if ($length < $min || $length > $max) { |
|
1509 | static::reportInvalidArgument(\sprintf( |
|
1510 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
1511 | static::valueToString($value), |
|
1512 | $min, |
|
1513 | $max |
|
1514 | )); |
|
1515 | } |
|
1516 | } |
|
1517 | ||
1518 | /** |
|
1519 | * Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file. |