Documentation

UriInterface extends JsonSerializable

Table of Contents

__toString()  : string
Returns the string representation as a URI reference.
getAuthority()  : string|null
Retrieve the authority component of the URI.
getFragment()  : string|null
Retrieve the fragment component of the URI.
getHost()  : string|null
Retrieve the host component of the URI.
getPath()  : string
Retrieve the path component of the URI.
getPort()  : int|null
Retrieve the port component of the URI.
getQuery()  : string|null
Retrieve the query string of the URI.
getScheme()  : string|null
Retrieve the scheme component of the URI.
getUserInfo()  : string|null
Retrieve the user information component of the URI.
jsonSerialize()  : string
Returns the string representation as a URI reference.
withFragment()  : self
Return an instance with the specified URI fragment.
withHost()  : self
Return an instance with the specified host.
withPath()  : self
Return an instance with the specified path.
withPort()  : self
Return an instance with the specified port.
withQuery()  : self
Return an instance with the specified query string.
withScheme()  : self
Return an instance with the specified scheme.
withUserInfo()  : self
Return an instance with the specified user information.

Methods

getAuthority()

Retrieve the authority component of the URI.

public getAuthority() : string|null

If no scheme is present, this method MUST return a null value.

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

Tags
see
https://tools.ietf.org/html/rfc3986#section-3.2
Return values
string|null

getFragment()

Retrieve the fragment component of the URI.

public getFragment() : string|null

If no host is present this method MUST return a null value.

The leading "#" character is not part of the fragment and MUST NOT be added.

The value returned MUST be percent-encoded, but MUST NOT double-encode any characters. To determine what characters to encode, please refer to RFC 3986, Sections 2 and 3.5.

Tags
see
https://tools.ietf.org/html/rfc3986#section-2
see
https://tools.ietf.org/html/rfc3986#section-3.5
Return values
string|null

getHost()

Retrieve the host component of the URI.

public getHost() : string|null

If no host is present this method MUST return a null value.

The value returned MUST be normalized to lowercase, per RFC 3986 Section 3.2.2.

Tags
see
http://tools.ietf.org/html/rfc3986#section-3.2.2
Return values
string|null

getPath()

Retrieve the path component of the URI.

public getPath() : string

The path can either be empty or absolute (starting with a slash) or rootless (not starting with a slash). Implementations MUST support all three syntaxes.

Normally, the empty path "" and absolute path "/" are considered equal as defined in RFC 7230 Section 2.7.3. But this method MUST NOT automatically do this normalization because in contexts with a trimmed base path, e.g. the front controller, this difference becomes significant. It's the task of the user to handle both "" and "/".

The value returned MUST be percent-encoded, but MUST NOT double-encode any characters. To determine what characters to encode, please refer to RFC 3986, Sections 2 and 3.3.

As an example, if the value should include a slash ("/") not intended as delimiter between path segments, that value MUST be passed in encoded form (e.g., "%2F") to the instance.

Tags
see
https://tools.ietf.org/html/rfc3986#section-2
see
https://tools.ietf.org/html/rfc3986#section-3.3
Return values
string

getPort()

Retrieve the port component of the URI.

public getPort() : int|null

If a port is present, and it is non-standard for the current scheme, this method MUST return it as an integer. If the port is the standard port used with the current scheme, this method SHOULD return null.

If no port is present, and no scheme is present, this method MUST return a null value.

If no port is present, but a scheme is present, this method MAY return the standard port for that scheme, but SHOULD return null.

Return values
int|null

getQuery()

Retrieve the query string of the URI.

public getQuery() : string|null

If no host is present this method MUST return a null value.

The leading "?" character is not part of the query and MUST NOT be added.

The value returned MUST be percent-encoded, but MUST NOT double-encode any characters. To determine what characters to encode, please refer to RFC 3986, Sections 2 and 3.4.

As an example, if a value in a key/value pair of the query string should include an ampersand ("&") not intended as a delimiter between values, that value MUST be passed in encoded form (e.g., "%26") to the instance.

Tags
see
https://tools.ietf.org/html/rfc3986#section-2
see
https://tools.ietf.org/html/rfc3986#section-3.4
Return values
string|null

getScheme()

Retrieve the scheme component of the URI.

public getScheme() : string|null

If no scheme is present, this method MUST return a null value.

The value returned MUST be normalized to lowercase, per RFC 3986 Section 3.1.

The trailing ":" character is not part of the scheme and MUST NOT be added.

Tags
see
https://tools.ietf.org/html/rfc3986#section-3.1
Return values
string|null

getUserInfo()

Retrieve the user information component of the URI.

public getUserInfo() : string|null

If no scheme is present, this method MUST return a null value.

If a user is present in the URI, this will return that value; additionally, if the password is also present, it will be appended to the user value, with a colon (":") separating the values.

The trailing "@" character is not part of the user information and MUST NOT be added.

Return values
string|null

withFragment()

Return an instance with the specified URI fragment.

public withFragment(string|null $fragment) : self

This method MUST retain the state of the current instance, and return an instance that contains the specified URI fragment.

Users can provide both encoded and decoded fragment characters. Implementations ensure the correct encoding as outlined in getFragment().

A null value provided for the fragment is equivalent to removing the fragment information.

Parameters
$fragment : string|null
Tags
throws
SyntaxError

for invalid component or transformations that would result in a object in invalid state.

Return values
self

withHost()

Return an instance with the specified host.

public withHost(string|null $host) : self

This method MUST retain the state of the current instance, and return an instance that contains the specified host.

A null value provided for the host is equivalent to removing the host information.

Parameters
$host : string|null
Tags
throws
SyntaxError

for invalid component or transformations that would result in a object in invalid state.

throws
IdnSupportMissing

for component or transformations requiring IDN support when IDN support is not present or misconfigured.

Return values
self

withPath()

Return an instance with the specified path.

public withPath(string $path) : self

This method MUST retain the state of the current instance, and return an instance that contains the specified path.

The path can either be empty or absolute (starting with a slash) or rootless (not starting with a slash). Implementations MUST support all three syntaxes.

Users can provide both encoded and decoded path characters. Implementations ensure the correct encoding as outlined in getPath().

Parameters
$path : string
Tags
throws
SyntaxError

for invalid component or transformations that would result in a object in invalid state.

Return values
self

withPort()

Return an instance with the specified port.

public withPort(int|null $port) : self

This method MUST retain the state of the current instance, and return an instance that contains the specified port.

A null value provided for the port is equivalent to removing the port information.

Parameters
$port : int|null
Tags
throws
SyntaxError

for invalid component or transformations that would result in a object in invalid state.

Return values
self

withQuery()

Return an instance with the specified query string.

public withQuery(string|null $query) : self

This method MUST retain the state of the current instance, and return an instance that contains the specified query string.

Users can provide both encoded and decoded query characters. Implementations ensure the correct encoding as outlined in getQuery().

A null value provided for the query is equivalent to removing the query information.

Parameters
$query : string|null
Tags
throws
SyntaxError

for invalid component or transformations that would result in a object in invalid state.

Return values
self

withScheme()

Return an instance with the specified scheme.

public withScheme(string|null $scheme) : self

This method MUST retain the state of the current instance, and return an instance that contains the specified scheme.

A null value provided for the scheme is equivalent to removing the scheme information.

Parameters
$scheme : string|null
Tags
throws
SyntaxError

for invalid component or transformations that would result in a object in invalid state.

Return values
self

withUserInfo()

Return an instance with the specified user information.

public withUserInfo(string|null $user[, string|null $password = null ]) : self

This method MUST retain the state of the current instance, and return an instance that contains the specified user information.

Password is optional, but the user information MUST include the user; a null value for the user is equivalent to removing user information.

Parameters
$user : string|null
$password : string|null = null
Tags
throws
SyntaxError

for invalid component or transformations that would result in a object in invalid state.

Return values
self

Search results