| @@ 1850-1859 (lines=10) @@ | ||
| 1847 | * |
|
| 1848 | * @throws InvalidArgumentException |
|
| 1849 | */ |
|
| 1850 | public static function minCount($array, $min, $message = '') |
|
| 1851 | { |
|
| 1852 | if (\count($array) < $min) { |
|
| 1853 | static::reportInvalidArgument(\sprintf( |
|
| 1854 | $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
| 1855 | \count($array), |
|
| 1856 | $min |
|
| 1857 | )); |
|
| 1858 | } |
|
| 1859 | } |
|
| 1860 | ||
| 1861 | /** |
|
| 1862 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| @@ 1870-1879 (lines=10) @@ | ||
| 1867 | * |
|
| 1868 | * @throws InvalidArgumentException |
|
| 1869 | */ |
|
| 1870 | public static function maxCount($array, $max, $message = '') |
|
| 1871 | { |
|
| 1872 | if (\count($array) > $max) { |
|
| 1873 | static::reportInvalidArgument(\sprintf( |
|
| 1874 | $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
| 1875 | \count($array), |
|
| 1876 | $max |
|
| 1877 | )); |
|
| 1878 | } |
|
| 1879 | } |
|
| 1880 | ||
| 1881 | /** |
|
| 1882 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| @@ 1914-1921 (lines=8) @@ | ||
| 1911 | * |
|
| 1912 | * @throws InvalidArgumentException |
|
| 1913 | */ |
|
| 1914 | public static function isList($array, $message = '') |
|
| 1915 | { |
|
| 1916 | if (!\is_array($array) || $array !== \array_values($array)) { |
|
| 1917 | static::reportInvalidArgument( |
|
| 1918 | $message ?: 'Expected list - non-associative array.' |
|
| 1919 | ); |
|
| 1920 | } |
|
| 1921 | } |
|
| 1922 | ||
| 1923 | /** |
|
| 1924 | * @psalm-pure |
|