/** * @param string $keyId * * @return string * @throws DownloadFailedException */ public function download($keyId) { $params = ['search' => '0x' . $keyId, 'op' => 'get', 'options' => 'mr']; foreach ($this->keyServers as $keyServer) { $this->output->writeInfo(sprintf('Trying %s', $keyServer)); $result = $this->httpClient->get(new Url($keyServer . self::PATH), $params); if ($result->getHttpCode() == 200) { $this->output->writeInfo('Sucessfully downloaded key'); return $result->getBody(); } $this->output->writeWarning(sprintf('Failed with status code %s: %s', $result->getHttpCode(), $result->getErrorMessage())); } throw new DownloadFailedException(sprintf('Key %s not found on key servers', $keyId)); }
/** * @param PharAlias $alias * * @return Release * @throws InstallationFailedException * @throws ResolveException * */ private function resolveAlias(PharAlias $alias) { foreach ($this->aliasResolver->resolve($alias) as $repoUrl) { try { $repo = $this->pharIoRepositoryFactory->getRepository($repoUrl); $releases = $repo->getReleases($alias); return $releases->getLatest($alias->getVersionConstraint()); } catch (ResolveException $e) { $this->output->writeWarning(sprintf('Resolving alias %s with repository %s failed: %s', $alias, $repoUrl, $e->getMessage())); continue; } } throw new ResolveException(sprintf('Could not resolve alias %s', $alias)); }