| @@ 1866-1875 (lines=10) @@ | ||
| 1863 | * |
|
| 1864 | * @throws InvalidArgumentException |
|
| 1865 | */ |
|
| 1866 | public static function minCount($array, $min, $message = '') |
|
| 1867 | { |
|
| 1868 | if (\count($array) < $min) { |
|
| 1869 | static::reportInvalidArgument(\sprintf( |
|
| 1870 | $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
| 1871 | \count($array), |
|
| 1872 | $min |
|
| 1873 | )); |
|
| 1874 | } |
|
| 1875 | } |
|
| 1876 | ||
| 1877 | /** |
|
| 1878 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| @@ 1886-1895 (lines=10) @@ | ||
| 1883 | * |
|
| 1884 | * @throws InvalidArgumentException |
|
| 1885 | */ |
|
| 1886 | public static function maxCount($array, $max, $message = '') |
|
| 1887 | { |
|
| 1888 | if (\count($array) > $max) { |
|
| 1889 | static::reportInvalidArgument(\sprintf( |
|
| 1890 | $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
| 1891 | \count($array), |
|
| 1892 | $max |
|
| 1893 | )); |
|
| 1894 | } |
|
| 1895 | } |
|
| 1896 | ||
| 1897 | /** |
|
| 1898 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| @@ 1930-1937 (lines=8) @@ | ||
| 1927 | * |
|
| 1928 | * @throws InvalidArgumentException |
|
| 1929 | */ |
|
| 1930 | public static function isList($array, $message = '') |
|
| 1931 | { |
|
| 1932 | if (!\is_array($array) || $array !== \array_values($array)) { |
|
| 1933 | static::reportInvalidArgument( |
|
| 1934 | $message ?: 'Expected list - non-associative array.' |
|
| 1935 | ); |
|
| 1936 | } |
|
| 1937 | } |
|
| 1938 | ||
| 1939 | /** |
|
| 1940 | * @psalm-pure |
|