| @@ 1641-1650 (lines=10) @@ | ||
| 1638 | * |
|
| 1639 | * @throws InvalidArgumentException |
|
| 1640 | */ |
|
| 1641 | public static function minCount($array, $min, $message = '') |
|
| 1642 | { |
|
| 1643 | if (\count($array) < $min) { |
|
| 1644 | static::reportInvalidArgument(\sprintf( |
|
| 1645 | $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
| 1646 | \count($array), |
|
| 1647 | $min |
|
| 1648 | )); |
|
| 1649 | } |
|
| 1650 | } |
|
| 1651 | ||
| 1652 | /** |
|
| 1653 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| @@ 1661-1670 (lines=10) @@ | ||
| 1658 | * |
|
| 1659 | * @throws InvalidArgumentException |
|
| 1660 | */ |
|
| 1661 | public static function maxCount($array, $max, $message = '') |
|
| 1662 | { |
|
| 1663 | if (\count($array) > $max) { |
|
| 1664 | static::reportInvalidArgument(\sprintf( |
|
| 1665 | $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
| 1666 | \count($array), |
|
| 1667 | $max |
|
| 1668 | )); |
|
| 1669 | } |
|
| 1670 | } |
|
| 1671 | ||
| 1672 | /** |
|
| 1673 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| @@ 1704-1711 (lines=8) @@ | ||
| 1701 | * |
|
| 1702 | * @throws InvalidArgumentException |
|
| 1703 | */ |
|
| 1704 | public static function isList($array, $message = '') |
|
| 1705 | { |
|
| 1706 | if (!\is_array($array) || $array !== \array_values($array)) { |
|
| 1707 | static::reportInvalidArgument( |
|
| 1708 | $message ?: 'Expected list - non-associative array.' |
|
| 1709 | ); |
|
| 1710 | } |
|
| 1711 | } |
|
| 1712 | ||
| 1713 | /** |
|
| 1714 | * @psalm-assert non-empty-list $array |
|