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