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