@@ 1805-1814 (lines=10) @@ | ||
1802 | * |
|
1803 | * @throws InvalidArgumentException |
|
1804 | */ |
|
1805 | public static function minCount($array, $min, $message = '') |
|
1806 | { |
|
1807 | if (\count($array) < $min) { |
|
1808 | static::reportInvalidArgument(\sprintf( |
|
1809 | $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
1810 | \count($array), |
|
1811 | $min |
|
1812 | )); |
|
1813 | } |
|
1814 | } |
|
1815 | ||
1816 | /** |
|
1817 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
@@ 1825-1834 (lines=10) @@ | ||
1822 | * |
|
1823 | * @throws InvalidArgumentException |
|
1824 | */ |
|
1825 | public static function maxCount($array, $max, $message = '') |
|
1826 | { |
|
1827 | if (\count($array) > $max) { |
|
1828 | static::reportInvalidArgument(\sprintf( |
|
1829 | $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
1830 | \count($array), |
|
1831 | $max |
|
1832 | )); |
|
1833 | } |
|
1834 | } |
|
1835 | ||
1836 | /** |
|
1837 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
@@ 1869-1876 (lines=8) @@ | ||
1866 | * |
|
1867 | * @throws InvalidArgumentException |
|
1868 | */ |
|
1869 | public static function isList($array, $message = '') |
|
1870 | { |
|
1871 | if (!\is_array($array) || $array !== \array_values($array)) { |
|
1872 | static::reportInvalidArgument( |
|
1873 | $message ?: 'Expected list - non-associative array.' |
|
1874 | ); |
|
1875 | } |
|
1876 | } |
|
1877 | ||
1878 | /** |
|
1879 | * @psalm-pure |