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) deprecated

No description

string
getUser() deprecated

No description

withPassword(string $password) deprecated

No description

string
getPassword() deprecated

No description

withoutUserInfo() deprecated

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 84
UrlImmutable withUser(string $user) deprecated

deprecated

No description

Parameters

string $user

Return Value

UrlImmutable

at line 94
string getUser() deprecated

deprecated

No description

Return Value

string

at line 101
UrlImmutable withPassword(string $password) deprecated

deprecated

No description

Parameters

string $password

Return Value

UrlImmutable

at line 111
string getPassword() deprecated

deprecated

No description

Return Value

string

at line 118
UrlImmutable withoutUserInfo() deprecated

deprecated

No description

Return Value

UrlImmutable

at line 127
UrlImmutable withHost(string $host)

No description

Parameters

string $host

Return Value

UrlImmutable

at line 136
string getHost()

No description

Return Value

string

at line 146
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 158
UrlImmutable withPort(int $port)

No description

Parameters

int $port

Return Value

UrlImmutable

at line 170
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 179
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 185
UrlImmutable withPath(string $path)

No description

Parameters

string $path

Return Value

UrlImmutable

at line 198
string getPath()

No description

Return Value

string

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

No description

Parameters

string|array $query

Return Value

UrlImmutable

at line 213
string getQuery()

No description

Return Value

string

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

No description

Parameters

string $name
mixed $value

Return Value

UrlImmutable

at line 228
array getQueryParameters()

No description

Return Value

array

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

No description

Parameters

string $name

Return Value

array|string|null

at line 241
UrlImmutable withFragment(string $fragment)

No description

Parameters

string $fragment

Return Value

UrlImmutable

at line 249
string getFragment()

No description

Return Value

string

at line 255
string getAbsoluteUrl()

No description

Return Value

string

at line 266
string getAuthority()

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

Return Value

string

at line 283
string getHostUrl()

Returns the scheme and authority part of URI.

Return Value

string

at line 290
string __toString()

No description

Return Value

string

at line 299
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 309
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 340
protected string mergePath(string $path)

internal  
 

No description

Parameters

string $path

Return Value

string

at line 347
string jsonSerialize()

No description

Return Value

string

at line 357
final array export()

internal  
 

No description

Return Value

array

Traits

SmartObject