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