FileAccess Orion

HeaderBag
in package
implements IteratorAggregate, Countable

HeaderBag is a container for HTTP headers.

Tags
author

Fabien Potencier fabien@symfony.com

Interfaces, Classes, Traits and Enums

IteratorAggregate
Countable

Table of Contents

LOWER  = '-abcdefghijklmnopqrstuvwxyz'
UPPER  = '_ABCDEFGHIJKLMNOPQRSTUVWXYZ'
$cacheControl  : mixed
$headers  : mixed
__construct()  : mixed
__toString()  : string
Returns the headers as a string.
add()  : mixed
Adds new headers the current HTTP headers set.
addCacheControlDirective()  : mixed
Adds a custom Cache-Control directive.
all()  : array<string|int, mixed>
Returns the headers.
contains()  : bool
Returns true if the given HTTP header contains the given value.
count()  : int
Returns the number of headers.
get()  : string|null
Returns a header value by name.
getCacheControlDirective()  : mixed|null
Returns a Cache-Control directive value by name.
getDate()  : DateTimeInterface|null
Returns the HTTP header value converted to a date.
getIterator()  : ArrayIterator
Returns an iterator for headers.
has()  : bool
Returns true if the HTTP header is defined.
hasCacheControlDirective()  : bool
Returns true if the Cache-Control directive is defined.
keys()  : array<string|int, mixed>
Returns the parameter keys.
remove()  : mixed
Removes a header.
removeCacheControlDirective()  : mixed
Removes a Cache-Control directive.
replace()  : mixed
Replaces the current HTTP headers by a new set.
set()  : mixed
Sets a header by name.
getCacheControlHeader()  : mixed
parseCacheControl()  : array<string|int, mixed>
Parses a Cache-Control HTTP header.

Constants

LOWER

protected mixed LOWER = '-abcdefghijklmnopqrstuvwxyz'

UPPER

protected mixed UPPER = '_ABCDEFGHIJKLMNOPQRSTUVWXYZ'

Properties

$cacheControl

protected mixed $cacheControl = []

Methods

__construct()

public __construct([array<string|int, mixed> $headers = [] ]) : mixed
Parameters
$headers : array<string|int, mixed> = []
Return values
mixed

__toString()

Returns the headers as a string.

public __toString() : string
Return values
string

The headers

add()

Adds new headers the current HTTP headers set.

public add(array<string|int, mixed> $headers) : mixed
Parameters
$headers : array<string|int, mixed>
Return values
mixed

addCacheControlDirective()

Adds a custom Cache-Control directive.

public addCacheControlDirective(string $key[, mixed $value = true ]) : mixed
Parameters
$key : string

The Cache-Control directive name

$value : mixed = true

The Cache-Control directive value

Return values
mixed

all()

Returns the headers.

public all() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of headers

contains()

Returns true if the given HTTP header contains the given value.

public contains(string $key, string $value) : bool
Parameters
$key : string

The HTTP header name

$value : string

The HTTP value

Return values
bool

true if the value is contained in the header, false otherwise

count()

Returns the number of headers.

public count() : int
Return values
int

The number of headers

get()

Returns a header value by name.

public get(string $key[, string|null $default = null ]) : string|null
Parameters
$key : string

The header name

$default : string|null = null

The default value

Return values
string|null

The first header value or default value

getCacheControlDirective()

Returns a Cache-Control directive value by name.

public getCacheControlDirective(string $key) : mixed|null
Parameters
$key : string

The directive name

Return values
mixed|null

The directive value if defined, null otherwise

getDate()

Returns the HTTP header value converted to a date.

public getDate(string $key[, DateTime $default = null ]) : DateTimeInterface|null
Parameters
$key : string

The parameter key

$default : DateTime = null
Tags
throws
RuntimeException

When the HTTP header is not parseable

Return values
DateTimeInterface|null

The parsed DateTime or the default value if the header does not exist

getIterator()

Returns an iterator for headers.

public getIterator() : ArrayIterator
Return values
ArrayIterator

An \ArrayIterator instance

has()

Returns true if the HTTP header is defined.

public has(string $key) : bool
Parameters
$key : string

The HTTP header

Return values
bool

true if the parameter exists, false otherwise

hasCacheControlDirective()

Returns true if the Cache-Control directive is defined.

public hasCacheControlDirective(string $key) : bool
Parameters
$key : string

The Cache-Control directive

Return values
bool

true if the directive exists, false otherwise

keys()

Returns the parameter keys.

public keys() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of parameter keys

remove()

Removes a header.

public remove(string $key) : mixed
Parameters
$key : string

The HTTP header name

Return values
mixed

removeCacheControlDirective()

Removes a Cache-Control directive.

public removeCacheControlDirective(string $key) : mixed
Parameters
$key : string

The Cache-Control directive

Return values
mixed

replace()

Replaces the current HTTP headers by a new set.

public replace([array<string|int, mixed> $headers = [] ]) : mixed
Parameters
$headers : array<string|int, mixed> = []
Return values
mixed

set()

Sets a header by name.

public set(string $key, string|array<string|int, string> $values[, bool $replace = true ]) : mixed
Parameters
$key : string

The key

$values : string|array<string|int, string>

The value or an array of values

$replace : bool = true

Whether to replace the actual value or not (true by default)

Return values
mixed

getCacheControlHeader()

protected getCacheControlHeader() : mixed
Return values
mixed

parseCacheControl()

Parses a Cache-Control HTTP header.

protected parseCacheControl(string $header) : array<string|int, mixed>
Parameters
$header : string

The value of the Cache-Control HTTP header

Return values
array<string|int, mixed>

An array representing the attribute values

Search results