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