final class ServerHelper (View source)

Exposes raw server parameters separately from trust-resolved request origin metadata.

The helper never consults global state and never reparses forwarding headers.

Methods

__construct(ServerRequestInterface $request, ResolvedRequestContext $context)

Binds raw server access and trusted origin access to one explicit request.

string
get(string $key, string $default = '')

Returns one raw server parameter as text or the supplied fallback.

string
bool
has(string $key)

Reports whether one non-empty raw string server parameter is available.

bool
array
all()

Returns the raw server-parameter snapshot carried by the explicit PSR request.

array
string
host(string $default = 'localhost')

Returns the allowlisted host or the explicit fallback when no host was trusted.

string
string
scheme()

Returns the scheme established by the central request trust policy.

string
bool

Reports whether the central request trust policy resolved HTTPS.

bool
string|null
clientIp(string|null $default = null)

Returns the verified client address or the explicit fallback when unavailable.

string|null

Details

__construct

__construct(ServerRequestInterface $request, ResolvedRequestContext $context)

Binds raw server access and trusted origin access to one explicit request.

Parameters

ServerRequestInterface $request
ResolvedRequestContext $context

get

string get(string $key, string $default = '')

Returns one raw server parameter as text or the supplied fallback.

Parameters

string $key
string $default

Return Value

string

has

bool has(string $key)

Reports whether one non-empty raw string server parameter is available.

Parameters

string $key

Return Value

bool

all

array all()

Returns the raw server-parameter snapshot carried by the explicit PSR request.

Return Value

array

host

string host(string $default = 'localhost')

Returns the allowlisted host or the explicit fallback when no host was trusted.

Parameters

string $default

Return Value

string

scheme

string scheme()

Returns the scheme established by the central request trust policy.

Return Value

string

isHttps

bool isHttps()

Reports whether the central request trust policy resolved HTTPS.

Return Value

bool

clientIp

string|null clientIp(string|null $default = null)

Returns the verified client address or the explicit fallback when unavailable.

Parameters

string|null $default

Return Value

string|null