final class AllowedHostMatcher (View source)

internal  
 

Compiles exact hostnames and bounded suffix wildcards for request-origin validation.

Methods

__construct(array $allowedHosts = [])

Validates and compiles host patterns without interpreting an empty list as unrestricted access.

bool
allows(string $host)

Reports whether a normalized request host matches one explicit pattern.

bool
bool
isValidHost(string $host)

Reports whether a host is an IP literal or a canonical ASCII DNS hostname.

bool
string
normalizeHost(string $host)

Canonicalizes case and one DNS root marker before comparison.

string

Details

__construct

__construct(array $allowedHosts = [])

Validates and compiles host patterns without interpreting an empty list as unrestricted access.

Parameters

array $allowedHosts

Exceptions

InvalidArgumentException

allows

bool allows(string $host)

Reports whether a normalized request host matches one explicit pattern.

Parameters

string $host

Return Value

bool

isValidHost

bool isValidHost(string $host)

Reports whether a host is an IP literal or a canonical ASCII DNS hostname.

Parameters

string $host

Return Value

bool

normalizeHost

string normalizeHost(string $host)

Canonicalizes case and one DNS root marker before comparison.

Parameters

string $host

Return Value

string