lib/AcmeClient.php
private function fetchDirectory(): Promise {
        return call(function () {
            try {
                $this->logger->debug('Fetching directory from {uri}', [
                    'uri' => $this->directoryUri
                ]);

                /** @var Response $response */
                $response = yield $this->http->request($this->directoryUri);
                $directory = json_decode(yield $response->getBody(), true);

                if ($response->getStatus() !== 200) {
                    $error = $directory;

                    if (isset($error['type'], $error['detail'])) {
                        throw new AcmeException("Invalid directory response: {$error['detail']}", $error['type']);
                    }

                    throw new AcmeException('Invalid directory response. HTTP response code: ' . $response->getStatus());
                }

                if (empty($directory)) {
                    throw new AcmeException('Invalid empty directory.');
                }

                $this->directory = $directory;
                $this->saveNonce($response);
            } catch (Throwable $e) {
                throw new AcmeException('Could not obtain directory: ' . $e->getMessage(), null, $e);
            }
        });
    }
private function fetchDirectory(): Promise {
        return call(function () {
            try {
                $this->logger->debug('Fetching directory from {uri}', [
                    'uri' => $this->directoryUri
                ]);

                /** @var Response $response */
                $response = yield $this->http->request($this->directoryUri);
                $directory = json_decode(yield $response->getBody(), true);

                if ($response->getStatus() !== 200) {
                    $error = $directory;

                    if (isset($error['type'], $error['detail'])) {
                        throw new AcmeException("Invalid directory response: {$error['detail']}", $error['type']);
                    }

                    throw new AcmeException('Invalid directory response. HTTP response code: ' . $response->getStatus());
                }

                if (empty($directory)) {
                    throw new AcmeException('Invalid empty directory.');
                }

                $this->directory = $directory;
                $this->saveNonce($response);
            } catch (Throwable $e) {
                throw new AcmeException('Could not obtain directory: ' . $e->getMessage(), null, $e);
            }
        });
    }
private function fetchDirectory ( ) : Promise { return call ( function ( ) { try { $ this -> logger -> debug ( 'Fetching directory from {uri}' , [ 'uri' => $ this -> directoryUri ] ) ; /** @var Response $response */ $ response = yield $ this -> http -> request ( $ this -> directoryUri ) ; $ directory = json_decode ( yield $ response -> getBody ( ) , true ) ; if ( $ response -> getStatus ( ) !== 200 ) { $ error = $ directory ; if ( isset ( $ error [ 'type' ] , $ error [ 'detail' ] ) ) { throw new AcmeException ( "Invalid directory response: {$error['detail']}" , $ error [ 'type' ] ) ; } throw new AcmeException ( 'Invalid directory response. HTTP response code: ' . $ response -> getStatus ( ) ) ; } if ( empty ( $ directory ) ) { throw new AcmeException ( 'Invalid empty directory.' ) ; } $ this -> directory = $ directory ; $ this -> saveNonce ( $ response ) ; } catch ( Throwable $ e ) { throw new AcmeException ( 'Could not obtain directory: ' . $ e -> getMessage ( ) , null , $ e ) ; } } ) ; }
Retrieves the directory and stores it in the directory property.

@return Promise Resolves once the directory is fetched.
@throws AcmeException If the directory could not be fetched or was invalid.
Retrieves the directory and stores it in the directory property .