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