Kelunik\Acme\AcmeClient::fetchDirectory PHP Method

fetchDirectory() private method

Retrieves the directory and stores it in the directory property.
private fetchDirectory ( ) : Generator
return Generator coroutine resolved by Amp.
    private function fetchDirectory()
    {
        try {
            /** @var Response $response */
            $response = (yield $this->http->request($this->directoryUri));
            if ($response->getStatus() !== 200) {
                $info = json_decode($response->getBody());
                if (isset($info->type, $info->detail)) {
                    throw new AcmeException("Invalid directory response: {$info->detail}", $info->type);
                }
                throw new AcmeException("Invalid directory response. HTTP response code: " . $response->getStatus());
            }
            $directory = json_decode($response->getBody(), true);
            if (empty($directory)) {
                throw new AcmeException("Invalid directory: empty!");
            }
            $this->directory = $directory;
            $this->saveNonce($response);
        } catch (Exception $e) {
            throw new AcmeException("Could not obtain directory: " . $e->getMessage(), null, $e);
        } catch (Throwable $e) {
            throw new AcmeException("Could not obtain directory: " . $e->getMessage(), null, $e);
        }
    }