| @@ 1631-1639 (lines=9) @@ | ||
| 1628 | * |
|
| 1629 | * @throws InvalidArgumentException |
|
| 1630 | */ |
|
| 1631 | public static function keyExists($array, $key, $message = '') |
|
| 1632 | { |
|
| 1633 | if (!(isset($array[$key]) || \array_key_exists($key, $array))) { |
|
| 1634 | static::reportInvalidArgument(\sprintf( |
|
| 1635 | $message ?: 'Expected the key %s to exist.', |
|
| 1636 | static::valueToString($key) |
|
| 1637 | )); |
|
| 1638 | } |
|
| 1639 | } |
|
| 1640 | ||
| 1641 | /** |
|
| 1642 | * @param array $array |
|
| @@ 1648-1656 (lines=9) @@ | ||
| 1645 | * |
|
| 1646 | * @throws InvalidArgumentException |
|
| 1647 | */ |
|
| 1648 | public static function keyNotExists($array, $key, $message = '') |
|
| 1649 | { |
|
| 1650 | if (isset($array[$key]) || \array_key_exists($key, $array)) { |
|
| 1651 | static::reportInvalidArgument(\sprintf( |
|
| 1652 | $message ?: 'Expected the key %s to not exist.', |
|
| 1653 | static::valueToString($key) |
|
| 1654 | )); |
|
| 1655 | } |
|
| 1656 | } |
|
| 1657 | ||
| 1658 | /** |
|
| 1659 | * Checks if a value is a valid array key (int or string). |
|