@@ 1872-1881 (lines=10) @@ | ||
1869 | * |
|
1870 | * @throws InvalidArgumentException |
|
1871 | */ |
|
1872 | public static function minCount($array, $min, $message = '') |
|
1873 | { |
|
1874 | if (\count($array) < $min) { |
|
1875 | static::reportInvalidArgument(\sprintf( |
|
1876 | $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
1877 | \count($array), |
|
1878 | $min |
|
1879 | )); |
|
1880 | } |
|
1881 | } |
|
1882 | ||
1883 | /** |
|
1884 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
@@ 1892-1901 (lines=10) @@ | ||
1889 | * |
|
1890 | * @throws InvalidArgumentException |
|
1891 | */ |
|
1892 | public static function maxCount($array, $max, $message = '') |
|
1893 | { |
|
1894 | if (\count($array) > $max) { |
|
1895 | static::reportInvalidArgument(\sprintf( |
|
1896 | $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
1897 | \count($array), |
|
1898 | $max |
|
1899 | )); |
|
1900 | } |
|
1901 | } |
|
1902 | ||
1903 | /** |
|
1904 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
@@ 1936-1943 (lines=8) @@ | ||
1933 | * |
|
1934 | * @throws InvalidArgumentException |
|
1935 | */ |
|
1936 | public static function isList($array, $message = '') |
|
1937 | { |
|
1938 | if (!\is_array($array) || $array !== \array_values($array)) { |
|
1939 | static::reportInvalidArgument( |
|
1940 | $message ?: 'Expected list - non-associative array.' |
|
1941 | ); |
|
1942 | } |
|
1943 | } |
|
1944 | ||
1945 | /** |
|
1946 | * @psalm-pure |