@@ 1461-1469 (lines=9) @@ | ||
1458 | * @param string|int $key |
|
1459 | * @param string $message |
|
1460 | */ |
|
1461 | public static function keyExists($array, $key, $message = '') |
|
1462 | { |
|
1463 | if (!(isset($array[$key]) || \array_key_exists($key, $array))) { |
|
1464 | static::reportInvalidArgument(\sprintf( |
|
1465 | $message ?: 'Expected the key %s to exist.', |
|
1466 | static::valueToString($key) |
|
1467 | )); |
|
1468 | } |
|
1469 | } |
|
1470 | ||
1471 | /** |
|
1472 | * @param array $array |
|
@@ 1476-1484 (lines=9) @@ | ||
1473 | * @param string|int $key |
|
1474 | * @param string $message |
|
1475 | */ |
|
1476 | public static function keyNotExists($array, $key, $message = '') |
|
1477 | { |
|
1478 | if (isset($array[$key]) || \array_key_exists($key, $array)) { |
|
1479 | static::reportInvalidArgument(\sprintf( |
|
1480 | $message ?: 'Expected the key %s to not exist.', |
|
1481 | static::valueToString($key) |
|
1482 | )); |
|
1483 | } |
|
1484 | } |
|
1485 | ||
1486 | /** |
|
1487 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |