Exemple #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();
 }
Exemple #2
0
 /**
  * Format a URI authority according to the Formatter properties
  *
  * @param Uri $uri
  *
  * @return string
  */
 protected function formatAuthority(Uri $uri)
 {
     if ('' == $uri->getHost()) {
         return '';
     }
     $components = $uri->toArray();
     $port = $components['port'];
     if (!empty($port)) {
         $port = ':' . $port;
     }
     return '//' . $this->uriParser->BuildUserInfo($components['user'], $components['pass']) . $this->formatHost(new Host($components['host'])) . $port;
 }
 /**
  * {@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));
 }