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