URL class
Framework\HTTP\URL
Class URL.
Implements:
JsonSerializable, Stringable
Defined in libraries/http/src/URL.php
Properties #
- $fragment
- The #fragment (id).
- $hostname
- -
- $pass
- -
- $pathSegments
- The /paths/of/url.
- $port
- -
- $queryData
- The ?queries.
- $scheme
- -
- $user
- -
$fragment
protected ?string $fragment = NULL
The #fragment (id).
$hostname
protected ?string $hostname = NULL
$pass
protected ?string $pass = NULL
$pathSegments
protected array $pathSegments = array (
)
The /paths/of/url.
$port
protected ?int $port = NULL
$queryData
protected array $queryData = array (
)
The ?queries.
$scheme
protected ?string $scheme = NULL
$user
protected ?string $user = NULL
Methods #
- __construct()
- URL constructor.
- __toString()
- -
- addQueries()
- -
- addQuery()
- -
- getBaseUrl()
- -
- getFragment()
- -
- getHost()
- -
- getHostname()
- -
- getOrigin()
- -
- getParsedUrl()
- -
- getPass()
- -
- getPath()
- -
- getPathSegment()
- -
- getPathSegments()
- -
- getPort()
- -
- getQuery()
- Get the "Query" part of the URL.
- getQueryData()
- -
- getRelative()
- Get the relative URL.
- getScheme()
- -
- getUrl()
- -
- getUser()
- -
- jsonSerialize()
- -
- removeQueryData()
- -
- setFragment()
- -
- setHostname()
- -
- setPass()
- -
- setPath()
- -
- setPathSegments()
- -
- setPort()
- -
- setQuery()
- -
- setQueryData()
- -
- setScheme()
- -
- setUser()
- -
- toString()
- -
- filterQuery()
- -
- getPortPart()
- -
- setUrl()
- -
__construct()
public function __construct(string $url)
URL constructor.
Parameters
- string $url - An absolute URL
__toString()
public function __toString(): string
Returns
string
addQueries()
public function addQueries(array $queries): static
Parameters
- array $queries
Returns
static
addQuery()
public function addQuery(string $query, string|int|null $value = NULL): static
Parameters
- string $query
- string|int|null $value
Returns
static
getBaseUrl()
public function getBaseUrl(string $path = '/'): string
Parameters
- string $path
Returns
string
getFragment()
public function getFragment(): ?string
Returns
?string
getHost()
public function getHost(): ?string
Returns
?string
getHostname()
public function getHostname(): ?string
Returns
?string
getOrigin()
public function getOrigin(): string
Returns
string
getParsedUrl()
public function getParsedUrl(): array
Returns
array
getPass()
public function getPass(): ?string
Returns
?string
getPath()
public function getPath(): string
Returns
string
getPathSegment()
public function getPathSegment(int $index): ?string
Parameters
- int $index
Returns
?string
getPathSegments()
public function getPathSegments(): array
Returns
array
getPort()
public function getPort(): ?int
Returns
?int
getQuery()
public function getQuery(array $allowedKeys = array (
)): ?string
Get the "Query" part of the URL.
Parameters
- array $allowedKeys - Allowed query keys
Returns
?string
getQueryData()
public function getQueryData(array $allowedKeys = array (
)): array
Parameters
- array $allowedKeys
Returns
array
getRelative()
public function getRelative(): string
Get the relative URL.
Returns
string
getScheme()
public function getScheme(): ?string
Returns
?string
getUrl()
public function getUrl(): string
Returns
string
getUser()
public function getUser(): ?string
Returns
?string
jsonSerialize()
public function jsonSerialize(): string
Returns
string
removeQueryData()
public function removeQueryData(string $key): static
Parameters
- string $key
Returns
static
setFragment()
public function setFragment(string $fragment): static
Parameters
- string $fragment
Returns
static
setHostname()
public function setHostname(string $hostname): static
Parameters
- string $hostname
Returns
static
setPass()
public function setPass(string $pass): static
Parameters
- string $pass
Returns
static
setPath()
public function setPath(string $segments): static
Parameters
- string $segments
Returns
static
setPathSegments()
public function setPathSegments(array $segments): static
Parameters
- array $segments
Returns
static
setPort()
public function setPort(int $port): static
Parameters
- int $port
Returns
static
setQuery()
public function setQuery(string $data, array $only = array (
)): static
Parameters
- string $data
- array $only
Returns
static
setQueryData()
public function setQueryData(array $data, array $only = array (
)): static
Parameters
- array $data
- array $only
Returns
static
setScheme()
public function setScheme(string $scheme): static
Parameters
- string $scheme
Returns
static
setUser()
public function setUser(string $user): static
Parameters
- string $user
Returns
static
toString()
public function toString(): string
Returns
string
filterQuery()
protected function filterQuery(array $allowed): array
Parameters
- array $allowed
Returns
array
getPortPart()
protected function getPortPart(): string
Returns
string
setUrl()
protected function setUrl(string $url): static
Parameters
- string $url
Returns
static