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