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