|ElasticsearchResponse $response * @return array */ public static function asArray(array|ElasticsearchResponse $response): array { return is_array($response) ? $response : $response->asArray(); } /** * Execute a HEAD-style Elasticsearch call without throwing on 404. * * @param callable(Client): ElasticsearchResponse $callback */ public static function boolResponse(Client $client, callable $callback): bool { $previousSetting = $client->getResponseException(); $client->setResponseException(false); try { return $callback($client)->asBool(); } finally { $client->setResponseException($previousSetting); } } public static function isNotFound(Throwable $throwable): bool { return $throwable instanceof ClientResponseException && $throwable->getCode() === 404; } }