Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function resolve(Uri $relative)
 {
     if (!$relative instanceof HttpUriInterface || !empty($relative->getScheme())) {
         return $relative->withoutDotSegments();
     }
     if (!empty($relative->getHost())) {
         return $relative->withScheme($this->getScheme())->withoutDotSegments();
     }
     return $this->resolveRelative($relative)->withFragment($relative->getFragment())->withoutDotSegments();
 }
Beispiel #2
0
 /**
  * Format a Interfaces\Schemes\Uri according to the Formatter properties
  *
  * @param Uri $uri
  *
  * @return string
  */
 protected function formatUri(Uri $uri)
 {
     $scheme = $uri->getScheme();
     if (!empty($scheme)) {
         $scheme .= ':';
     }
     $auth = $this->formatAuthority($uri);
     $query = $this->formatUriPart(new Query($uri->getQuery()));
     if (!empty($query)) {
         $query = '?' . $query;
     }
     $fragment = $uri->getFragment();
     if (!empty($fragment)) {
         $fragment = '#' . $fragment;
     }
     return $scheme . $auth . $this->formatPath($uri->getPath(), !empty($auth)) . $query . $fragment;
 }
 /**
  * {@inheritdoc}
  */
 public function relativize(Uri $relative)
 {
     if (!$relative instanceof HierarchicalUri) {
         return $relative;
     }
     if ($this->getScheme() !== $relative->getScheme() || $this->getAuthority() !== $relative->getAuthority()) {
         return $relative;
     }
     $relativePath = $this->path->modify($relative->getPath());
     return $relative->withScheme('')->withUserInfo('')->withHost('')->withPort('')->withPath($this->path->relativize($relativePath));
 }