@@ 1759-1768 (lines=10) @@ | ||
1756 | * |
|
1757 | * @throws InvalidArgumentException |
|
1758 | */ |
|
1759 | public static function minCount($array, $min, $message = '') |
|
1760 | { |
|
1761 | if (\count($array) < $min) { |
|
1762 | static::reportInvalidArgument(\sprintf( |
|
1763 | $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
1764 | \count($array), |
|
1765 | $min |
|
1766 | )); |
|
1767 | } |
|
1768 | } |
|
1769 | ||
1770 | /** |
|
1771 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
@@ 1779-1788 (lines=10) @@ | ||
1776 | * |
|
1777 | * @throws InvalidArgumentException |
|
1778 | */ |
|
1779 | public static function maxCount($array, $max, $message = '') |
|
1780 | { |
|
1781 | if (\count($array) > $max) { |
|
1782 | static::reportInvalidArgument(\sprintf( |
|
1783 | $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
1784 | \count($array), |
|
1785 | $max |
|
1786 | )); |
|
1787 | } |
|
1788 | } |
|
1789 | ||
1790 | /** |
|
1791 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
@@ 1823-1830 (lines=8) @@ | ||
1820 | * |
|
1821 | * @throws InvalidArgumentException |
|
1822 | */ |
|
1823 | public static function isList($array, $message = '') |
|
1824 | { |
|
1825 | if (!\is_array($array) || $array !== \array_values($array)) { |
|
1826 | static::reportInvalidArgument( |
|
1827 | $message ?: 'Expected list - non-associative array.' |
|
1828 | ); |
|
1829 | } |
|
1830 | } |
|
1831 | ||
1832 | /** |
|
1833 | * @psalm-pure |