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