KMP PHP API Reference

UrlComparerTrait

A trait that provides a method to compare url.

Table of Contents

Properties

$_parts  : array<string|int, mixed>
Parts of the URL used for normalization.

Methods

compareUrls()  : bool
Check if first URL is a parent of the right URL, without regards to query parameters or hash.
_hostname()  : string|null
Retrieve the hostname (if any).
_matchHost()  : bool
Checks if the given URL components match the current host.
_matchRelative()  : bool
Checks if the given URL components match the current relative URL. This methods only works with full URL, and do not check the host.
_normalize()  : string|null
Normalize an URL.
_relative()  : string
Retrieve the relative path of the root URL from hostname.
_removeRelative()  : string
Remove relative part an URL (if any).

Properties

$_parts

Parts of the URL used for normalization.

protected array<string|int, mixed> $_parts = ["plugin", "prefix", "controller", "action", "pass"]

Methods

compareUrls()

Check if first URL is a parent of the right URL, without regards to query parameters or hash.

public compareUrls(string|array<string|int, mixed> $lhs[, string|array<string|int, mixed> $rhs = null ][, array<string|int, mixed> $parts = [] ]) : bool
Parameters
$lhs : string|array<string|int, mixed>

First URL to compare.

$rhs : string|array<string|int, mixed> = null

Second URL to compare. Default is current URL (Router::url()).

$parts : array<string|int, mixed> = []

Include pass parameters

Return values
bool

true if both URL match, false otherwise.

_hostname()

Retrieve the hostname (if any).

protected _hostname() : string|null
Return values
string|null

The hostname, or null.

_matchHost()

Checks if the given URL components match the current host.

protected _matchHost(string $url) : bool
Parameters
$url : string

URL to check.

Return values
bool

true if the URL matches, false otherwise.

_matchRelative()

Checks if the given URL components match the current relative URL. This methods only works with full URL, and do not check the host.

protected _matchRelative(string $url) : bool
Parameters
$url : string

URL to check.

Return values
bool

true if the URL matches, false otherwise.

_normalize()

Normalize an URL.

protected _normalize(string|array<string|int, mixed> $url[, array<string|int, mixed> $parts = [] ]) : string|null
Parameters
$url : string|array<string|int, mixed>

URL to normalize.

$parts : array<string|int, mixed> = []

Include pass parameters.

Return values
string|null

Normalized URL.

_relative()

Retrieve the relative path of the root URL from hostname.

protected _relative() : string
Return values
string

The relative path.

_removeRelative()

Remove relative part an URL (if any).

protected _removeRelative(string $url) : string
Parameters
$url : string

URL from which the relative part should be removed.

Return values
string

The new URL.


        
On this page

Search results