/** * {@inheritdoc} */ public function execute(QueryInterface $query) : ResultInterface { $this->dispatcher->dispatch(Events::PRE_QUERY, new PreQueryEvent($query)); $response = $this->http->send($this->translator->translate($query)); if (!$this->isSuccessful($response)) { throw QueryException::failed($query, $response); } $response = json_decode((string) $response->getBody(), true); $result = Result::fromRaw($response['results'][0] ?? []); $this->dispatcher->dispatch(Events::POST_QUERY, new PostQueryEvent($query, $result)); return $result; }