@@ 1819-1827 (lines=9) @@ | ||
1816 | * |
|
1817 | * @throws InvalidArgumentException |
|
1818 | */ |
|
1819 | public static function keyExists($array, $key, $message = '') |
|
1820 | { |
|
1821 | if (!(isset($array[$key]) || \array_key_exists($key, $array))) { |
|
1822 | static::reportInvalidArgument(\sprintf( |
|
1823 | $message ?: 'Expected the key %s to exist.', |
|
1824 | static::valueToString($key) |
|
1825 | )); |
|
1826 | } |
|
1827 | } |
|
1828 | ||
1829 | /** |
|
1830 | * @psalm-pure |
|
@@ 1838-1846 (lines=9) @@ | ||
1835 | * |
|
1836 | * @throws InvalidArgumentException |
|
1837 | */ |
|
1838 | public static function keyNotExists($array, $key, $message = '') |
|
1839 | { |
|
1840 | if (isset($array[$key]) || \array_key_exists($key, $array)) { |
|
1841 | static::reportInvalidArgument(\sprintf( |
|
1842 | $message ?: 'Expected the key %s to not exist.', |
|
1843 | static::valueToString($key) |
|
1844 | )); |
|
1845 | } |
|
1846 | } |
|
1847 | ||
1848 | /** |
|
1849 | * Checks if a value is a valid array key (int or string). |