| @@ 1779-1788 (lines=10) @@ | ||
| 1776 | * |
|
| 1777 | * @throws InvalidArgumentException |
|
| 1778 | */ |
|
| 1779 | public static function minCount($array, $min, $message = '') |
|
| 1780 | { |
|
| 1781 | if (\count($array) < $min) { |
|
| 1782 | static::reportInvalidArgument(\sprintf( |
|
| 1783 | $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
| 1784 | \count($array), |
|
| 1785 | $min |
|
| 1786 | )); |
|
| 1787 | } |
|
| 1788 | } |
|
| 1789 | ||
| 1790 | /** |
|
| 1791 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| @@ 1799-1808 (lines=10) @@ | ||
| 1796 | * |
|
| 1797 | * @throws InvalidArgumentException |
|
| 1798 | */ |
|
| 1799 | public static function maxCount($array, $max, $message = '') |
|
| 1800 | { |
|
| 1801 | if (\count($array) > $max) { |
|
| 1802 | static::reportInvalidArgument(\sprintf( |
|
| 1803 | $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
| 1804 | \count($array), |
|
| 1805 | $max |
|
| 1806 | )); |
|
| 1807 | } |
|
| 1808 | } |
|
| 1809 | ||
| 1810 | /** |
|
| 1811 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| @@ 1843-1850 (lines=8) @@ | ||
| 1840 | * |
|
| 1841 | * @throws InvalidArgumentException |
|
| 1842 | */ |
|
| 1843 | public static function isList($array, $message = '') |
|
| 1844 | { |
|
| 1845 | if (!\is_array($array) || $array !== \array_values($array)) { |
|
| 1846 | static::reportInvalidArgument( |
|
| 1847 | $message ?: 'Expected list - non-associative array.' |
|
| 1848 | ); |
|
| 1849 | } |
|
| 1850 | } |
|
| 1851 | ||
| 1852 | /** |
|
| 1853 | * @psalm-pure |
|