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