@@ 1582-1590 (lines=9) @@ | ||
1579 | * |
|
1580 | * @throws InvalidArgumentException |
|
1581 | */ |
|
1582 | public static function keyExists($array, $key, $message = '') |
|
1583 | { |
|
1584 | if (!(isset($array[$key]) || \array_key_exists($key, $array))) { |
|
1585 | static::reportInvalidArgument(\sprintf( |
|
1586 | $message ?: 'Expected the key %s to exist.', |
|
1587 | static::valueToString($key) |
|
1588 | )); |
|
1589 | } |
|
1590 | } |
|
1591 | ||
1592 | /** |
|
1593 | * @param array $array |
|
@@ 1599-1607 (lines=9) @@ | ||
1596 | * |
|
1597 | * @throws InvalidArgumentException |
|
1598 | */ |
|
1599 | public static function keyNotExists($array, $key, $message = '') |
|
1600 | { |
|
1601 | if (isset($array[$key]) || \array_key_exists($key, $array)) { |
|
1602 | static::reportInvalidArgument(\sprintf( |
|
1603 | $message ?: 'Expected the key %s to not exist.', |
|
1604 | static::valueToString($key) |
|
1605 | )); |
|
1606 | } |
|
1607 | } |
|
1608 | ||
1609 | /** |
|
1610 | * Checks if a value is a valid array key (int or string). |