| @@ 1791-1799 (lines=9) @@ | ||
| 1788 | * |
|
| 1789 | * @throws InvalidArgumentException |
|
| 1790 | */ |
|
| 1791 | public static function keyExists($array, $key, $message = '') |
|
| 1792 | { |
|
| 1793 | if (!(isset($array[$key]) || \array_key_exists($key, $array))) { |
|
| 1794 | static::reportInvalidArgument(\sprintf( |
|
| 1795 | $message ?: 'Expected the key %s to exist.', |
|
| 1796 | static::valueToString($key) |
|
| 1797 | )); |
|
| 1798 | } |
|
| 1799 | } |
|
| 1800 | ||
| 1801 | /** |
|
| 1802 | * @psalm-pure |
|
| @@ 1810-1818 (lines=9) @@ | ||
| 1807 | * |
|
| 1808 | * @throws InvalidArgumentException |
|
| 1809 | */ |
|
| 1810 | public static function keyNotExists($array, $key, $message = '') |
|
| 1811 | { |
|
| 1812 | if (isset($array[$key]) || \array_key_exists($key, $array)) { |
|
| 1813 | static::reportInvalidArgument(\sprintf( |
|
| 1814 | $message ?: 'Expected the key %s to not exist.', |
|
| 1815 | static::valueToString($key) |
|
| 1816 | )); |
|
| 1817 | } |
|
| 1818 | } |
|
| 1819 | ||
| 1820 | /** |
|
| 1821 | * Checks if a value is a valid array key (int or string). |
|