| @@ 1414-1422 (lines=9) @@ | ||
| 1411 | * @param string|int $key |
|
| 1412 | * @param string $message |
|
| 1413 | */ |
|
| 1414 | public static function keyExists($array, $key, $message = '') |
|
| 1415 | { |
|
| 1416 | if (!(isset($array[$key]) || \array_key_exists($key, $array))) { |
|
| 1417 | static::reportInvalidArgument(\sprintf( |
|
| 1418 | $message ?: 'Expected the key %s to exist.', |
|
| 1419 | static::valueToString($key) |
|
| 1420 | )); |
|
| 1421 | } |
|
| 1422 | } |
|
| 1423 | ||
| 1424 | /** |
|
| 1425 | * @param array $array |
|
| @@ 1429-1437 (lines=9) @@ | ||
| 1426 | * @param string|int $key |
|
| 1427 | * @param string $message |
|
| 1428 | */ |
|
| 1429 | public static function keyNotExists($array, $key, $message = '') |
|
| 1430 | { |
|
| 1431 | if (isset($array[$key]) || \array_key_exists($key, $array)) { |
|
| 1432 | static::reportInvalidArgument(\sprintf( |
|
| 1433 | $message ?: 'Expected the key %s to not exist.', |
|
| 1434 | static::valueToString($key) |
|
| 1435 | )); |
|
| 1436 | } |
|
| 1437 | } |
|
| 1438 | ||
| 1439 | /** |
|
| 1440 | * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|