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