| @@ 1941-1950 (lines=10) @@ | ||
| 1938 | * |
|
| 1939 | * @throws InvalidArgumentException |
|
| 1940 | */ |
|
| 1941 | public static function minCount($array, $min, $message = '') |
|
| 1942 | { |
|
| 1943 | if (\count($array) < $min) { |
|
| 1944 | static::reportInvalidArgument(\sprintf( |
|
| 1945 | $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
| 1946 | \count($array), |
|
| 1947 | $min |
|
| 1948 | )); |
|
| 1949 | } |
|
| 1950 | } |
|
| 1951 | ||
| 1952 | /** |
|
| 1953 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| @@ 1961-1970 (lines=10) @@ | ||
| 1958 | * |
|
| 1959 | * @throws InvalidArgumentException |
|
| 1960 | */ |
|
| 1961 | public static function maxCount($array, $max, $message = '') |
|
| 1962 | { |
|
| 1963 | if (\count($array) > $max) { |
|
| 1964 | static::reportInvalidArgument(\sprintf( |
|
| 1965 | $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
| 1966 | \count($array), |
|
| 1967 | $max |
|
| 1968 | )); |
|
| 1969 | } |
|
| 1970 | } |
|
| 1971 | ||
| 1972 | /** |
|
| 1973 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| @@ 2005-2012 (lines=8) @@ | ||
| 2002 | * |
|
| 2003 | * @throws InvalidArgumentException |
|
| 2004 | */ |
|
| 2005 | public static function isList($array, $message = '') |
|
| 2006 | { |
|
| 2007 | if (!\is_array($array) || $array !== \array_values($array)) { |
|
| 2008 | static::reportInvalidArgument( |
|
| 2009 | $message ?: 'Expected list - non-associative array.' |
|
| 2010 | ); |
|
| 2011 | } |
|
| 2012 | } |
|
| 2013 | ||
| 2014 | /** |
|
| 2015 | * @psalm-pure |
|