| @@ 1612-1620 (lines=9) @@ | ||
| 1609 | * |
|
| 1610 | * @throws InvalidArgumentException |
|
| 1611 | */ |
|
| 1612 | public static function keyExists($array, $key, $message = '') |
|
| 1613 | { |
|
| 1614 | if (!(isset($array[$key]) || \array_key_exists($key, $array))) { |
|
| 1615 | static::reportInvalidArgument(\sprintf( |
|
| 1616 | $message ?: 'Expected the key %s to exist.', |
|
| 1617 | static::valueToString($key) |
|
| 1618 | )); |
|
| 1619 | } |
|
| 1620 | } |
|
| 1621 | ||
| 1622 | /** |
|
| 1623 | * @param array $array |
|
| @@ 1629-1637 (lines=9) @@ | ||
| 1626 | * |
|
| 1627 | * @throws InvalidArgumentException |
|
| 1628 | */ |
|
| 1629 | public static function keyNotExists($array, $key, $message = '') |
|
| 1630 | { |
|
| 1631 | if (isset($array[$key]) || \array_key_exists($key, $array)) { |
|
| 1632 | static::reportInvalidArgument(\sprintf( |
|
| 1633 | $message ?: 'Expected the key %s to not exist.', |
|
| 1634 | static::valueToString($key) |
|
| 1635 | )); |
|
| 1636 | } |
|
| 1637 | } |
|
| 1638 | ||
| 1639 | /** |
|
| 1640 | * Checks if a value is a valid array key (int or string). |
|