Since: 8.5

final class Url (View source)

Methods

static Url|null
parse(string $uri, Url|null $baseUrl = null, array $errors = null)

No description

__construct(string $uri, Url|null $baseUrl = null, array $softErrors = null)

No description

string
getScheme()

Retrieve the scheme component

Url
withScheme(string $scheme)

No description

string|null
getUsername()

Retrieve the username component

Url
withUsername(string|null $username)

No description

string|null
getPassword()

Retrieve the password component

Url
withPassword(string|null $password)

No description

string|null
getAsciiHost()

Retrieve the host component as an ASCII string

string|null
getUnicodeHost()

Retrieve the host component as an Unicode string

Url
withHost(string|null $host)

No description

int|null
getPort()

Retrieve the port component

Url
withPort(int|null $port)

No description

string
getPath()

Retrieve the path component

Url
withPath(string $path)

No description

string|null
getQuery()

Retrieve the query component

Url
withQuery(string|null $query)

No description

string|null
getFragment()

Retrieve the fragment component

Url
withFragment(string|null $fragment)

No description

bool
equals(Url $url, UriComparisonMode $comparisonMode = \Uri\UriComparisonMode::ExcludeFragment)

Check if two URLs are equivalent

string
toAsciiString()

Recompose the URL as an ASCII string

string
toUnicodeString()

Recompose the URL as a Unicode string

Url
resolve(string $uri, array $softErrors = null)

No description

array
__serialize()

No description

void
__unserialize(array $data)

No description

array
__debugInfo()

Return the internal state of the URL

UrlHostType|null
getHostType()

No description

bool
isSpecialScheme()

No description

Details

static Url|null parse(string $uri, Url|null $baseUrl = null, array $errors = null)

No description

Parameters

string $uri
Url|null $baseUrl
array $errors

Return Value

Url|null

__construct(string $uri, Url|null $baseUrl = null, array $softErrors = null)

No description

Parameters

string $uri
Url|null $baseUrl
array $softErrors

Exceptions

InvalidUrlException

string getScheme()

Retrieve the scheme component

Retrieves the scheme component.

Return Value

string

Returns the scheme component as a string if the scheme component exists, null is returned otherwise.

Url withScheme(string $scheme)

No description

Parameters

string $scheme

Return Value

Url

Exceptions

InvalidUrlException

string|null getUsername()

Retrieve the username component

Retrieves the username component.

Return Value

string|null

Returns the username component as a string if the username component exists, null is returned otherwise.

Url withUsername(string|null $username)

No description

Parameters

string|null $username

Return Value

Url

Exceptions

InvalidUrlException

string|null getPassword()

Retrieve the password component

Retrieves the password component.

Return Value

string|null

Returns the password component as a string if the password component exists, null is returned otherwise.

Url withPassword(string|null $password)

No description

Parameters

string|null $password

Return Value

Url

Exceptions

InvalidUrlException

string|null getAsciiHost()

Retrieve the host component as an ASCII string

Retrieves the host component as a string using punycode transcription instead of Unicode characters.

Return Value

string|null

Returns the host component as an ASCII string if the host component exists, null is returned otherwise.

string|null getUnicodeHost()

Retrieve the host component as an Unicode string

Retrieves the host component as a string, which may contain Unicode characters.

Return Value

string|null

Returns the host component as a Unicode string if the host component exists, null is returned otherwise.

Url withHost(string|null $host)

No description

Parameters

string|null $host

Return Value

Url

Exceptions

InvalidUrlException

int|null getPort()

Retrieve the port component

Retrieves the port component.

Return Value

int|null

Returns the port component as an integer if the port component exists, null is returned otherwise.

Url withPort(int|null $port)

No description

Parameters

int|null $port

Return Value

Url

Exceptions

InvalidUrlException

string getPath()

Retrieve the path component

Retrieves the path component.

Return Value

string

Returns the path component as a string.

Url withPath(string $path)

No description

Parameters

string $path

Return Value

Url

Exceptions

InvalidUrlException

string|null getQuery()

Retrieve the query component

Retrieves the query component.

Return Value

string|null

Returns the query component as a string if the query component exists, null is returned otherwise.

Url withQuery(string|null $query)

No description

Parameters

string|null $query

Return Value

Url

Exceptions

InvalidUrlException

string|null getFragment()

Retrieve the fragment component

Retrieves the fragment component.

Return Value

string|null

Returns the fragment component as a string if the fragment component exists, null is returned otherwise.

Url withFragment(string|null $fragment)

No description

Parameters

string|null $fragment

Return Value

Url

Exceptions

InvalidUrlException

bool equals(Url $url, UriComparisonMode $comparisonMode = \Uri\UriComparisonMode::ExcludeFragment)

Check if two URLs are equivalent

Checks if two URLs are equivalent.

Parameters

Url $url

URL to compare the current URL against.

UriComparisonMode $comparisonMode

Whether the fragment component is taken into account of the comparison (Uri\UriComparisonMode::IncludeFragment) or not (Uri\UriComparisonMode::ExcludeFragment). By default, the fragment is excluded.

Return Value

bool

Returns true if the two URLs are equivalent, or false otherwise.

string toAsciiString()

Recompose the URL as an ASCII string

Recomposes the URL as an ASCII string, using punycode transcription instead of Unicode characters in the host component.

Return Value

string

Returns the recomposed URL as an ASCII string.

string toUnicodeString()

Recompose the URL as a Unicode string

Recomposes the URL as a string, where the host component may contain Unicode characters.

Return Value

string

Returns the recomposed URL as a Unicode string.

Url resolve(string $uri, array $softErrors = null)

No description

Parameters

string $uri
array $softErrors

Return Value

Url

Exceptions

InvalidUrlException

array __serialize()

No description

Return Value

array

Exceptions

Exception

void __unserialize(array $data)

No description

Parameters

array $data

Return Value

void

Exceptions

Exception

array __debugInfo()

Return the internal state of the URL

Returns the internal state of the URL.

Return Value

array

Returns the internal state of the URL as an array.

UrlHostType|null getHostType()

Since: 8.6

No description

Return Value

UrlHostType|null

bool isSpecialScheme()

Since: 8.6

No description

Return Value

bool