PHP Class GuzzleHttp\Psr7\Uri

Inheritance: implements Psr\Http\Message\UriInterface
Mostra file Open project: nystudio107/instantanalytics Class Usage Examples

Public Methods

Method Description
__construct ( string $uri = '' )
__toString ( )
composeComponents ( string $scheme, string $authority, string $path, string $query, string $fragment ) : string Composes a URI reference string from its various components.
fromParts ( array $parts ) : Psr\Http\Message\UriInterface Creates a URI from a hash of parse_url components.
getAuthority ( )
getFragment ( )
getHost ( )
getPath ( )
getPort ( )
getQuery ( )
getScheme ( )
getUserInfo ( )
isAbsolute ( Psr\Http\Message\UriInterface $uri ) : boolean Whether the URI is absolute, i.e. it has a scheme.
isAbsolutePathReference ( Psr\Http\Message\UriInterface $uri ) : boolean Whether the URI is a absolute-path reference.
isDefaultPort ( Psr\Http\Message\UriInterface $uri ) : boolean Whether the URI has the default port of the current scheme.
isNetworkPathReference ( Psr\Http\Message\UriInterface $uri ) : boolean Whether the URI is a network-path reference.
isRelativePathReference ( Psr\Http\Message\UriInterface $uri ) : boolean Whether the URI is a relative-path reference.
isSameDocumentReference ( Psr\Http\Message\UriInterface $uri, Psr\Http\Message\UriInterface $base = null ) : boolean Whether the URI is a same-document reference.
removeDotSegments ( string $path ) : string Removes dot segments from a path and returns the new path.
resolve ( Psr\Http\Message\UriInterface $base, string | Psr\Http\Message\UriInterface $rel ) : Psr\Http\Message\UriInterface Converts the relative URI into a new URI that is resolved against the base URI.
withFragment ( $fragment )
withHost ( $host )
withPath ( $path )
withPort ( $port )
withQuery ( $query )
withQueryValue ( Psr\Http\Message\UriInterface $uri, string $key, string | null $value ) : Psr\Http\Message\UriInterface Creates a new URI with a specific query string value.
withScheme ( $scheme )
withUserInfo ( $user, $password = null )
withoutQueryValue ( Psr\Http\Message\UriInterface $uri, string $key ) : Psr\Http\Message\UriInterface Creates a new URI with a specific query string value removed.

Private Methods

Method Description
applyParts ( array $parts ) Apply parse_url parts to a URI.
filterHost ( string $host ) : string
filterPath ( string $path ) : string Filters the path of a URI
filterPort ( integer | null $port ) : integer | null
filterQueryAndFragment ( string $str ) : string Filters the query string or fragment of a URI.
filterScheme ( string $scheme ) : string
rawurlencodeMatchZero ( array $match )
removeDefaultPort ( )
validateState ( )

Method Details

__construct() public method

public __construct ( string $uri = '' )
$uri string URI to parse

__toString() public method

public __toString ( )

composeComponents() public static method

Usually this method does not need to be called manually but instead is used indirectly via Psr\Http\Message\UriInterface::__toString. 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 file_get_contents only work with file:///myfile but not with file:/myfile although they are equivalent according to RFC 3986. But file:/// is the more common syntax for the file scheme anyway (Chrome for example redirects to that format).
public static composeComponents ( string $scheme, string $authority, string $path, string $query, string $fragment ) : string
$scheme string
$authority string
$path string
$query string
$fragment string
return string

fromParts() public static method

Creates a URI from a hash of parse_url components.
public static fromParts ( array $parts ) : Psr\Http\Message\UriInterface
$parts array
return Psr\Http\Message\UriInterface

getAuthority() public method

public getAuthority ( )

getFragment() public method

public getFragment ( )

getHost() public method

public getHost ( )

getPath() public method

public getPath ( )

getPort() public method

public getPort ( )

getQuery() public method

public getQuery ( )

getScheme() public method

public getScheme ( )

getUserInfo() public method

public getUserInfo ( )

isAbsolute() public static method

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: - network-path references, e.g. '//example.com/path' - absolute-path references, e.g. '/path' - relative-path references, e.g. 'subpath'
See also: Uri::isNetworkPathReference
See also: Uri::isAbsolutePathReference
See also: Uri::isRelativePathReference
public static isAbsolute ( Psr\Http\Message\UriInterface $uri ) : boolean
$uri Psr\Http\Message\UriInterface
return boolean

isAbsolutePathReference() public static method

A relative reference that begins with a single slash character is termed an absolute-path reference.
public static isAbsolutePathReference ( Psr\Http\Message\UriInterface $uri ) : boolean
$uri Psr\Http\Message\UriInterface
return boolean

isDefaultPort() public static method

Psr\Http\Message\UriInterface::getPort may return null or the standard port. This method can be used independently of the implementation.
public static isDefaultPort ( Psr\Http\Message\UriInterface $uri ) : boolean
$uri Psr\Http\Message\UriInterface
return boolean

isNetworkPathReference() public static method

A relative reference that begins with two slash characters is termed an network-path reference.
public static isNetworkPathReference ( Psr\Http\Message\UriInterface $uri ) : boolean
$uri Psr\Http\Message\UriInterface
return boolean

isRelativePathReference() public static method

A relative reference that does not begin with a slash character is termed a relative-path reference.
public static isRelativePathReference ( Psr\Http\Message\UriInterface $uri ) : boolean
$uri Psr\Http\Message\UriInterface
return boolean

isSameDocumentReference() public static method

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 static isSameDocumentReference ( Psr\Http\Message\UriInterface $uri, Psr\Http\Message\UriInterface $base = null ) : boolean
$uri Psr\Http\Message\UriInterface The URI to check
$base Psr\Http\Message\UriInterface An optional base URI to compare against
return boolean

removeDotSegments() public static method

Removes dot segments from a path and returns the new path.
See also: UriResolver::removeDotSegments
Deprecation: since version 1.4. Use UriResolver::removeDotSegments instead.
public static removeDotSegments ( string $path ) : string
$path string
return string

resolve() public static method

Converts the relative URI into a new URI that is resolved against the base URI.
See also: UriResolver::resolve
Deprecation: since version 1.4. Use UriResolver::resolve instead.
public static resolve ( Psr\Http\Message\UriInterface $base, string | Psr\Http\Message\UriInterface $rel ) : Psr\Http\Message\UriInterface
$base Psr\Http\Message\UriInterface Base URI
$rel string | Psr\Http\Message\UriInterface Relative URI
return Psr\Http\Message\UriInterface

withFragment() public method

public withFragment ( $fragment )

withHost() public method

public withHost ( $host )

withPath() public method

public withPath ( $path )

withPort() public method

public withPort ( $port )

withQuery() public method

public withQuery ( $query )

withQueryValue() public static method

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 withQueryValue ( Psr\Http\Message\UriInterface $uri, string $key, string | null $value ) : Psr\Http\Message\UriInterface
$uri Psr\Http\Message\UriInterface URI to use as a base.
$key string Key to set.
$value string | null Value to set
return Psr\Http\Message\UriInterface

withScheme() public method

public withScheme ( $scheme )

withUserInfo() public method

public withUserInfo ( $user, $password = null )

withoutQueryValue() public static method

Any existing query string values that exactly match the provided key are removed.
public static withoutQueryValue ( Psr\Http\Message\UriInterface $uri, string $key ) : Psr\Http\Message\UriInterface
$uri Psr\Http\Message\UriInterface URI to use as a base.
$key string Query string key to remove.
return Psr\Http\Message\UriInterface