| @@ 1652-1660 (lines=9) @@ | ||
| 1649 | * |
|
| 1650 | * @throws InvalidArgumentException |
|
| 1651 | */ |
|
| 1652 | public static function keyExists($array, $key, $message = '') |
|
| 1653 | { |
|
| 1654 | if (!(isset($array[$key]) || \array_key_exists($key, $array))) { |
|
| 1655 | static::reportInvalidArgument(\sprintf( |
|
| 1656 | $message ?: 'Expected the key %s to exist.', |
|
| 1657 | static::valueToString($key) |
|
| 1658 | )); |
|
| 1659 | } |
|
| 1660 | } |
|
| 1661 | ||
| 1662 | /** |
|
| 1663 | * @param array $array |
|
| @@ 1669-1677 (lines=9) @@ | ||
| 1666 | * |
|
| 1667 | * @throws InvalidArgumentException |
|
| 1668 | */ |
|
| 1669 | public static function keyNotExists($array, $key, $message = '') |
|
| 1670 | { |
|
| 1671 | if (isset($array[$key]) || \array_key_exists($key, $array)) { |
|
| 1672 | static::reportInvalidArgument(\sprintf( |
|
| 1673 | $message ?: 'Expected the key %s to not exist.', |
|
| 1674 | static::valueToString($key) |
|
| 1675 | )); |
|
| 1676 | } |
|
| 1677 | } |
|
| 1678 | ||
| 1679 | /** |
|
| 1680 | * Checks if a value is a valid array key (int or string). |
|