@@ 1679-1687 (lines=9) @@ | ||
1676 | * |
|
1677 | * @throws InvalidArgumentException |
|
1678 | */ |
|
1679 | public static function keyExists($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 exist.', |
|
1684 | static::valueToString($key) |
|
1685 | )); |
|
1686 | } |
|
1687 | } |
|
1688 | ||
1689 | /** |
|
1690 | * @psalm-pure |
|
@@ 1698-1706 (lines=9) @@ | ||
1695 | * |
|
1696 | * @throws InvalidArgumentException |
|
1697 | */ |
|
1698 | public static function keyNotExists($array, $key, $message = '') |
|
1699 | { |
|
1700 | if (isset($array[$key]) || \array_key_exists($key, $array)) { |
|
1701 | static::reportInvalidArgument(\sprintf( |
|
1702 | $message ?: 'Expected the key %s to not exist.', |
|
1703 | static::valueToString($key) |
|
1704 | )); |
|
1705 | } |
|
1706 | } |
|
1707 | ||
1708 | /** |
|
1709 | * Checks if a value is a valid array key (int or string). |