\Jkphl\UtilityUrl

URL manipulation class

Summary

Methods
Properties
Constants
__construct()
set()
addQuery()
removeQuery()
sanitize()
absolutize()
isRelative()
__get()
__set()
__toString()
instance()
No public properties found
No constants found
No protected methods found
$_url
$_parts
$_keys
N/A
No private methods found
No private properties found
N/A

Properties

$_url

$_url : \string

Original URL string

Type

\string

$_parts

$_parts : \array

URL parts

Type

\array

$_keys

$_keys : array

URL part constant / key name mapping

Type

array

Methods

__construct()

__construct(\string $url, \boolean $sanitize) : \Jkphl\Utility\Url

Constructor

Parameters

\string $url

Original URL

\boolean $sanitize

Sanitize URL

Returns

\Jkphl\Utility\Url

URL manipulation object

set()

set(\string $key, \mixed $value) : \Jkphl\Utility\Url

Set a specific URL part

Parameters

\string $key

Part key

\mixed $value

Value

Returns

\Jkphl\Utility\Url

URL manipulation object

addQuery()

addQuery(\array $params) : \Jkphl\Utility\Url

Add query parameters

Parameters

\array $params

Add query parameters to the URL (key / value pairs, also nested)

Returns

\Jkphl\Utility\Url

URL manipulation object

removeQuery()

removeQuery(\array $params) : \Jkphl\Utility\Url

Remove specific query parameters from URL

Parameters

\array $params

Query parameter names to remove from the URL

Returns

\Jkphl\Utility\Url

URL manipulation object

sanitize()

sanitize() : \Jkphl\Utility\Url

Sanitize some default URL parts

Returns

\Jkphl\Utility\Url

URL manipulation object

absolutize()

absolutize(\Jkphl\Utility\Url $reference) : \Jkphl\Utility\Url

Resolve this URL against a reference URL (in case this one is relative or otherwise incomplete)

Parameters

\Jkphl\Utility\Url $reference

Reference URL

Returns

\Jkphl\Utility\Url

URL manipulation object

isRelative()

isRelative() : \boolean

Return whether this URL is relative

Returns

\boolean —

Whether this URL is relative

__get()

__get(\string $key) : \mixed

Return a specific URL part (generic getter)

Parameters

\string $key

Property key

Returns

\mixed —

Property value

__set()

__set(\string $key, \mixed $value) : \Jkphl\Utility\Url

Set a specific URL part (generic setter)

Parameters

\string $key

Key

\mixed $value

Value

Returns

\Jkphl\Utility\Url

URL manipulation object

__toString()

__toString() : \string

String serialization

Returns

\string —

URL string

instance()

instance(\string $url, \boolean $sanitize, \string|\Jkphl\Utility\Url $resolve) : \Jkphl\Utility\Url

Create and return a (possibly sanitized and resolved) URL manipulation object

Parameters

\string $url

Original URL

\boolean $sanitize

Sanitize URL

\string|\Jkphl\Utility\Url $resolve

URL (string or object) to resolve the new one against

Returns

\Jkphl\Utility\Url

URL manipulation object