| @@ 1921-1930 (lines=10) @@ | ||
| 1918 | * |
|
| 1919 | * @throws InvalidArgumentException |
|
| 1920 | */ |
|
| 1921 | public static function minCount($array, $min, $message = '') |
|
| 1922 | { |
|
| 1923 | if (\count($array) < $min) { |
|
| 1924 | static::reportInvalidArgument(\sprintf( |
|
| 1925 | $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
| 1926 | \count($array), |
|
| 1927 | $min |
|
| 1928 | )); |
|
| 1929 | } |
|
| 1930 | } |
|
| 1931 | ||
| 1932 | /** |
|
| 1933 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| @@ 1941-1950 (lines=10) @@ | ||
| 1938 | * |
|
| 1939 | * @throws InvalidArgumentException |
|
| 1940 | */ |
|
| 1941 | public static function maxCount($array, $max, $message = '') |
|
| 1942 | { |
|
| 1943 | if (\count($array) > $max) { |
|
| 1944 | static::reportInvalidArgument(\sprintf( |
|
| 1945 | $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
| 1946 | \count($array), |
|
| 1947 | $max |
|
| 1948 | )); |
|
| 1949 | } |
|
| 1950 | } |
|
| 1951 | ||
| 1952 | /** |
|
| 1953 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| @@ 1985-1992 (lines=8) @@ | ||
| 1982 | * |
|
| 1983 | * @throws InvalidArgumentException |
|
| 1984 | */ |
|
| 1985 | public static function isList($array, $message = '') |
|
| 1986 | { |
|
| 1987 | if (!\is_array($array) || $array !== \array_values($array)) { |
|
| 1988 | static::reportInvalidArgument( |
|
| 1989 | $message ?: 'Expected list - non-associative array.' |
|
| 1990 | ); |
|
| 1991 | } |
|
| 1992 | } |
|
| 1993 | ||
| 1994 | /** |
|
| 1995 | * @psalm-pure |
|