| @@ 1860-1868 (lines=9) @@ | ||
| 1857 | * |
|
| 1858 | * @throws InvalidArgumentException |
|
| 1859 | */ |
|
| 1860 | public static function keyExists($array, $key, $message = '') |
|
| 1861 | { |
|
| 1862 | if (!(isset($array[$key]) || \array_key_exists($key, $array))) { |
|
| 1863 | static::reportInvalidArgument(\sprintf( |
|
| 1864 | $message ?: 'Expected the key %s to exist.', |
|
| 1865 | static::valueToString($key) |
|
| 1866 | )); |
|
| 1867 | } |
|
| 1868 | } |
|
| 1869 | ||
| 1870 | /** |
|
| 1871 | * @psalm-pure |
|
| @@ 1879-1887 (lines=9) @@ | ||
| 1876 | * |
|
| 1877 | * @throws InvalidArgumentException |
|
| 1878 | */ |
|
| 1879 | public static function keyNotExists($array, $key, $message = '') |
|
| 1880 | { |
|
| 1881 | if (isset($array[$key]) || \array_key_exists($key, $array)) { |
|
| 1882 | static::reportInvalidArgument(\sprintf( |
|
| 1883 | $message ?: 'Expected the key %s to not exist.', |
|
| 1884 | static::valueToString($key) |
|
| 1885 | )); |
|
| 1886 | } |
|
| 1887 | } |
|
| 1888 | ||
| 1889 | /** |
|
| 1890 | * Checks if a value is a valid array key (int or string). |
|