class UriPattern (View source)

Provides PCRE based matching for URIs.

Methods

__construct()

Creates a new instance of UriPattern.

allowNonAscii(bool $enabled = true)

Allows or forbids non ascii characters in some parts of the URI.

bool
matchUri(string $uri, array $matches = [])

Matches the string against URI or relative-ref ABNF.

bool
matchAbsoluteUri(string $uri, array $matches = [])

Matches the string against the URI ABNF.

bool
matchRelativeUri(string $uri, array $matches = [])

Matches the string against the relative-ref ABNF.

bool
matchScheme(string $scheme, array $matches = [])

Matches the string against the scheme ABNF.

bool
matchHost(string $host, array $matches = [])

Matches the string against the host ABNF.

Details

__construct()

Creates a new instance of UriPattern.

allowNonAscii(bool $enabled = true)

Allows or forbids non ascii characters in some parts of the URI.

When enabled, non ascii characters are allowed in userinfo, reg_name, path, query and fragment parts of the URI. Note that pattern does not verify whether the bytes actually form valid UTF-8 sequences or not. Enabling this option simply allows bytes within the range of x80-xFF.

Parameters

bool $enabled True to allow, false to forbid

bool matchUri(string $uri, array $matches = [])

Matches the string against URI or relative-ref ABNF.

Parameters

string $uri The string to match
array $matches Provides the matched sub sections from the match

Return Value

bool True if the URI matches, false if not

bool matchAbsoluteUri(string $uri, array $matches = [])

Matches the string against the URI ABNF.

Parameters

string $uri The string to match
array $matches Provides the matched sub sections from the match

Return Value

bool True if the URI matches, false if not

bool matchRelativeUri(string $uri, array $matches = [])

Matches the string against the relative-ref ABNF.

Parameters

string $uri The string to match
array $matches Provides the matched sub sections from the match

Return Value

bool True if the URI matches, false if not

bool matchScheme(string $scheme, array $matches = [])

Matches the string against the scheme ABNF.

Parameters

string $scheme The string to match
array $matches Provides the matched sub sections from the match

Return Value

bool True if the scheme matches, false if not

bool matchHost(string $host, array $matches = [])

Matches the string against the host ABNF.

Parameters

string $host The string to match
array $matches Provides the matched sub sections from the match

Return Value

bool True if the host matches, false if not