@@ 851-861 (lines=11) @@ | ||
848 | * @param mixed max |
|
849 | * @param string $message |
|
850 | */ |
|
851 | public static function range($value, $min, $max, $message = '') |
|
852 | { |
|
853 | if ($value < $min || $value > $max) { |
|
854 | static::reportInvalidArgument(\sprintf( |
|
855 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
856 | static::valueToString($value), |
|
857 | static::valueToString($min), |
|
858 | static::valueToString($max) |
|
859 | )); |
|
860 | } |
|
861 | } |
|
862 | ||
863 | /** |
|
864 | * Does strict comparison, so Assert::oneOf(3, ['3']) does not pass the assertion. |
|
@@ 1191-1203 (lines=13) @@ | ||
1188 | * @param mixed $max |
|
1189 | * @param string $message |
|
1190 | */ |
|
1191 | public static function lengthBetween($value, $min, $max, $message = '') |
|
1192 | { |
|
1193 | $length = static::strlen($value); |
|
1194 | ||
1195 | if ($length < $min || $length > $max) { |
|
1196 | static::reportInvalidArgument(\sprintf( |
|
1197 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
1198 | static::valueToString($value), |
|
1199 | $min, |
|
1200 | $max |
|
1201 | )); |
|
1202 | } |
|
1203 | } |
|
1204 | ||
1205 | /** |
|
1206 | * Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file. |