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