private function getResourceUri($resource)
{
if (!is_string($resource)) {
throw new InvalidArgumentException(sprintf("\$resource must be of type string, %s given.", gettype($resource)));
}
// ACME MUST be served over HTTPS, but we use HTTP for testing …
if (substr($resource, 0, 7) === "http://" || substr($resource, 0, 8) === "https://") {
return new Success($resource);
}
if (!$this->directory) {
return \Amp\pipe(\Amp\resolve($this->fetchDirectory()), function () use($resource) {
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}'."));
}