/** * returns the resolve URI * * @param LeagueUriInterface|UriInterface $relative the relative URI * * @return LeagueUriInterface|UriInterface */ protected function resolveRelative($relative) { $path = $relative->getPath(); if (!empty($path)) { return $this->resolveRelativePath($relative, $path, $relative->getQuery()); } $query = $relative->getQuery(); if (!empty($query)) { return $this->getBaseUri($relative)->withPath($this->uri->getPath())->withQuery($query); } return $this->getBaseUri($relative)->withPath($this->uri->getPath())->withQuery($this->uri->getQuery()); }
/** * Format a URI Fragment component according to the Formatter properties * * @param UriInterface|Uri $uri * * @return string */ protected function formatFragment($uri) { $fragment = $uri->getFragment(); if ($this->preserveFragment || '' != $fragment) { $fragment = '#' . $fragment; } return $fragment; }
/** * Format a URL authority according to the Formatter properties * * @param Interfaces\Uri $url * * @return string */ protected function formatAuthority(Interfaces\Uri $url) { if ('' == $url->getHost()) { return ''; } $port = $url->port->getUriComponent(); if ($url->hasStandardPort()) { $port = ''; } return '//' . $url->userInfo->getUriComponent() . $this->formatHost($url->host) . $port; }
/** * Format a URI authority according to the Formatter properties * * @param UriInterface|Uri $uri * * @return string */ protected function formatAuthority($uri) { if ('' == $uri->getHost()) { return ''; } $components = $this->uriParser->parse((string) $uri); $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 resolve(Interfaces\Uri $relative) { if (!$relative->scheme->isEmpty()) { return $relative->normalize(); } if (!$relative->host->isEmpty()) { return $this->resolveAuthority($relative)->normalize(); } return $this->resolveRelative($relative)->normalize(); }