@@ 1096-1106 (lines=11) @@ | ||
1093 | * |
|
1094 | * @throws InvalidArgumentException |
|
1095 | */ |
|
1096 | public static function range($value, $min, $max, $message = '') |
|
1097 | { |
|
1098 | if ($value < $min || $value > $max) { |
|
1099 | static::reportInvalidArgument(\sprintf( |
|
1100 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
1101 | static::valueToString($value), |
|
1102 | static::valueToString($min), |
|
1103 | static::valueToString($max) |
|
1104 | )); |
|
1105 | } |
|
1106 | } |
|
1107 | ||
1108 | /** |
|
1109 | * A more human-readable alias of Assert::inArray(). |
|
@@ 1568-1580 (lines=13) @@ | ||
1565 | * |
|
1566 | * @throws InvalidArgumentException |
|
1567 | */ |
|
1568 | public static function lengthBetween($value, $min, $max, $message = '') |
|
1569 | { |
|
1570 | $length = static::strlen($value); |
|
1571 | ||
1572 | if ($length < $min || $length > $max) { |
|
1573 | static::reportInvalidArgument(\sprintf( |
|
1574 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
1575 | static::valueToString($value), |
|
1576 | $min, |
|
1577 | $max |
|
1578 | )); |
|
1579 | } |
|
1580 | } |
|
1581 | ||
1582 | /** |
|
1583 | * Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file. |