| @@ 1660-1668 (lines=9) @@ | ||
| 1657 | * |
|
| 1658 | * @throws InvalidArgumentException |
|
| 1659 | */ |
|
| 1660 | public static function keyExists($array, $key, $message = '') |
|
| 1661 | { |
|
| 1662 | if (!(isset($array[$key]) || \array_key_exists($key, $array))) { |
|
| 1663 | static::reportInvalidArgument(\sprintf( |
|
| 1664 | $message ?: 'Expected the key %s to exist.', |
|
| 1665 | static::valueToString($key) |
|
| 1666 | )); |
|
| 1667 | } |
|
| 1668 | } |
|
| 1669 | ||
| 1670 | /** |
|
| 1671 | * @psalm-pure |
|
| @@ 1679-1687 (lines=9) @@ | ||
| 1676 | * |
|
| 1677 | * @throws InvalidArgumentException |
|
| 1678 | */ |
|
| 1679 | public static function keyNotExists($array, $key, $message = '') |
|
| 1680 | { |
|
| 1681 | if (isset($array[$key]) || \array_key_exists($key, $array)) { |
|
| 1682 | static::reportInvalidArgument(\sprintf( |
|
| 1683 | $message ?: 'Expected the key %s to not exist.', |
|
| 1684 | static::valueToString($key) |
|
| 1685 | )); |
|
| 1686 | } |
|
| 1687 | } |
|
| 1688 | ||
| 1689 | /** |
|
| 1690 | * Checks if a value is a valid array key (int or string). |
|