/** * @param UriInterface $uri * * @return Content */ public function load(UriInterface $uri) { if (!$uri instanceof DataUriInterface) { throw new InvalidUriTypeException($uri, 'Eloquent\\Schemer\\Uri\\DataUriInterface'); } return new Content($uri->getData(), $this->stripMimeTypeParameters($uri->getMimeType())); }
/** * @param UriInterface $uri * * @return PointerInterface */ public function createFromUri(UriInterface $uri) { $pointer = $uri->getFragment(); if (null === $pointer || '/' !== substr($pointer, 0, 1)) { return new Pointer(); } return $this->create($pointer); }
/** * @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 $uri * * @return \Eloquent\Schemer\Loader\Content * @throws Exception\UndefinedLoaderException * @throws Exception\LoadExceptionInterface */ public function load(UriInterface $uri) { $scheme = $uri->getScheme(); if (null === $scheme) { $scheme = $this->defaultScheme(); } return $this->loaderByScheme($scheme)->load($uri); }
/** * @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; }