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