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