Aplus Framework Docs

URL
in package
implements JsonSerializable, Stringable

Class URL.

Tags
see
https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Identifying_resources_on_the_Web#urls
see
https://developer.mozilla.org/en-US/docs/Web/API/URL
see
https://datatracker.ietf.org/doc/html/rfc3986#section-3

Interfaces, Classes, Traits and Enums

JsonSerializable
Stringable

Table of Contents

$fragment  : string|null
The #fragment (id).
$hostname  : string|null
$pass  : string|null
$pathSegments  : array<string|int, mixed>
The /paths/of/url.
$port  : int|null
$queryData  : array<string|int, mixed>
The ?queries.
$scheme  : string|null
$user  : string|null
__construct()  : mixed
URL constructor.
__toString()  : string
addQueries()  : static
addQuery()  : static
getAsString()  : string
getBaseUrl()  : string
getFragment()  : string|null
getHost()  : string|null
getHostname()  : string|null
getOrigin()  : string
getParsedUrl()  : array<string, mixed>
getPass()  : string|null
getPath()  : string
getPathSegment()  : string|null
getPathSegments()  : array<int, string>
getPort()  : int|null
getQuery()  : string|null
Get the "Query" part of the URL.
getQueryData()  : array<string, mixed>
getScheme()  : string|null
getUser()  : string|null
jsonSerialize()  : string
removeQueryData()  : static
setFragment()  : static
setHostname()  : static
setPass()  : static
setPath()  : static
setPathSegments()  : static
setPort()  : static
setQuery()  : static
setQueryData()  : static
setScheme()  : static
setUser()  : static
toString()  : string
filterQuery()  : array<string, mixed>
getPortPart()  : string
setUrl()  : static

Properties

$fragment

The #fragment (id).

protected string|null $fragment = null

$hostname

protected string|null $hostname = null

$pass

protected string|null $pass = null

$pathSegments

The /paths/of/url.

protected array<string|int, mixed> $pathSegments = []

$port

protected int|null $port = null

$queryData

The ?queries.

protected array<string|int, mixed> $queryData = []

$scheme

protected string|null $scheme = null

$user

protected string|null $user = null

Methods

__construct()

URL constructor.

public __construct(string $url) : mixed
Parameters
$url : string
Return values
mixed

__toString()

public __toString() : string
Return values
string

addQueries()

public addQueries(array<string, int|string|null> $queries) : static
Parameters
$queries : array<string, int|string|null>
Return values
static

addQuery()

public addQuery(string $query[, int|string|null $value = null ]) : static
Parameters
$query : string
$value : int|string|null = null
Return values
static

getAsString()

public getAsString() : string
Tags
deprecated

Use URL::toString()

codeCoverageIgnore
Return values
string

getBaseUrl()

public getBaseUrl([string $path = '/' ]) : string
Parameters
$path : string = '/'
Return values
string

getFragment()

public getFragment() : string|null
Return values
string|null

getHost()

public getHost() : string|null
Return values
string|null

getHostname()

public getHostname() : string|null
Return values
string|null

getOrigin()

public getOrigin() : string
Return values
string

getParsedUrl()

public getParsedUrl() : array<string, mixed>
Return values
array<string, mixed>

getPass()

public getPass() : string|null
Return values
string|null

getPath()

public getPath() : string
Return values
string

getPathSegment()

public getPathSegment(int $index) : string|null
Parameters
$index : int
Return values
string|null

getPathSegments()

public getPathSegments() : array<int, string>
Return values
array<int, string>

getPort()

public getPort() : int|null
Return values
int|null

getQuery()

Get the "Query" part of the URL.

public getQuery([array<int, string> $allowedKeys = [] ]) : string|null
Parameters
$allowedKeys : array<int, string> = []

Allowed query keys

Return values
string|null

getQueryData()

public getQueryData([array<int, string> $allowedKeys = [] ]) : array<string, mixed>
Parameters
$allowedKeys : array<int, string> = []
Return values
array<string, mixed>

getScheme()

public getScheme() : string|null
Return values
string|null

getUser()

public getUser() : string|null
Return values
string|null

jsonSerialize()

public jsonSerialize() : string
Return values
string

removeQueryData()

public removeQueryData(string $key) : static
Parameters
$key : string
Return values
static

setFragment()

public setFragment(string $fragment) : static
Parameters
$fragment : string
Return values
static

setHostname()

public setHostname(string $hostname) : static
Parameters
$hostname : string
Tags
throws
InvalidArgumentException

for invalid URL Hostname

Return values
static

setPass()

public setPass(string $pass) : static
Parameters
$pass : string
Return values
static

setPath()

public setPath(string $segments) : static
Parameters
$segments : string
Return values
static

setPathSegments()

public setPathSegments(array<int, string> $segments) : static
Parameters
$segments : array<int, string>
Return values
static

setPort()

public setPort(int $port) : static
Parameters
$port : int
Tags
throws
InvalidArgumentException

for invalid URL Port

Return values
static

setQuery()

public setQuery(string $data[, array<string|int, string> $only = [] ]) : static
Parameters
$data : string
$only : array<string|int, string> = []
Return values
static

setQueryData()

public setQueryData(array<string|int, mixed> $data[, array<string|int, string> $only = [] ]) : static
Parameters
$data : array<string|int, mixed>
$only : array<string|int, string> = []
Return values
static

setScheme()

public setScheme(string $scheme) : static
Parameters
$scheme : string
Return values
static

setUser()

public setUser(string $user) : static
Parameters
$user : string
Return values
static

toString()

public toString() : string
Tags
since
5.3
Return values
string

filterQuery()

protected filterQuery(array<int, string> $allowed) : array<string, mixed>
Parameters
$allowed : array<int, string>
Return values
array<string, mixed>

getPortPart()

protected getPortPart() : string
Return values
string

setUrl()

protected setUrl(string $url) : static
Parameters
$url : string
Tags
throws
InvalidArgumentException

for invalid URL

Return values
static

Search results