| @@ 1741-1750 (lines=10) @@ | ||
| 1738 | * |
|
| 1739 | * @throws InvalidArgumentException |
|
| 1740 | */ |
|
| 1741 | public static function minCount($array, $min, $message = '') |
|
| 1742 | { |
|
| 1743 | if (\count($array) < $min) { |
|
| 1744 | static::reportInvalidArgument(\sprintf( |
|
| 1745 | $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
| 1746 | \count($array), |
|
| 1747 | $min |
|
| 1748 | )); |
|
| 1749 | } |
|
| 1750 | } |
|
| 1751 | ||
| 1752 | /** |
|
| 1753 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| @@ 1761-1770 (lines=10) @@ | ||
| 1758 | * |
|
| 1759 | * @throws InvalidArgumentException |
|
| 1760 | */ |
|
| 1761 | public static function maxCount($array, $max, $message = '') |
|
| 1762 | { |
|
| 1763 | if (\count($array) > $max) { |
|
| 1764 | static::reportInvalidArgument(\sprintf( |
|
| 1765 | $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
| 1766 | \count($array), |
|
| 1767 | $max |
|
| 1768 | )); |
|
| 1769 | } |
|
| 1770 | } |
|
| 1771 | ||
| 1772 | /** |
|
| 1773 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| @@ 1805-1812 (lines=8) @@ | ||
| 1802 | * |
|
| 1803 | * @throws InvalidArgumentException |
|
| 1804 | */ |
|
| 1805 | public static function isList($array, $message = '') |
|
| 1806 | { |
|
| 1807 | if (!\is_array($array) || $array !== \array_values($array)) { |
|
| 1808 | static::reportInvalidArgument( |
|
| 1809 | $message ?: 'Expected list - non-associative array.' |
|
| 1810 | ); |
|
| 1811 | } |
|
| 1812 | } |
|
| 1813 | ||
| 1814 | /** |
|
| 1815 | * @psalm-pure |
|