@@ 1840-1848 (lines=9) @@ | ||
1837 | * |
|
1838 | * @throws InvalidArgumentException |
|
1839 | */ |
|
1840 | public static function keyExists($array, $key, $message = '') |
|
1841 | { |
|
1842 | if (!(isset($array[$key]) || \array_key_exists($key, $array))) { |
|
1843 | static::reportInvalidArgument(\sprintf( |
|
1844 | $message ?: 'Expected the key %s to exist.', |
|
1845 | static::valueToString($key) |
|
1846 | )); |
|
1847 | } |
|
1848 | } |
|
1849 | ||
1850 | /** |
|
1851 | * @psalm-pure |
|
@@ 1859-1867 (lines=9) @@ | ||
1856 | * |
|
1857 | * @throws InvalidArgumentException |
|
1858 | */ |
|
1859 | public static function keyNotExists($array, $key, $message = '') |
|
1860 | { |
|
1861 | if (isset($array[$key]) || \array_key_exists($key, $array)) { |
|
1862 | static::reportInvalidArgument(\sprintf( |
|
1863 | $message ?: 'Expected the key %s to not exist.', |
|
1864 | static::valueToString($key) |
|
1865 | )); |
|
1866 | } |
|
1867 | } |
|
1868 | ||
1869 | /** |
|
1870 | * Checks if a value is a valid array key (int or string). |