@@ 900-910 (lines=11) @@ | ||
897 | * @param mixed max |
|
898 | * @param string $message |
|
899 | */ |
|
900 | public static function range($value, $min, $max, $message = '') |
|
901 | { |
|
902 | if ($value < $min || $value > $max) { |
|
903 | static::reportInvalidArgument(\sprintf( |
|
904 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
905 | static::valueToString($value), |
|
906 | static::valueToString($min), |
|
907 | static::valueToString($max) |
|
908 | )); |
|
909 | } |
|
910 | } |
|
911 | ||
912 | /** |
|
913 | * Does strict comparison, so Assert::oneOf(3, ['3']) does not pass the assertion. |
|
@@ 1240-1252 (lines=13) @@ | ||
1237 | * @param mixed $max |
|
1238 | * @param string $message |
|
1239 | */ |
|
1240 | public static function lengthBetween($value, $min, $max, $message = '') |
|
1241 | { |
|
1242 | $length = static::strlen($value); |
|
1243 | ||
1244 | if ($length < $min || $length > $max) { |
|
1245 | static::reportInvalidArgument(\sprintf( |
|
1246 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
1247 | static::valueToString($value), |
|
1248 | $min, |
|
1249 | $max |
|
1250 | )); |
|
1251 | } |
|
1252 | } |
|
1253 | ||
1254 | /** |
|
1255 | * Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file. |