示例#1
0
 /**
  * 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());
 }
示例#2
0
 /**
  * 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;
 }
示例#3
0
文件: Formatter.php 项目: BauRo/url
 /**
  * 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;
 }
示例#4
0
 /**
  * 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;
 }
示例#5
0
文件: Properties.php 项目: BauRo/url
 /**
  * {@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();
 }