/** * @param UriInterface $uri * * @return Content * @throws LoadException */ public function load(UriInterface $uri) { if (!$uri instanceof HttpUriInterface) { throw new InvalidUriTypeException($uri, 'Eloquent\\Schemer\\Uri\\HttpUriInterface'); } if (!$uri->isAbsolute()) { throw new RelativeUriException($uri); } $response = $this->browser()->get($uri->toString()); if (!$response->isSuccessful()) { throw new LoadException($uri); } $mimeType = $this->mimeTypeByResponse($response); if (null === $mimeType) { $mimeType = $this->extensionMap()->getByPath($this->pathFromUri($uri)); } return new Content($response->getContent(), $mimeType); }
/** * @param UriInterface $uri * @param Exception|null $previous */ public function __construct(UriInterface $uri, Exception $previous = null) { $this->uri = $uri; parent::__construct(sprintf('Unable to read from %s.', var_export($uri->toString(), true)), 0, $previous); }
/** * @param UriInterface $referenceUri * * @return Value\ValueInterface|null */ protected function resolution(UriInterface $referenceUri) { $key = $referenceUri->toString(); if (array_key_exists($key, $this->resolutions)) { return $this->resolutions[$key]; } return null; }