@@ 1726-1735 (lines=10) @@ | ||
1723 | * |
|
1724 | * @throws InvalidArgumentException |
|
1725 | */ |
|
1726 | public static function minCount($array, $min, $message = '') |
|
1727 | { |
|
1728 | if (\count($array) < $min) { |
|
1729 | static::reportInvalidArgument(\sprintf( |
|
1730 | $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
1731 | \count($array), |
|
1732 | $min |
|
1733 | )); |
|
1734 | } |
|
1735 | } |
|
1736 | ||
1737 | /** |
|
1738 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
@@ 1746-1755 (lines=10) @@ | ||
1743 | * |
|
1744 | * @throws InvalidArgumentException |
|
1745 | */ |
|
1746 | public static function maxCount($array, $max, $message = '') |
|
1747 | { |
|
1748 | if (\count($array) > $max) { |
|
1749 | static::reportInvalidArgument(\sprintf( |
|
1750 | $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
1751 | \count($array), |
|
1752 | $max |
|
1753 | )); |
|
1754 | } |
|
1755 | } |
|
1756 | ||
1757 | /** |
|
1758 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
@@ 1789-1796 (lines=8) @@ | ||
1786 | * |
|
1787 | * @throws InvalidArgumentException |
|
1788 | */ |
|
1789 | public static function isList($array, $message = '') |
|
1790 | { |
|
1791 | if (!\is_array($array) || $array !== \array_values($array)) { |
|
1792 | static::reportInvalidArgument( |
|
1793 | $message ?: 'Expected list - non-associative array.' |
|
1794 | ); |
|
1795 | } |
|
1796 | } |
|
1797 | ||
1798 | /** |
|
1799 | * @psalm-assert non-empty-list $array |