@@ 1563-1571 (lines=9) @@ | ||
1560 | * |
|
1561 | * @throws InvalidArgumentException |
|
1562 | */ |
|
1563 | public static function keyExists($array, $key, $message = '') |
|
1564 | { |
|
1565 | if (!(isset($array[$key]) || \array_key_exists($key, $array))) { |
|
1566 | static::reportInvalidArgument(\sprintf( |
|
1567 | $message ?: 'Expected the key %s to exist.', |
|
1568 | static::valueToString($key) |
|
1569 | )); |
|
1570 | } |
|
1571 | } |
|
1572 | ||
1573 | /** |
|
1574 | * @param array $array |
|
@@ 1580-1588 (lines=9) @@ | ||
1577 | * |
|
1578 | * @throws InvalidArgumentException |
|
1579 | */ |
|
1580 | public static function keyNotExists($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 not exist.', |
|
1585 | static::valueToString($key) |
|
1586 | )); |
|
1587 | } |
|
1588 | } |
|
1589 | ||
1590 | /** |
|
1591 | * Checks if a value is a valid array key (int or string). |