@@ 1572-1580 (lines=9) @@ | ||
1569 | * |
|
1570 | * @throws InvalidArgumentException |
|
1571 | */ |
|
1572 | public static function keyExists($array, $key, $message = '') |
|
1573 | { |
|
1574 | if (!(isset($array[$key]) || \array_key_exists($key, $array))) { |
|
1575 | static::reportInvalidArgument(\sprintf( |
|
1576 | $message ?: 'Expected the key %s to exist.', |
|
1577 | static::valueToString($key) |
|
1578 | )); |
|
1579 | } |
|
1580 | } |
|
1581 | ||
1582 | /** |
|
1583 | * @param array $array |
|
@@ 1589-1597 (lines=9) @@ | ||
1586 | * |
|
1587 | * @throws InvalidArgumentException |
|
1588 | */ |
|
1589 | public static function keyNotExists($array, $key, $message = '') |
|
1590 | { |
|
1591 | if (isset($array[$key]) || \array_key_exists($key, $array)) { |
|
1592 | static::reportInvalidArgument(\sprintf( |
|
1593 | $message ?: 'Expected the key %s to not exist.', |
|
1594 | static::valueToString($key) |
|
1595 | )); |
|
1596 | } |
|
1597 | } |
|
1598 | ||
1599 | /** |
|
1600 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |