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