@@ 1773-1781 (lines=9) @@ | ||
1770 | * |
|
1771 | * @throws InvalidArgumentException |
|
1772 | */ |
|
1773 | public static function keyExists($array, $key, $message = '') |
|
1774 | { |
|
1775 | if (!(isset($array[$key]) || \array_key_exists($key, $array))) { |
|
1776 | static::reportInvalidArgument(\sprintf( |
|
1777 | $message ?: 'Expected the key %s to exist.', |
|
1778 | static::valueToString($key) |
|
1779 | )); |
|
1780 | } |
|
1781 | } |
|
1782 | ||
1783 | /** |
|
1784 | * @psalm-pure |
|
@@ 1792-1800 (lines=9) @@ | ||
1789 | * |
|
1790 | * @throws InvalidArgumentException |
|
1791 | */ |
|
1792 | public static function keyNotExists($array, $key, $message = '') |
|
1793 | { |
|
1794 | if (isset($array[$key]) || \array_key_exists($key, $array)) { |
|
1795 | static::reportInvalidArgument(\sprintf( |
|
1796 | $message ?: 'Expected the key %s to not exist.', |
|
1797 | static::valueToString($key) |
|
1798 | )); |
|
1799 | } |
|
1800 | } |
|
1801 | ||
1802 | /** |
|
1803 | * Checks if a value is a valid array key (int or string). |