| @@ 1633-1642 (lines=10) @@ | ||
| 1630 | * |
|
| 1631 | * @throws InvalidArgumentException |
|
| 1632 | */ |
|
| 1633 | public static function minCount($array, $min, $message = '') |
|
| 1634 | { |
|
| 1635 | if (\count($array) < $min) { |
|
| 1636 | static::reportInvalidArgument(\sprintf( |
|
| 1637 | $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
| 1638 | \count($array), |
|
| 1639 | $min |
|
| 1640 | )); |
|
| 1641 | } |
|
| 1642 | } |
|
| 1643 | ||
| 1644 | /** |
|
| 1645 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| @@ 1653-1662 (lines=10) @@ | ||
| 1650 | * |
|
| 1651 | * @throws InvalidArgumentException |
|
| 1652 | */ |
|
| 1653 | public static function maxCount($array, $max, $message = '') |
|
| 1654 | { |
|
| 1655 | if (\count($array) > $max) { |
|
| 1656 | static::reportInvalidArgument(\sprintf( |
|
| 1657 | $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
| 1658 | \count($array), |
|
| 1659 | $max |
|
| 1660 | )); |
|
| 1661 | } |
|
| 1662 | } |
|
| 1663 | ||
| 1664 | /** |
|
| 1665 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| @@ 1696-1703 (lines=8) @@ | ||
| 1693 | * |
|
| 1694 | * @throws InvalidArgumentException |
|
| 1695 | */ |
|
| 1696 | public static function isList($array, $message = '') |
|
| 1697 | { |
|
| 1698 | if (!\is_array($array) || $array !== \array_values($array)) { |
|
| 1699 | static::reportInvalidArgument( |
|
| 1700 | $message ?: 'Expected list - non-associative array.' |
|
| 1701 | ); |
|
| 1702 | } |
|
| 1703 | } |
|
| 1704 | ||
| 1705 | /** |
|
| 1706 | * @param mixed $array |
|