| @@ 1567-1575 (lines=9) @@ | ||
| 1564 | * |
|
| 1565 | * @throws InvalidArgumentException |
|
| 1566 | */ |
|
| 1567 | public static function keyExists($array, $key, $message = '') |
|
| 1568 | { |
|
| 1569 | if (!(isset($array[$key]) || \array_key_exists($key, $array))) { |
|
| 1570 | static::reportInvalidArgument(\sprintf( |
|
| 1571 | $message ?: 'Expected the key %s to exist.', |
|
| 1572 | static::valueToString($key) |
|
| 1573 | )); |
|
| 1574 | } |
|
| 1575 | } |
|
| 1576 | ||
| 1577 | /** |
|
| 1578 | * @param array $array |
|
| @@ 1584-1592 (lines=9) @@ | ||
| 1581 | * |
|
| 1582 | * @throws InvalidArgumentException |
|
| 1583 | */ |
|
| 1584 | public static function keyNotExists($array, $key, $message = '') |
|
| 1585 | { |
|
| 1586 | if (isset($array[$key]) || \array_key_exists($key, $array)) { |
|
| 1587 | static::reportInvalidArgument(\sprintf( |
|
| 1588 | $message ?: 'Expected the key %s to not exist.', |
|
| 1589 | static::valueToString($key) |
|
| 1590 | )); |
|
| 1591 | } |
|
| 1592 | } |
|
| 1593 | ||
| 1594 | /** |
|
| 1595 | * Checks if a value is a valid array key (int or string). |
|