You are here

public function Uri::getAuthority in Zircon Profile 8

Same name in this branch
  1. 8 vendor/zendframework/zend-diactoros/src/Uri.php \Zend\Diactoros\Uri::getAuthority()
  2. 8 vendor/guzzlehttp/psr7/src/Uri.php \GuzzleHttp\Psr7\Uri::getAuthority()
Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/psr7/src/Uri.php \GuzzleHttp\Psr7\Uri::getAuthority()

Retrieve the authority component of the URI.

If no authority information is present, this method MUST return an empty string.

The authority syntax of the URI is:

<pre> [user-info@]host[:port] </pre>

If the port component is not set or is the standard port for the current scheme, it SHOULD NOT be included.

Return value

string The URI authority, in "[user-info@]host[:port]" format.

Overrides UriInterface::getAuthority

See also

https://tools.ietf.org/html/rfc3986#section-3.2

1 call to Uri::getAuthority()
Uri::__toString in vendor/guzzlehttp/psr7/src/Uri.php
Return the string representation as a URI reference.

File

vendor/guzzlehttp/psr7/src/Uri.php, line 274

Class

Uri
Basic PSR-7 URI implementation.

Namespace

GuzzleHttp\Psr7

Code

public function getAuthority() {
  if (empty($this->host)) {
    return '';
  }
  $authority = $this->host;
  if (!empty($this->userInfo)) {
    $authority = $this->userInfo . '@' . $authority;
  }
  if ($this
    ->isNonStandardPort($this->scheme, $this->host, $this->port)) {
    $authority .= ':' . $this->port;
  }
  return $authority;
}