Uri
in package
implements
Conditionable, UriInterface
Tags
Table of Contents
Interfaces
Constants
- ASCII = " eiasntrolud][cmp'\ng|hv.fb,:=-q10C2*yx)(L9AS/P\"EjMIk3>5T<D4}B{8FwR67UGN;JzV#HOW_&!K?XQ%Y\\\tZ+~^\$@`\x00\x01\x02\x03\x04\x05\x06\x07\x08\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
- All ASCII letters sorted by typical frequency of occurrence.
- MAXIMUM_CACHED_ITEMS = 100
- Maximum number of cached items.
- REGEXP_BINARY = ',(;|^)base64$,'
- Base64 content regular expression pattern.
- REGEXP_FILE_PATH = ',^(?<delim>/)?(?<volume>[a-zA-Z])(?:[:|\|]|%7C)(?<rest>.*)?,'
- Regular expression pattern to for file URI.
- REGEXP_HOST_PORT = ',^(?<host>(\[.*]|[^:])*)(:(?<port>[^/?#]*))?$,x'
- RFC3986 IPvFuture host and port component.
- REGEXP_INVALID_CHARS = '/[\x00-\x1f\x7f]/'
- RFC3986 invalid characters.
- REGEXP_MIMETYPE = ',^\w+/[-.\w]+(?:\+[-.\w]+)?$,'
- Mimetype regular expression pattern.
- REGEXP_WINDOW_PATH = ',^(?<root>[a-zA-Z][:|\|]),'
- Windows filepath regular expression pattern.
Properties
- $authority : string|null
- $fragment : string|null
- $host : string|null
- $origin : string|null
- $pass : string|null
- $path : string
- $port : int|null
- $query : string|null
- $scheme : string|null
- $uriAsciiString : string
- $uriUnicodeString : string
- $user : string|null
- $userInfo : string|null
Methods
- __debugInfo() : ComponentMap
- __toString() : string
- Returns the string representation as a URI reference.
- createFromBaseUri() : static
- DEPRECATION WARNING! This method will be removed in the next major point release.
- createFromComponents() : self
- DEPRECATION WARNING! This method will be removed in the next major point release.
- createFromDataPath() : self
- DEPRECATION WARNING! This method will be removed in the next major point release.
- createFromServer() : self
- DEPRECATION WARNING! This method will be removed in the next major point release.
- createFromString() : self
- DEPRECATION WARNING! This method will be removed in the next major point release.
- createFromUnixPath() : self
- DEPRECATION WARNING! This method will be removed in the next major point release.
- createFromUri() : self
- DEPRECATION WARNING! This method will be removed in the next major point release.
- createFromWindowsPath() : self
- DEPRECATION WARNING! This method will be removed in the next major point release.
- equals() : bool
- fromBaseUri() : self
- DEPRECATION WARNING! This method will be removed in the next major point release.
- fromComponents() : self
- Create a new instance from a hash representation of the URI similar to PHP parse_url function result.
- fromData() : self
- Create a new instance from a data URI string.
- fromFileContents() : self
- Create a new instance from a data file path.
- fromRfc8089() : static
- Creates a new instance from a RFC8089 compatible URI.
- fromServer() : self
- Create a new instance from the environment.
- fromTemplate() : self
- Creates a new instance from a template.
- fromUnixPath() : self
- Create a new instance from a Unix path string.
- fromWindowsPath() : self
- Create a new instance from a local Windows path string.
- getAuthority() : string|null
- Retrieve the authority component of the URI.
- getComponents() : ComponentMap
- DEPRECATION WARNING! This method will be removed in the next major point release.
- getFragment() : string|null
- Retrieve the fragment component of the URI.
- getHost() : string|null
- Retrieve the host component of the URI.
- getOrigin() : string|null
- getPassword() : string|null
- 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.
- getUnicodeHost() : string|null
- getUserInfo() : string|null
- Retrieve the user information component of the URI.
- getUsername() : string|null
- Returns the user component encoded value.
- isAbsolute() : bool
- Tells whether the URI is absolute.
- isAbsolutePath() : bool
- Tells whether the URI is an absolute path.
- isCrossOrigin() : bool
- Tells whether two URI do not share the same origin.
- isDomainHost() : bool
- isIpHost() : bool
- isIpv4Host() : bool
- isIpv6Host() : bool
- isIpvFutureHost() : bool
- isLocalFile() : bool
- Tells whether the `file` scheme base URI represents a local file.
- isNetworkPath() : bool
- Tells whether the URI is a network path.
- isOpaque() : bool
- Tells whether the URI is opaque or not.
- isRegisteredNameHost() : bool
- isRelativePath() : bool
- Tells whether the URI is a relative path.
- isSameDocument() : bool
- Tells whether both URIs refer to the same document.
- isSameOrigin() : bool
- jsonSerialize() : string
- Returns the string representation as a URI reference.
- new() : self
- Create a new instance from a string.
- normalize() : static
- Normalize a URI by applying non-destructive and destructive normalization rules as defined in RFC3986 and RFC3987.
- parse() : self|null
- Returns a new instance from a URI and a Base URI.or null on failure.
- relativize() : static
- Relativize a URI according to a base URI.
- resolve() : static
- Resolves a URI against a base URI using RFC3986 rules.
- toAsciiString() : string
- Returns the string representation as a URI reference.
- toComponents() : ComponentMap
- Returns an associative array containing all the URI components.
- toDisplayString() : string
- Returns the human-readable string representation of the URI as an IRI.
- toFileContents() : int|null
- Save the data to a specific file.
- toRfc8089() : string|null
- Returns a string representation of a File URI according to RFC8089.
- toString() : string
- Returns the string representation as a URI reference.
- toUnicodeString() : string
- Returns the string representation as a URI reference.
- toUnixPath() : string|null
- Returns the Unix filesystem path.
- toWindowsPath() : string|null
- Returns the Windows filesystem path.
- tryNew() : self|null
- Create a new instance from a string or a stringable structure or returns null on failure.
- when() : static
- Apply the callback if the given "condition" is (or resolves to) true.
- withFragment() : static
- Return an instance with the specified URI fragment.
- withHost() : static
- Return an instance with the specified host.
- withPassword() : static
- withPath() : static
- Return an instance with the specified path.
- withPort() : static
- Return an instance with the specified port.
- withQuery() : static
- Return an instance with the specified query string.
- withScheme() : static
- Return an instance with the specified scheme.
- withUserInfo() : static
- Return an instance with the specified user information.
- withUsername() : static
- __construct() : mixed
- assertValidPath() : void
- Assert the path is a compliant with RFC2397.
- assertValidRfc3986Uri() : void
- assert the URI internal state is valid.
- assertValidState() : void
- assert the URI scheme is valid.
- fetchHostname() : array{0: string|null, 1: int|null}
- Returns the environment host.
- fetchRequestUri() : array<int, string|null>
- Returns the environment path.
- fetchScheme() : string
- Returns the environment scheme.
- fetchUserInfo() : array<string|int, mixed>
- Returns the environment user info.
- filterString() : string|null
- Filter a string.
- formatDataPath() : string
- Filter the Path component.
- formatFilePath() : string
- Format the path component for the URI scheme file.
- formatHost() : string|null
- Validate and Format the Host component.
- formatPath() : string
- Format the Path component.
- formatPathWithEmptyBaseQuery() : string
- Formatting the path to keep a resolvable URI.
- formatPort() : int|null
- Format the Port component.
- formatRelativePath() : string
- Formatting the path to keep a valid URI.
- formatScheme() : string|null
- Format the Scheme and Host component.
- getSegments() : array<string|int, string>
- returns the path segments.
- isNonEmptyHostUri() : bool
- URI validation for URI schemes which disallow the empty '' host.
- isNonEmptyHostUriWithoutFragment() : bool
- URI validation for URIs schemes which disallow the empty '' host and forbids the fragment component.
- isNonEmptyHostUriWithoutFragmentAndQuery() : bool
- URI validation for URIs schemes which disallow the empty '' host and forbids fragment and query components.
- isUriWithSchemeAndPathOnly() : bool
- URI validation for URI schemes which allows only scheme and path components.
- isUriWithSchemeHostAndPathOnly() : bool
- URI validation for URI schemes which allows only scheme, host and path components.
- isValidBlob() : bool
- isValidMailto() : bool
- relativizePath() : string
- Relatives the URI for an authority-less target URI.
- setOrigin() : string|null
- Sets the URI origin.
- validateEmailList() : bool
- validateParameter() : bool
- Validate mediatype parameter.
Constants
ASCII
All ASCII letters sorted by typical frequency of occurrence.
private
string
ASCII
= " eiasntrolud][cmp'\ng|hv.fb,:=-q10C2*yx)(L9AS/P\"EjMIk3>5T<D4}B{8FwR67UGN;JzV#HOW_&!K?XQ%Y\\\tZ+~^\$@`\x00\x01\x02\x03\x04\x05\x06\x07\x08\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
MAXIMUM_CACHED_ITEMS
Maximum number of cached items.
private
int
MAXIMUM_CACHED_ITEMS
= 100
REGEXP_BINARY
Base64 content regular expression pattern.
private
string
REGEXP_BINARY
= ',(;|^)base64$,'
Tags
REGEXP_FILE_PATH
Regular expression pattern to for file URI.
private
string
REGEXP_FILE_PATH
= ',^(?<delim>/)?(?<volume>[a-zA-Z])(?:[:|\|]|%7C)(?<rest>.*)?,'
| as %7C) by formatPath(),
so we account for that here.
REGEXP_HOST_PORT
RFC3986 IPvFuture host and port component.
private
string
REGEXP_HOST_PORT
= ',^(?<host>(\[.*]|[^:])*)(:(?<port>[^/?#]*))?$,x'
REGEXP_INVALID_CHARS
RFC3986 invalid characters.
private
string
REGEXP_INVALID_CHARS
= '/[\x00-\x1f\x7f]/'
Tags
REGEXP_MIMETYPE
Mimetype regular expression pattern.
private
string
REGEXP_MIMETYPE
= ',^\w+/[-.\w]+(?:\+[-.\w]+)?$,'
Tags
REGEXP_WINDOW_PATH
Windows filepath regular expression pattern.
private
string
REGEXP_WINDOW_PATH
= ',^(?<root>[a-zA-Z][:|\|]),'
Properties
$authority read-only
private
string|null
$authority
$fragment read-only
private
string|null
$fragment
$host read-only
private
string|null
$host
$origin read-only
private
string|null
$origin
$pass read-only
private
string|null
$pass
$path read-only
private
string
$path
$port read-only
private
int|null
$port
$query read-only
private
string|null
$query
$scheme read-only
private
string|null
$scheme
$uriAsciiString read-only
private
string
$uriAsciiString
$uriUnicodeString read-only
private
string
$uriUnicodeString
$user read-only
private
string|null
$user
$userInfo read-only
private
string|null
$userInfo
Methods
__debugInfo()
public
__debugInfo() : ComponentMap
Return values
ComponentMap__toString()
Returns the string representation as a URI reference.
public
__toString() : string
Return values
stringcreateFromBaseUri()
DEPRECATION WARNING! This method will be removed in the next major point release.
public
static createFromBaseUri(Stringable|UriInterface|string $uri[, Stringable|UriInterface|string|null $baseUri = null ]) : static
Since version 7.0.0
use League\Uri\Uri::fromBaseUri() instead
Parameters
- $uri : Stringable|UriInterface|string
- $baseUri : Stringable|UriInterface|string|null = null
Tags
Return values
staticcreateFromComponents()
DEPRECATION WARNING! This method will be removed in the next major point release.
public
static createFromComponents([InputComponentMap $components = [] ]) : self
Since version 7.0.0
use League\Uri\Uri::fromComponents() instead
Parameters
- $components : InputComponentMap = []
-
a hash representation of the URI similar to PHP parse_url function result
Tags
Return values
selfcreateFromDataPath()
DEPRECATION WARNING! This method will be removed in the next major point release.
public
static createFromDataPath(string $path[, resource|null $context = null ]) : self
Since version 7.0.0
use League\Uri\Uri::fromDataPath() instead
Parameters
- $path : string
- $context : resource|null = null
Tags
Return values
selfcreateFromServer()
DEPRECATION WARNING! This method will be removed in the next major point release.
public
static createFromServer(array<string|int, mixed> $server) : self
Since version 7.0.0
use League\Uri\Uri::fromServer() instead
Parameters
- $server : array<string|int, mixed>
Tags
Return values
selfcreateFromString()
DEPRECATION WARNING! This method will be removed in the next major point release.
public
static createFromString([Stringable|string $uri = '' ]) : self
Since version 7.0.0
use League\Uri\Uri::new() instead
Parameters
- $uri : Stringable|string = ''
Tags
Return values
selfcreateFromUnixPath()
DEPRECATION WARNING! This method will be removed in the next major point release.
public
static createFromUnixPath([string $uri = '' ]) : self
Since version 7.0.0
use League\Uri\Uri::fromUnixPath() instead
Parameters
- $uri : string = ''
Tags
Return values
selfcreateFromUri()
DEPRECATION WARNING! This method will be removed in the next major point release.
public
static createFromUri(UriInterface|UriInterface $uri) : self
Since version 7.0.0
use League\Uri\Uri::new() instead
Parameters
- $uri : UriInterface|UriInterface
Tags
Return values
selfcreateFromWindowsPath()
DEPRECATION WARNING! This method will be removed in the next major point release.
public
static createFromWindowsPath([string $uri = '' ]) : self
Since version 7.0.0
use League\Uri\Uri::fromWindowsPath() instead
Parameters
- $uri : string = ''
Tags
Return values
selfequals()
public
equals(Uri|Url|UriInterface|Stringable|Urn|string $uri[, UriComparisonMode $uriComparisonMode = UriComparisonMode::ExcludeFragment ]) : bool
Parameters
- $uri : Uri|Url|UriInterface|Stringable|Urn|string
- $uriComparisonMode : UriComparisonMode = UriComparisonMode::ExcludeFragment
Return values
boolfromBaseUri()
DEPRECATION WARNING! This method will be removed in the next major point release.
public
static fromBaseUri(Url|Uri|Stringable|string $uri[, Url|Uri|Stringable|string|null $baseUri = null ]) : self
Since version 7.6.0
use League\Uri\Uri::parse() instead
Parameters
- $uri : Url|Uri|Stringable|string
- $baseUri : Url|Uri|Stringable|string|null = null
Tags
Return values
selffromComponents()
Create a new instance from a hash representation of the URI similar to PHP parse_url function result.
public
static fromComponents([InputComponentMap $components = [] ]) : self
Parameters
- $components : InputComponentMap = []
-
a hash representation of the URI similar to PHP parse_url function result
Return values
selffromData()
Create a new instance from a data URI string.
public
static fromData(Stringable|string $data[, string $mimetype = '' ][, string $parameters = '' ]) : self
Parameters
- $data : Stringable|string
- $mimetype : string = ''
- $parameters : string = ''
Tags
Return values
selffromFileContents()
Create a new instance from a data file path.
public
static fromFileContents(SplFileInfo|SplFileObject|resource|Stringable|string $path[, resource|null $context = null ]) : self
Parameters
- $path : SplFileInfo|SplFileObject|resource|Stringable|string
- $context : resource|null = null
Tags
Return values
selffromRfc8089()
Creates a new instance from a RFC8089 compatible URI.
public
static fromRfc8089(Stringable|string $uri) : static
Parameters
- $uri : Stringable|string
Tags
Return values
staticfromServer()
Create a new instance from the environment.
public
static fromServer(array<string|int, mixed> $server) : self
Parameters
- $server : array<string|int, mixed>
Return values
selffromTemplate()
Creates a new instance from a template.
public
static fromTemplate(UriTemplate|Stringable|string $template[, iterable<string|int, mixed> $variables = [] ]) : self
Parameters
- $template : UriTemplate|Stringable|string
- $variables : iterable<string|int, mixed> = []
Tags
Return values
selffromUnixPath()
Create a new instance from a Unix path string.
public
static fromUnixPath(Stringable|string $path) : self
Parameters
- $path : Stringable|string
Return values
selffromWindowsPath()
Create a new instance from a local Windows path string.
public
static fromWindowsPath(Stringable|string $path) : self
Parameters
- $path : Stringable|string
Return values
selfgetAuthority()
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.
Return values
string|nullgetComponents()
DEPRECATION WARNING! This method will be removed in the next major point release.
public
getComponents() : ComponentMap
Since version 7.5.0
use League\Uri\Uri::toComponents() instead
Tags
Return values
ComponentMapgetFragment()
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.
Return values
string|nullgetHost()
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.
Return values
string|nullgetOrigin()
public
getOrigin() : string|null
Return values
string|nullgetPassword()
public
getPassword() : string|null
Return values
string|nullgetPath()
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.
Return values
stringgetPort()
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|nullgetQuery()
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.
Return values
string|nullgetScheme()
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.
Return values
string|nullgetUnicodeHost()
public
getUnicodeHost() : string|null
Return values
string|nullgetUserInfo()
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|nullgetUsername()
Returns the user component encoded value.
public
getUsername() : string|null
Tags
Return values
string|nullisAbsolute()
Tells whether the URI is absolute.
public
isAbsolute() : bool
Return values
boolisAbsolutePath()
Tells whether the URI is an absolute path.
public
isAbsolutePath() : bool
Return values
boolisCrossOrigin()
Tells whether two URI do not share the same origin.
public
isCrossOrigin(Uri|Url|Urn|Stringable|string $uri) : bool
Parameters
- $uri : Uri|Url|Urn|Stringable|string
Return values
boolisDomainHost()
public
isDomainHost() : bool
Return values
boolisIpHost()
public
isIpHost() : bool
Return values
boolisIpv4Host()
public
isIpv4Host() : bool
Return values
boolisIpv6Host()
public
isIpv6Host() : bool
Return values
boolisIpvFutureHost()
public
isIpvFutureHost() : bool
Return values
boolisLocalFile()
Tells whether the `file` scheme base URI represents a local file.
public
isLocalFile() : bool
Return values
boolisNetworkPath()
Tells whether the URI is a network path.
public
isNetworkPath() : bool
Return values
boolisOpaque()
Tells whether the URI is opaque or not.
public
isOpaque() : bool
A URI is opaque if and only if it is absolute and does not have an authority path.
Return values
boolisRegisteredNameHost()
public
isRegisteredNameHost() : bool
Return values
boolisRelativePath()
Tells whether the URI is a relative path.
public
isRelativePath() : bool
Return values
boolisSameDocument()
Tells whether both URIs refer to the same document.
public
isSameDocument(Uri|Url|UriInterface|Stringable|Urn|string $uri) : bool
Parameters
- $uri : Uri|Url|UriInterface|Stringable|Urn|string
Return values
boolisSameOrigin()
public
isSameOrigin(Uri|Url|Urn|Stringable|string $uri) : bool
Parameters
- $uri : Uri|Url|Urn|Stringable|string
Return values
booljsonSerialize()
Returns the string representation as a URI reference.
public
jsonSerialize() : string
Tags
Return values
stringnew()
Create a new instance from a string.
public
static new([Uri|Url|Urn|Stringable|string $uri = '' ]) : self
Parameters
- $uri : Uri|Url|Urn|Stringable|string = ''
Return values
selfnormalize()
Normalize a URI by applying non-destructive and destructive normalization rules as defined in RFC3986 and RFC3987.
public
normalize() : static
Return values
staticparse()
Returns a new instance from a URI and a Base URI.or null on failure.
public
static parse(Uri|Url|Urn|Stringable|string $uri[, Uri|Url|Urn|Stringable|string|null $baseUri = null ]) : self|null
The returned URI must be absolute if a base URI is provided
Parameters
- $uri : Uri|Url|Urn|Stringable|string
- $baseUri : Uri|Url|Urn|Stringable|string|null = null
Return values
self|nullrelativize()
Relativize a URI according to a base URI.
public
relativize(Uri|Url|UriInterface|Stringable|Urn|string $uri) : static
This method MUST retain the state of the submitted URI instance, and return a URI instance of the same type that contains the applied modifications.
This method MUST be transparent when dealing with error and exceptions. It MUST not alter of silence them apart from validating its own parameters.
Parameters
- $uri : Uri|Url|UriInterface|Stringable|Urn|string
Return values
staticresolve()
Resolves a URI against a base URI using RFC3986 rules.
public
resolve(Uri|Url|UriInterface|Stringable|Urn|string $uri) : static
This method MUST retain the state of the submitted URI instance, and return a URI instance of the same type that contains the applied modifications.
This method MUST be transparent when dealing with errors and exceptions. It MUST not alter or silence them apart from validating its own parameters.
Parameters
- $uri : Uri|Url|UriInterface|Stringable|Urn|string
Return values
statictoAsciiString()
Returns the string representation as a URI reference.
public
toAsciiString() : string
Tags
Return values
stringtoComponents()
Returns an associative array containing all the URI components.
public
toComponents() : ComponentMap
Return values
ComponentMaptoDisplayString()
Returns the human-readable string representation of the URI as an IRI.
public
toDisplayString() : string
Tags
Return values
stringtoFileContents()
Save the data to a specific file.
public
toFileContents(SplFileInfo|SplFileObject|resource|Stringable|string $destination[, resource|null $context = null ]) : int|null
The method returns the number of bytes written to the file or null for any other scheme except the data scheme
Parameters
- $destination : SplFileInfo|SplFileObject|resource|Stringable|string
- $context : resource|null = null
Tags
Return values
int|nulltoRfc8089()
Returns a string representation of a File URI according to RFC8089.
public
toRfc8089() : string|null
The method will return null if the URI scheme is not the file scheme
Tags
Return values
string|nulltoString()
Returns the string representation as a URI reference.
public
toString() : string
Tags
Return values
stringtoUnicodeString()
Returns the string representation as a URI reference.
public
toUnicodeString() : string
The host is converted to its UNICODE representation if available
Return values
stringtoUnixPath()
Returns the Unix filesystem path.
public
toUnixPath() : string|null
The method will return null if a scheme is present and is not the file scheme
Return values
string|nulltoWindowsPath()
Returns the Windows filesystem path.
public
toWindowsPath() : string|null
The method will return null if a scheme is present and is not the file scheme
Return values
string|nulltryNew()
Create a new instance from a string or a stringable structure or returns null on failure.
public
static tryNew([Uri|Url|Urn|Stringable|string $uri = '' ]) : self|null
Parameters
- $uri : Uri|Url|Urn|Stringable|string = ''
Return values
self|nullwhen()
Apply the callback if the given "condition" is (or resolves to) true.
public
when(callable|bool $condition, callable $onSuccess[, callable|null $onFail = null ]) : static
Parameters
- $condition : callable|bool
- $onSuccess : callable
- $onFail : callable|null = null
Return values
staticwithFragment()
Return an instance with the specified URI fragment.
public
withFragment(Stringable|string|null $fragment) : static
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 : Stringable|string|null
Return values
staticwithHost()
Return an instance with the specified host.
public
withHost(Stringable|string|null $host) : static
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 : Stringable|string|null
Return values
staticwithPassword()
public
withPassword(Stringable|string|null $password) : static
Parameters
- $password : Stringable|string|null
Return values
staticwithPath()
Return an instance with the specified path.
public
withPath(Stringable|string $path) : static
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 : Stringable|string
Return values
staticwithPort()
Return an instance with the specified port.
public
withPort(int|null $port) : static
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
Return values
staticwithQuery()
Return an instance with the specified query string.
public
withQuery(Stringable|string|null $query) : static
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 : Stringable|string|null
Return values
staticwithScheme()
Return an instance with the specified scheme.
public
withScheme(Stringable|string|null $scheme) : static
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 : Stringable|string|null
Return values
staticwithUserInfo()
Return an instance with the specified user information.
public
withUserInfo(Stringable|string|null $user[, Stringable|string|null $password = null ]) : static
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 : Stringable|string|null
- $password : Stringable|string|null = null
Return values
staticwithUsername()
public
withUsername(Stringable|string|null $user) : static
Parameters
- $user : Stringable|string|null
Return values
static__construct()
private
__construct(string|null $scheme, string|null $user, string|null $pass, string|null $host, int|null $port, string $path, string|null $query, string|null $fragment) : mixed
Parameters
- $scheme : string|null
- $user : string|null
- $pass : string|null
- $host : string|null
- $port : int|null
- $path : string
- $query : string|null
- $fragment : string|null
assertValidPath()
Assert the path is a compliant with RFC2397.
private
static assertValidPath(string $mimetype, string $parameters, string $data) : void
Parameters
- $mimetype : string
- $parameters : string
- $data : string
Tags
assertValidRfc3986Uri()
assert the URI internal state is valid.
private
assertValidRfc3986Uri() : void
Tags
assertValidState()
assert the URI scheme is valid.
private
assertValidState() : void
Tags
fetchHostname()
Returns the environment host.
private
static fetchHostname(array<string|int, mixed> $server) : array{0: string|null, 1: int|null}
Parameters
- $server : array<string|int, mixed>
Tags
Return values
array{0: string|null, 1: int|null}fetchRequestUri()
Returns the environment path.
private
static fetchRequestUri(array<string|int, mixed> $server) : array<int, string|null>
Parameters
- $server : array<string|int, mixed>
Return values
array<int, string|null>fetchScheme()
Returns the environment scheme.
private
static fetchScheme(array<string|int, mixed> $server) : string
Parameters
- $server : array<string|int, mixed>
Return values
stringfetchUserInfo()
Returns the environment user info.
private
static fetchUserInfo(array<string|int, mixed> $server) : array<string|int, mixed>
Parameters
- $server : array<string|int, mixed>
Return values
array<string|int, mixed> —{0: ?string, 1: ?string}
filterString()
Filter a string.
private
filterString(Stringable|string|null $str) : string|null
Parameters
- $str : Stringable|string|null
Tags
Return values
string|nullformatDataPath()
Filter the Path component.
private
static formatDataPath(string $path) : string
Parameters
- $path : string
Tags
Return values
stringformatFilePath()
Format the path component for the URI scheme file.
private
static formatFilePath(string $path) : string
Parameters
- $path : string
Return values
stringformatHost()
Validate and Format the Host component.
private
formatHost(string|null $host) : string|null
Parameters
- $host : string|null
Return values
string|nullformatPath()
Format the Path component.
private
formatPath(string $path) : string
Parameters
- $path : string
Return values
stringformatPathWithEmptyBaseQuery()
Formatting the path to keep a resolvable URI.
private
static formatPathWithEmptyBaseQuery(string $path) : string
Parameters
- $path : string
Return values
stringformatPort()
Format the Port component.
private
formatPort([int|null $port = null ]) : int|null
Parameters
- $port : int|null = null
Tags
Return values
int|nullformatRelativePath()
Formatting the path to keep a valid URI.
private
static formatRelativePath(string $path, string $basePath) : string
Parameters
- $path : string
- $basePath : string
Return values
stringformatScheme()
Format the Scheme and Host component.
private
formatScheme(string|null $scheme) : string|null
Parameters
- $scheme : string|null
Tags
Return values
string|nullgetSegments()
returns the path segments.
private
static getSegments(string $path) : array<string|int, string>
Parameters
- $path : string
Return values
array<string|int, string>isNonEmptyHostUri()
URI validation for URI schemes which disallow the empty '' host.
private
isNonEmptyHostUri() : bool
Return values
boolisNonEmptyHostUriWithoutFragment()
URI validation for URIs schemes which disallow the empty '' host and forbids the fragment component.
private
isNonEmptyHostUriWithoutFragment() : bool
Return values
boolisNonEmptyHostUriWithoutFragmentAndQuery()
URI validation for URIs schemes which disallow the empty '' host and forbids fragment and query components.
private
isNonEmptyHostUriWithoutFragmentAndQuery() : bool
Return values
boolisUriWithSchemeAndPathOnly()
URI validation for URI schemes which allows only scheme and path components.
private
isUriWithSchemeAndPathOnly() : bool
Return values
boolisUriWithSchemeHostAndPathOnly()
URI validation for URI schemes which allows only scheme, host and path components.
private
isUriWithSchemeHostAndPathOnly() : bool
Return values
boolisValidBlob()
private
isValidBlob() : bool
Return values
boolisValidMailto()
private
isValidMailto() : bool
Return values
boolrelativizePath()
Relatives the URI for an authority-less target URI.
private
static relativizePath(string $path, string $basePath) : string
Parameters
- $path : string
- $basePath : string
Return values
stringsetOrigin()
Sets the URI origin.
private
setOrigin() : string|null
The origin read-only property of the URL interface returns a string containing the Unicode serialization of the represented URL.
Return values
string|nullvalidateEmailList()
private
static validateEmailList(string $emails) : bool
Parameters
- $emails : string
Return values
boolvalidateParameter()
Validate mediatype parameter.
private
static validateParameter(string $parameter) : bool
Parameters
- $parameter : string