src/Alhames/Api/HttpClient.php
public function request(string $method, string $uri, array $options = []): ResponseInterface
    {
        if (null !== $this->qps && null !== $this->lastRequestTime) {
            $lastInterval = floor((microtime(true) - $this->lastRequestTime) * 1000000);
            $timeout = ceil(1000000 / $this->qps);
            if ($lastInterval < $timeout) {
                usleep($timeout - $lastInterval);
            }
        }

        try {
            $response = $this->client->request($method, $uri, $options);
        } catch (RequestException $e) {
            $response = $e->getResponse();
            throw $e;
        } finally {
            $this->lastRequestTime = microtime(true);
            if (null !== $this->logger) {
                $statusCode = !empty($response) ? $response->getStatusCode() : 0;
                $this->logger->debug(sprintf('"%s %s" %d', $method, $uri, $statusCode), [
                    'method' => $method,
                    'uri' => $uri,
                    'options' => $options,
                    'time' => $this->lastRequestTime,
                    'response' => $response ?? null,
                ]);
            }
        }

        return $response;
    }
public function request(string $method, string $uri, array $options = []): ResponseInterface
    {
        if (null !== $this->qps && null !== $this->lastRequestTime) {
            $lastInterval = floor((microtime(true) - $this->lastRequestTime) * 1000000);
            $timeout = ceil(1000000 / $this->qps);
            if ($lastInterval < $timeout) {
                usleep($timeout - $lastInterval);
            }
        }

        try {
            $response = $this->client->request($method, $uri, $options);
        } catch (RequestException $e) {
            $response = $e->getResponse();
            throw $e;
        } finally {
            $this->lastRequestTime = microtime(true);
            if (null !== $this->logger) {
                $statusCode = !empty($response) ? $response->getStatusCode() : 0;
                $this->logger->debug(sprintf('"%s %s" %d', $method, $uri, $statusCode), [
                    'method' => $method,
                    'uri' => $uri,
                    'options' => $options,
                    'time' => $this->lastRequestTime,
                    'response' => $response ?? null,
                ]);
            }
        }

        return $response;
    }
@param string $method
@param string $uri
@param array  $options

@throws GuzzleException

@return ResponseInterface