PSR-7 URI implementation.
- author Michael Dowling
- author Tobias Schultze
- author Matthew Weier O'Phinney
- Implements
JsonSerializable Psr\Http\Message\UriInterface Stringable
Methods |
public __construct(string $uri = '') |
public __toString() : string |
public static composeComponents(?string $scheme, ?string $authority, string $path, ?string $query, ?string $fragment) : string Composes a URI reference string from its various components. Usually this method does not need to be called manually but instead is used indirectly via
PSR-7 UriInterface treats an empty component the same as a missing component as getQuery(), getFragment() etc. always return a string. This explains the slight difference to RFC 3986 Section 5.3. Another adjustment is that the authority separator is added even when the authority is missing/empty
for the "file" scheme. This is because PHP stream functions like
|
public static fromParts(array $parts) : Psr\Http\Message\UriInterface Creates a URI from a hash of
|
public getAuthority() : string |
public getFragment() : string |
public getHost() : string |
public getPath() : string |
public getPort() : ?int |
public getQuery() : string |
public getScheme() : string |
public getUserInfo() : string |
public static isAbsolute(Psr\Http\Message\UriInterface $uri) : bool Whether the URI is absolute, i.e. it has a scheme. An instance of UriInterface can either be an absolute URI or a relative reference. This method returns true if it is the former. An absolute URI has a scheme. A relative reference is used to express a URI relative to another URI, the base URI. Relative references can be divided into several forms:
|
public static isAbsolutePathReference(Psr\Http\Message\UriInterface $uri) : bool Whether the URI is a absolute-path reference. A relative reference that begins with a single slash character is termed an absolute-path reference.
|
public static isDefaultPort(Psr\Http\Message\UriInterface $uri) : bool Whether the URI has the default port of the current scheme.
|
public static isNetworkPathReference(Psr\Http\Message\UriInterface $uri) : bool Whether the URI is a network-path reference. A relative reference that begins with two slash characters is termed an network-path reference.
|
public static isRelativePathReference(Psr\Http\Message\UriInterface $uri) : bool Whether the URI is a relative-path reference. A relative reference that does not begin with a slash character is termed a relative-path reference.
|
public static isSameDocumentReference(Psr\Http\Message\UriInterface $uri, ?Psr\Http\Message\UriInterface $base = NULL) : bool Whether the URI is a same-document reference. A same-document reference refers to a URI that is, aside from its fragment component, identical to the base URI. When no base URI is given, only an empty URI reference (apart from its fragment) is considered a same-document reference.
|
public jsonSerialize() : string |
public withFragment( $fragment) : Psr\Http\Message\UriInterface |
public withHost( $host) : Psr\Http\Message\UriInterface |
public static withoutQueryValue(Psr\Http\Message\UriInterface $uri, string $key) : Psr\Http\Message\UriInterface Creates a new URI with a specific query string value removed. Any existing query string values that exactly match the provided key are removed.
|
public withPath( $path) : Psr\Http\Message\UriInterface |
public withPort( $port) : Psr\Http\Message\UriInterface |
public withQuery( $query) : Psr\Http\Message\UriInterface |
public static withQueryValue(Psr\Http\Message\UriInterface $uri, string $key, ?string $value) : Psr\Http\Message\UriInterface Creates a new URI with a specific query string value. Any existing query string values that exactly match the provided key are removed and replaced with the given key value pair. A value of null will set the query string key without a value, e.g. "key" instead of "key=value".
|
public static withQueryValues(Psr\Http\Message\UriInterface $uri, array $keyValueArray) : Psr\Http\Message\UriInterface Creates a new URI with multiple specific query string values. It has the same behavior as withQueryValue() but for an associative array of key => value.
|
public withScheme( $scheme) : Psr\Http\Message\UriInterface |
public withUserInfo( $user, $password = NULL) : Psr\Http\Message\UriInterface |
Constants |
private GuzzleHttp Sub-delims for use in a regex.
|
private GuzzleHttp Unreserved characters for use in a regex.
|
private GuzzleHttp |
private GuzzleHttp Absolute http and https URIs require a host per RFC 7230 Section 2.7 but in generic URIs the host can be empty. So for http(s) URIs we apply this default host when no host is given yet to form a valid URI. |
private GuzzleHttp |
Properties |
private $composedComponents = NULL
|
private $fragment = ''
|
private $host = ''
|
private $path = ''
|
private $port = NULL
|
private $query = ''
|
private $scheme = ''
|
private $userInfo = ''
|
Methods |
private applyParts(array $parts) : void Apply parse_url parts to a URI.
|
private filterHost( $host) : string
|
private filterPath( $path) : string Filters the path of a URI
|
private filterPort( $port) : ?int
|
private filterQueryAndFragment( $str) : string Filters the query string or fragment of a URI.
|
private filterScheme( $scheme) : string
|
private filterUserInfoComponent( $component) : string
|
private static generateQueryString(string $key, ?string $value) : string |
private static getFilteredQueryString(Psr\Http\Message\UriInterface $uri, array $keys) : array
|
private static parse(string $url) UTF-8 aware \parse_url() replacement. The internal function produces broken output for non ASCII domain names (IDN) when used with locales other than "C". On the other hand, cURL understands IDN correctly only when UTF-8 locale is configured ("C.UTF-8", "en_US.UTF-8", etc.).
|
private rawurlencodeMatchZero(array $match) : string |
private removeDefaultPort() : void |
private validateState() : void |
Methods |
public static composeComponents(?string $scheme, ?string $authority, string $path, ?string $query, ?string $fragment) : string Composes a URI reference string from its various components. Usually this method does not need to be called manually but instead is used indirectly via
PSR-7 UriInterface treats an empty component the same as a missing component as getQuery(), getFragment() etc. always return a string. This explains the slight difference to RFC 3986 Section 5.3. Another adjustment is that the authority separator is added even when the authority is missing/empty
for the "file" scheme. This is because PHP stream functions like
|
public static fromParts(array $parts) : Psr\Http\Message\UriInterface Creates a URI from a hash of
|
private static generateQueryString(string $key, ?string $value) : string |
private static getFilteredQueryString(Psr\Http\Message\UriInterface $uri, array $keys) : array
|
public static isAbsolute(Psr\Http\Message\UriInterface $uri) : bool Whether the URI is absolute, i.e. it has a scheme. An instance of UriInterface can either be an absolute URI or a relative reference. This method returns true if it is the former. An absolute URI has a scheme. A relative reference is used to express a URI relative to another URI, the base URI. Relative references can be divided into several forms:
|
public static isAbsolutePathReference(Psr\Http\Message\UriInterface $uri) : bool Whether the URI is a absolute-path reference. A relative reference that begins with a single slash character is termed an absolute-path reference.
|
public static isDefaultPort(Psr\Http\Message\UriInterface $uri) : bool Whether the URI has the default port of the current scheme.
|
public static isNetworkPathReference(Psr\Http\Message\UriInterface $uri) : bool Whether the URI is a network-path reference. A relative reference that begins with two slash characters is termed an network-path reference.
|
public static isRelativePathReference(Psr\Http\Message\UriInterface $uri) : bool Whether the URI is a relative-path reference. A relative reference that does not begin with a slash character is termed a relative-path reference.
|
public static isSameDocumentReference(Psr\Http\Message\UriInterface $uri, ?Psr\Http\Message\UriInterface $base = NULL) : bool Whether the URI is a same-document reference. A same-document reference refers to a URI that is, aside from its fragment component, identical to the base URI. When no base URI is given, only an empty URI reference (apart from its fragment) is considered a same-document reference.
|
private static parse(string $url) UTF-8 aware \parse_url() replacement. The internal function produces broken output for non ASCII domain names (IDN) when used with locales other than "C". On the other hand, cURL understands IDN correctly only when UTF-8 locale is configured ("C.UTF-8", "en_US.UTF-8", etc.).
|
public static withoutQueryValue(Psr\Http\Message\UriInterface $uri, string $key) : Psr\Http\Message\UriInterface Creates a new URI with a specific query string value removed. Any existing query string values that exactly match the provided key are removed.
|
public static withQueryValue(Psr\Http\Message\UriInterface $uri, string $key, ?string $value) : Psr\Http\Message\UriInterface Creates a new URI with a specific query string value. Any existing query string values that exactly match the provided key are removed and replaced with the given key value pair. A value of null will set the query string key without a value, e.g. "key" instead of "key=value".
|
public static withQueryValues(Psr\Http\Message\UriInterface $uri, array $keyValueArray) : Psr\Http\Message\UriInterface Creates a new URI with multiple specific query string values. It has the same behavior as withQueryValue() but for an associative array of key => value.
|