You are here

public function Uri::__toString in Lockr 7.3

Return the string representation as a URI reference.

Depending on which components of the URI are present, the resulting string is either a full URI or relative reference according to RFC 3986, Section 4.1. The method concatenates the various components of the URI, using the appropriate delimiters:

  • If a scheme is present, it MUST be suffixed by ":".
  • If an authority is present, it MUST be prefixed by "//".
  • The path can be concatenated without delimiters. But there are two cases where the path has to be adjusted to make the URI reference valid as PHP does not allow to throw an exception in __toString():

    • If the path is rootless and an authority is present, the path MUST be prefixed by "/".
    • If the path is starting with more than one "/" and no authority is present, the starting slashes MUST be reduced to one.
  • If a query is present, it MUST be prefixed by "?".
  • If a fragment is present, it MUST be prefixed by "#".

Return value

string

Overrides UriInterface::__toString

See also

http://tools.ietf.org/html/rfc3986#section-4.1

File

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

Class

Uri
PSR-7 URI implementation.

Namespace

GuzzleHttp\Psr7

Code

public function __toString() {
  return self::composeComponents($this->scheme, $this
    ->getAuthority(), $this->path, $this->query, $this->fragment);
}