HeaderBag
class HeaderBag implements IteratorAggregate, Countable
HeaderBag is a container for HTTP headers.
Methods
Constructor.
Returns the headers as a string.
Returns the headers.
Returns the parameter keys.
Replaces the current HTTP headers by a new set.
Adds new headers the current HTTP headers set.
Returns a header value by name.
Sets a header by name.
Returns true if the HTTP header is defined.
Returns true if the given HTTP header contains the given value.
Removes a header.
Adds a custom Cache-Control directive.
Returns true if the Cache-Control directive is defined.
Returns a Cache-Control directive value by name.
Removes a Cache-Control directive.
Returns an iterator for headers.
Returns the number of headers.
Details
at line line 29
__construct(array $headers = array())
Constructor.
at line line 41
string
__toString()
Returns the headers as a string.
at line line 65
array
all()
Returns the headers.
at line line 75
array
keys()
Returns the parameter keys.
at line line 85
replace(array $headers = array())
Replaces the current HTTP headers by a new set.
at line line 96
add(array $headers)
Adds new headers the current HTTP headers set.
at line line 112
string|array
get(string $key, mixed $default = null, bool $first = true)
Returns a header value by name.
at line line 138
set(string $key, string|array $values, bool $replace = true)
Sets a header by name.
at line line 162
bool
has(string $key)
Returns true if the HTTP header is defined.
at line line 175
bool
contains(string $key, string $value)
Returns true if the given HTTP header contains the given value.
at line line 185
remove(string $key)
Removes a header.
at line line 206
null|DateTime
getDate(string $key, DateTime $default = null)
Returns the HTTP header value converted to a date.
at line line 225
addCacheControlDirective(string $key, mixed $value = true)
Adds a custom Cache-Control directive.
at line line 239
bool
hasCacheControlDirective(string $key)
Returns true if the Cache-Control directive is defined.
at line line 251
mixed|null
getCacheControlDirective(string $key)
Returns a Cache-Control directive value by name.
at line line 261
removeCacheControlDirective(string $key)
Removes a Cache-Control directive.
at line line 273
ArrayIterator
getIterator()
Returns an iterator for headers.
at line line 283
int
count()
Returns the number of headers.