| @@ 1705-1714 (lines=10) @@ | ||
| 1702 | * |
|
| 1703 | * @throws InvalidArgumentException |
|
| 1704 | */ |
|
| 1705 | public static function minCount($array, $min, $message = '') |
|
| 1706 | { |
|
| 1707 | if (\count($array) < $min) { |
|
| 1708 | static::reportInvalidArgument(\sprintf( |
|
| 1709 | $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
| 1710 | \count($array), |
|
| 1711 | $min |
|
| 1712 | )); |
|
| 1713 | } |
|
| 1714 | } |
|
| 1715 | ||
| 1716 | /** |
|
| 1717 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| @@ 1725-1734 (lines=10) @@ | ||
| 1722 | * |
|
| 1723 | * @throws InvalidArgumentException |
|
| 1724 | */ |
|
| 1725 | public static function maxCount($array, $max, $message = '') |
|
| 1726 | { |
|
| 1727 | if (\count($array) > $max) { |
|
| 1728 | static::reportInvalidArgument(\sprintf( |
|
| 1729 | $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
| 1730 | \count($array), |
|
| 1731 | $max |
|
| 1732 | )); |
|
| 1733 | } |
|
| 1734 | } |
|
| 1735 | ||
| 1736 | /** |
|
| 1737 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| @@ 1768-1775 (lines=8) @@ | ||
| 1765 | * |
|
| 1766 | * @throws InvalidArgumentException |
|
| 1767 | */ |
|
| 1768 | public static function isList($array, $message = '') |
|
| 1769 | { |
|
| 1770 | if (!\is_array($array) || $array !== \array_values($array)) { |
|
| 1771 | static::reportInvalidArgument( |
|
| 1772 | $message ?: 'Expected list - non-associative array.' |
|
| 1773 | ); |
|
| 1774 | } |
|
| 1775 | } |
|
| 1776 | ||
| 1777 | /** |
|
| 1778 | * @psalm-assert non-empty-list $array |
|