| @@ 1309-1321 (lines=13) @@ | ||
| 1306 | * @param null $exception |
|
| 1307 | * @throws Exception |
|
| 1308 | */ |
|
| 1309 | public static function lengthBetween($value, $min, $max, $message = '', $exception = null) |
|
| 1310 | { |
|
| 1311 | $length = static::strlen($value); |
|
| 1312 | ||
| 1313 | if ($length < $min || $length > $max) { |
|
| 1314 | static::throwException(\sprintf( |
|
| 1315 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
| 1316 | static::valueToString($value), |
|
| 1317 | $min, |
|
| 1318 | $max |
|
| 1319 | ), $exception); |
|
| 1320 | } |
|
| 1321 | } |
|
| 1322 | ||
| 1323 | /** |
|
| 1324 | * Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file. |
|
| @@ 1654-1666 (lines=13) @@ | ||
| 1651 | * @param null $exception |
|
| 1652 | * @throws Exception |
|
| 1653 | */ |
|
| 1654 | public static function countBetween($array, $min, $max, $message = '', $exception = null) |
|
| 1655 | { |
|
| 1656 | $count = \count($array); |
|
| 1657 | ||
| 1658 | if ($count < $min || $count > $max) { |
|
| 1659 | static::throwException(\sprintf( |
|
| 1660 | $message ?: 'Expected an array to contain between %2$d and %3$d elements. Got: %d', |
|
| 1661 | $count, |
|
| 1662 | $min, |
|
| 1663 | $max |
|
| 1664 | ), $exception); |
|
| 1665 | } |
|
| 1666 | } |
|
| 1667 | ||
| 1668 | /** |
|
| 1669 | * @param mixed $array |
|