| @@ 1656-1665 (lines=10) @@ | ||
| 1653 | * | |
| 1654 | * @throws InvalidArgumentException | |
| 1655 | */ | |
| 1656 | public static function minCount($array, $min, $message = '') | |
| 1657 |     { | |
| 1658 |         if (\count($array) < $min) { | |
| 1659 | static::reportInvalidArgument(\sprintf( | |
| 1660 | $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', | |
| 1661 | \count($array), | |
| 1662 | $min | |
| 1663 | )); | |
| 1664 | } | |
| 1665 | } | |
| 1666 | ||
| 1667 | /** | |
| 1668 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. | |
| @@ 1676-1685 (lines=10) @@ | ||
| 1673 | * | |
| 1674 | * @throws InvalidArgumentException | |
| 1675 | */ | |
| 1676 | public static function maxCount($array, $max, $message = '') | |
| 1677 |     { | |
| 1678 |         if (\count($array) > $max) { | |
| 1679 | static::reportInvalidArgument(\sprintf( | |
| 1680 | $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', | |
| 1681 | \count($array), | |
| 1682 | $max | |
| 1683 | )); | |
| 1684 | } | |
| 1685 | } | |
| 1686 | ||
| 1687 | /** | |
| 1688 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. | |
| @@ 1719-1726 (lines=8) @@ | ||
| 1716 | * | |
| 1717 | * @throws InvalidArgumentException | |
| 1718 | */ | |
| 1719 | public static function isList($array, $message = '') | |
| 1720 |     { | |
| 1721 |         if (!\is_array($array) || $array !== \array_values($array)) { | |
| 1722 | static::reportInvalidArgument( | |
| 1723 | $message ?: 'Expected list - non-associative array.' | |
| 1724 | ); | |
| 1725 | } | |
| 1726 | } | |
| 1727 | ||
| 1728 | /** | |
| 1729 | * @psalm-assert non-empty-list $array | |