| @@ 1880-1888 (lines=9) @@ | ||
| 1877 | * |
|
| 1878 | * @throws InvalidArgumentException |
|
| 1879 | */ |
|
| 1880 | public static function keyExists($array, $key, $message = '') |
|
| 1881 | { |
|
| 1882 | if (!(isset($array[$key]) || \array_key_exists($key, $array))) { |
|
| 1883 | static::reportInvalidArgument(\sprintf( |
|
| 1884 | $message ?: 'Expected the key %s to exist.', |
|
| 1885 | static::valueToString($key) |
|
| 1886 | )); |
|
| 1887 | } |
|
| 1888 | } |
|
| 1889 | ||
| 1890 | /** |
|
| 1891 | * @psalm-pure |
|
| @@ 1899-1907 (lines=9) @@ | ||
| 1896 | * |
|
| 1897 | * @throws InvalidArgumentException |
|
| 1898 | */ |
|
| 1899 | public static function keyNotExists($array, $key, $message = '') |
|
| 1900 | { |
|
| 1901 | if (isset($array[$key]) || \array_key_exists($key, $array)) { |
|
| 1902 | static::reportInvalidArgument(\sprintf( |
|
| 1903 | $message ?: 'Expected the key %s to not exist.', |
|
| 1904 | static::valueToString($key) |
|
| 1905 | )); |
|
| 1906 | } |
|
| 1907 | } |
|
| 1908 | ||
| 1909 | /** |
|
| 1910 | * Checks if a value is a valid array key (int or string). |
|