final class HeaderBag (View source)

Stores HTTP header values under case-insensitive canonical names.

Methods

__construct(array $headers = [])

Initializes the bag while normalizing every supplied header name.

array
all()

Returns all headers keyed by their canonical names.

array
bool
has(string $name)

Reports whether a header exists regardless of name casing or underscores.

bool
mixed
get(string $name, mixed $default = null)

Returns a header value by normalized name or the supplied fallback.

mixed
void
set(string $name, string $value)

Replaces the value stored under a normalized header name.

void

Details

__construct

__construct(array $headers = [])

Initializes the bag while normalizing every supplied header name.

Parameters

array $headers

all

array all()

Returns all headers keyed by their canonical names.

Return Value

array

has

bool has(string $name)

Reports whether a header exists regardless of name casing or underscores.

Parameters

string $name

Return Value

bool

get

mixed get(string $name, mixed $default = null)

Returns a header value by normalized name or the supplied fallback.

Parameters

string $name
mixed $default

Return Value

mixed

set

void set(string $name, string $value)

Replaces the value stored under a normalized header name.

Parameters

string $name
string $value

Return Value

void