lib/AcmeClient.php
private function getResourceUri(string $resource): Promise {
        // ACME MUST be served over HTTPS, but we use HTTP for testing …
        if (0 === strpos($resource, 'http://') || 0 === strpos($resource, 'https://')) {
            return new Success($resource);
        }

        if (!$this->directory) {
            return call(function () use ($resource) {
                yield $this->fetchDirectory();

                return $this->getResourceUri($resource);
            });
        }

        if (isset($this->directory[$resource])) {
            return new Success($this->directory[$resource]);
        }

        return new Failure(new AcmeException("Resource not found in directory: '{$resource}'."));
    }
private function getResourceUri(string $resource): Promise {
        // ACME MUST be served over HTTPS, but we use HTTP for testing …
        if (0 === strpos($resource, 'http://') || 0 === strpos($resource, 'https://')) {
            return new Success($resource);
        }

        if (!$this->directory) {
            return call(function () use ($resource) {
                yield $this->fetchDirectory();

                return $this->getResourceUri($resource);
            });
        }

        if (isset($this->directory[$resource])) {
            return new Success($this->directory[$resource]);
        }

        return new Failure(new AcmeException("Resource not found in directory: '{$resource}'."));
    }
private function getResourceUri ( string $ resource ) : Promise { // ACME MUST be served over HTTPS, but we use HTTP for testing … if ( 0 === strpos ( $ resource , 'http://' ) || 0 === strpos ( $ resource , 'https://' ) ) { return new Success ( $ resource ) ; } if ( ! $ this -> directory ) { return call ( function ( ) use ( $ resource ) { yield $ this -> fetchDirectory ( ) ; return $ this -> getResourceUri ( $ resource ) ; } ) ; } if ( isset ( $ this -> directory [ $ resource ] ) ) { return new Success ( $ this -> directory [ $ resource ] ) ; } return new Failure ( new AcmeException ( "Resource not found in directory: '{$resource}'." ) ) ; }
Returns the URI to a resource by querying the directory. Can also handle URIs and returns them directly.

@param string $resource URI or directory entry.

@return Promise Resolves to the resource URI.
@throws AcmeException If the specified resource is not in the directory.
Returns the URI to a resource by querying the directory . Can also handle URIs and returns them directly .