@@ 1720-1728 (lines=9) @@ | ||
1717 | * |
|
1718 | * @throws InvalidArgumentException |
|
1719 | */ |
|
1720 | public static function keyExists($array, $key, $message = '') |
|
1721 | { |
|
1722 | if (!(isset($array[$key]) || \array_key_exists($key, $array))) { |
|
1723 | static::reportInvalidArgument(\sprintf( |
|
1724 | $message ?: 'Expected the key %s to exist.', |
|
1725 | static::valueToString($key) |
|
1726 | )); |
|
1727 | } |
|
1728 | } |
|
1729 | ||
1730 | /** |
|
1731 | * @psalm-pure |
|
@@ 1739-1747 (lines=9) @@ | ||
1736 | * |
|
1737 | * @throws InvalidArgumentException |
|
1738 | */ |
|
1739 | public static function keyNotExists($array, $key, $message = '') |
|
1740 | { |
|
1741 | if (isset($array[$key]) || \array_key_exists($key, $array)) { |
|
1742 | static::reportInvalidArgument(\sprintf( |
|
1743 | $message ?: 'Expected the key %s to not exist.', |
|
1744 | static::valueToString($key) |
|
1745 | )); |
|
1746 | } |
|
1747 | } |
|
1748 | ||
1749 | /** |
|
1750 | * Checks if a value is a valid array key (int or string). |