class UrlImmutable implements JsonSerializable

Immutable representation of a URL.

scheme  user  password  host  port      path        query    fragment
  |      |      |        |      |        |            |         |
/--\   /--\ /------\ /-------\ /--\/------------\ /--------\ /------\
http://john:x0y17575@nette.org:8042/en/manual.php?name=param#fragment  <-- absoluteUrl
\______\__________________________/
    |               |
 hostUrl        authority

Properties

string read-only $scheme
string read-only $user
string read-only $password
string read-only $host
int read-only $port
string read-only $path
string read-only $query
string read-only $fragment
string read-only $absoluteUrl
string read-only $authority
string read-only $hostUrl
array<string,mixed> read-only $queryParameters

Methods

__construct(Url $url)

No description

withScheme(string $scheme)

No description

string
getScheme()

No description

withUser(string $user)

No description

string
getUser()

No description

withPassword(string $password)

No description

string
getPassword()

No description

withoutUserInfo()

No description

withHost(string $host)

No description

string
getHost()

No description

string
getDomain(int $level = 2)

Returns the specified number of rightmost domain labels (e.g. level 2 of 'www.nette.org' -> 'nette.org').

withPort(int $port)

No description

int|null
getPort()

Returns the port number, falling back to the default port for the scheme if not explicitly set.

int|null
getDefaultPort()

Returns the default port for the current scheme, or null if the scheme is not recognized.

withPath(string $path)

No description

string
getPath()

No description

withQuery(string|array $query)

No description

string
getQuery()

No description

withQueryParameter(string $name, mixed $value)

No description

array
getQueryParameters()

No description

array|string|null
getQueryParameter(string $name)

No description

withFragment(string $fragment)

No description

string
getFragment()

No description

string
getAbsoluteUrl()

No description

string
getAuthority()

Returns the [user[:pass]@]host[:port] part of URI.

string
getHostUrl()

Returns the scheme and authority part of URI.

string
__toString()

No description

bool
isEqual(Url|self $url)

Checks whether two URLs are equal, ignoring query parameter order and trailing dots in hostnames.

resolve(string $reference)

Resolves a URI reference against this URL the same way a browser would.

string
mergePath(string $path)

No description

string
jsonSerialize()

No description

array
export()

No description

Details

at line 61
__construct(Url $url)

No description

Parameters

Url $url

Exceptions

InvalidArgumentException

at line 68
UrlImmutable withScheme(string $scheme)

No description

Parameters

string $scheme

Return Value

UrlImmutable

at line 77
string getScheme()

No description

Return Value

string

at line 83
UrlImmutable withUser(string $user)

No description

Parameters

string $user

Return Value

UrlImmutable

at line 94
string getUser()

No description

Return Value

string

at line 102
UrlImmutable withPassword(string $password)

No description

Parameters

string $password

Return Value

UrlImmutable

at line 113
string getPassword()

No description

Return Value

string

at line 121
UrlImmutable withoutUserInfo()

No description

Return Value

UrlImmutable

at line 132
UrlImmutable withHost(string $host)

No description

Parameters

string $host

Return Value

UrlImmutable

at line 141
string getHost()

No description

Return Value

string

at line 151
string getDomain(int $level = 2)

Returns the specified number of rightmost domain labels (e.g. level 2 of 'www.nette.org' -> 'nette.org').

Negative values trim from the right instead.

Parameters

int $level

Return Value

string

at line 163
UrlImmutable withPort(int $port)

No description

Parameters

int $port

Return Value

UrlImmutable

at line 175
int|null getPort()

Returns the port number, falling back to the default port for the scheme if not explicitly set.

Return Value

int|null

at line 184
int|null getDefaultPort()

Returns the default port for the current scheme, or null if the scheme is not recognized.

Return Value

int|null

at line 190
UrlImmutable withPath(string $path)

No description

Parameters

string $path

Return Value

UrlImmutable

at line 203
string getPath()

No description

Return Value

string

at line 210
UrlImmutable withQuery(string|array $query)

No description

Parameters

string|array $query

Return Value

UrlImmutable

at line 218
string getQuery()

No description

Return Value

string

at line 224
UrlImmutable withQueryParameter(string $name, mixed $value)

No description

Parameters

string $name
mixed $value

Return Value

UrlImmutable

at line 233
array getQueryParameters()

No description

Return Value

array

at line 240
array|string|null getQueryParameter(string $name)

No description

Parameters

string $name

Return Value

array|string|null

at line 246
UrlImmutable withFragment(string $fragment)

No description

Parameters

string $fragment

Return Value

UrlImmutable

at line 254
string getFragment()

No description

Return Value

string

at line 260
string getAbsoluteUrl()

No description

Return Value

string

at line 271
string getAuthority()

Returns the [user[:pass]@]host[:port] part of URI.

Return Value

string

at line 288
string getHostUrl()

Returns the scheme and authority part of URI.

Return Value

string

at line 295
string __toString()

No description

Return Value

string

at line 304
bool isEqual(Url|self $url)

Checks whether two URLs are equal, ignoring query parameter order and trailing dots in hostnames.

Parameters

Url|self $url

Return Value

bool

at line 314
UrlImmutable resolve(string $reference)

Resolves a URI reference against this URL the same way a browser would.

Relative paths are resolved against the current path; paths starting with / are resolved against the host root.

Parameters

string $reference

Return Value

UrlImmutable

at line 345
protected string mergePath(string $path)

internal  
 

No description

Parameters

string $path

Return Value

string

at line 352
string jsonSerialize()

No description

Return Value

string

at line 362
final array export()

internal  
 

No description

Return Value

array

Traits

SmartObject