File
vendorSymfonyComponentHttpFoundationHeaderBag.php
Package
Default
Class hierarchy
SymfonyComponentHttpFoundationHeaderBag
Implements

Tags

author

Fabien Potencier fabien@symfony.com

api

Properties

$headers

$headers : 

Type

Tags

None found

$cacheControl

$cacheControl : 

Type

Tags

None found

Methods

__construct()

__construct(array  $headers = array()) 

Constructor.

Parameters

array $headers

An array of HTTP headers

Tags

api

__toString()

__toString() : string

Returns the headers as a string.

Returns

string —

The headers

Tags

None found

all()

all() : array

Returns the headers.

Returns

array —

An array of headers

Tags

api

keys()

keys() : array

Returns the parameter keys.

Returns

array —

An array of parameter keys

Tags

api

replace()

replace(array  $headers = array()) 

Replaces the current HTTP headers by a new set.

Parameters

array $headers

An array of HTTP headers

Tags

api

add()

add(array  $headers) 

Adds new headers the current HTTP headers set.

Parameters

array $headers

An array of HTTP headers

Tags

api

get()

get(string  $key, mixed  $default = null, Boolean  $first = true) : string|array

Returns a header value by name.

Parameters

string $key

The header name

mixed $default

The default value

Boolean $first

Whether to return the first value or all header values

Returns

string|array —

The first header value if $first is true, an array of values otherwise

Tags

api

set()

set(string  $key, string|array  $values, Boolean  $replace = true) 

Sets a header by name.

Parameters

string $key

The key

string|array $values

The value or an array of values

Boolean $replace

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

Tags

api

has()

has(string  $key) : Boolean

Returns true if the HTTP header is defined.

Parameters

string $key

The HTTP header

Returns

Boolean —

true if the parameter exists, false otherwise

Tags

api

contains()

contains(string  $key, string  $value) : Boolean

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

Parameters

string $key

The HTTP header name

string $value

The HTTP value

Returns

Boolean —

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

Tags

api

remove()

remove(string  $key) 

Removes a header.

Parameters

string $key

The HTTP header name

Tags

api

getDate()

getDate(string  $key, \DateTime  $default = null) : null|\DateTime

Returns the HTTP header value converted to a date.

Parameters

string $key

The parameter key

DateTime $default

The default value

Throws

RuntimeException

When the HTTP header is not parseable

Returns

null|DateTime —

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

Tags

api

addCacheControlDirective()

addCacheControlDirective(  $key,   $value = true) 

Parameters

$key
$value

Tags

None found

hasCacheControlDirective()

hasCacheControlDirective(  $key) 

Parameters

$key

Tags

None found

getCacheControlDirective()

getCacheControlDirective(  $key) 

Parameters

$key

Tags

None found

removeCacheControlDirective()

removeCacheControlDirective(  $key) 

Parameters

$key

Tags

None found

getIterator()

getIterator() : \ArrayIterator

Returns an iterator for headers.

Returns

ArrayIterator —

An ArrayIterator instance

Tags

None found

count()

count() : integer

Returns the number of headers.

Returns

integer —

The number of headers

Tags

None found

getCacheControlHeader()

getCacheControlHeader() 

Tags

None found

parseCacheControl()

parseCacheControl(string  $header) : array

Parses a Cache-Control HTTP header.

Parameters

string $header

The value of the Cache-Control HTTP header

Returns

array —

An array representing the attribute values

Tags

None found