| @@ 1896-1905 (lines=10) @@ | ||
| 1893 | * |
|
| 1894 | * @throws InvalidArgumentException |
|
| 1895 | */ |
|
| 1896 | public static function minCount($array, $min, $message = '') |
|
| 1897 | { |
|
| 1898 | if (\count($array) < $min) { |
|
| 1899 | static::reportInvalidArgument(\sprintf( |
|
| 1900 | $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
| 1901 | \count($array), |
|
| 1902 | $min |
|
| 1903 | )); |
|
| 1904 | } |
|
| 1905 | } |
|
| 1906 | ||
| 1907 | /** |
|
| 1908 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| @@ 1916-1925 (lines=10) @@ | ||
| 1913 | * |
|
| 1914 | * @throws InvalidArgumentException |
|
| 1915 | */ |
|
| 1916 | public static function maxCount($array, $max, $message = '') |
|
| 1917 | { |
|
| 1918 | if (\count($array) > $max) { |
|
| 1919 | static::reportInvalidArgument(\sprintf( |
|
| 1920 | $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
| 1921 | \count($array), |
|
| 1922 | $max |
|
| 1923 | )); |
|
| 1924 | } |
|
| 1925 | } |
|
| 1926 | ||
| 1927 | /** |
|
| 1928 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| @@ 1960-1967 (lines=8) @@ | ||
| 1957 | * |
|
| 1958 | * @throws InvalidArgumentException |
|
| 1959 | */ |
|
| 1960 | public static function isList($array, $message = '') |
|
| 1961 | { |
|
| 1962 | if (!\is_array($array) || $array !== \array_values($array)) { |
|
| 1963 | static::reportInvalidArgument( |
|
| 1964 | $message ?: 'Expected list - non-associative array.' |
|
| 1965 | ); |
|
| 1966 | } |
|
| 1967 | } |
|
| 1968 | ||
| 1969 | /** |
|
| 1970 | * @psalm-pure |
|