HeaderBag (Component\HttpFoundation)
Symfony\Component\HttpFoundation\HeaderBag
class HeaderBag implements IteratorAggregate, Countable
HeaderBag is a container for HTTP headers.
Methods
__construct(array $headers = array()) Constructor. | ||
string | __toString() Returns the headers as a string. | |
array | all() Returns the headers. | |
array | keys() Returns the parameter keys. | |
replace(array $headers = array()) Replaces the current HTTP headers by a new set. | ||
add(array $headers) Adds new headers the current HTTP headers set. | ||
string|array | get(string $key, mixed $default = null, bool $first = true) Returns a header value by name. | |
set(string $key, string|array $values, bool $replace = true) Sets a header by name. | ||
bool | has(string $key) Returns true if the HTTP header is defined. | |
bool | contains(string $key, string $value) Returns true if the given HTTP header contains the given value. | |
remove(string $key) Removes a header. | ||
null|DateTime | getDate(string $key, DateTime $default = null) Returns the HTTP header value converted to a date. | |
addCacheControlDirective(string $key, mixed $value = true) Adds a custom Cache-Control directive. | ||
bool | hasCacheControlDirective(string $key) Returns true if the Cache-Control directive is defined. | |
mixed|null | getCacheControlDirective(string $key) Returns a Cache-Control directive value by name. | |
removeCacheControlDirective(string $key) Removes a Cache-Control directive. | ||
ArrayIterator | getIterator() Returns an iterator for headers. | |
int | count() Returns the number of headers. |
Details
public __construct(array $headers = array())
Constructor.
public string __toString()
Returns the headers as a string.
public array all()
Returns the headers.
public array keys()
Returns the parameter keys.
public replace(array $headers = array())
Replaces the current HTTP headers by a new set.
public add(array $headers)
Adds new headers the current HTTP headers set.
public string|array get(string $key, mixed $default = null, bool $first = true)
Returns a header value by name.
public set(string $key, string|array $values, bool $replace = true)
Sets a header by name.
public bool has(string $key)
Returns true if the HTTP header is defined.
public bool contains(string $key, string $value)
Returns true if the given HTTP header contains the given value.
public remove(string $key)
Removes a header.
public null|DateTime getDate(string $key, DateTime $default = null)
Returns the HTTP header value converted to a date.
public addCacheControlDirective(string $key, mixed $value = true)
Adds a custom Cache-Control directive.
public bool hasCacheControlDirective(string $key)
Returns true if the Cache-Control directive is defined.
public mixed|null getCacheControlDirective(string $key)
Returns a Cache-Control directive value by name.
public removeCacheControlDirective(string $key)
Removes a Cache-Control directive.
public ArrayIterator getIterator()
Returns an iterator for headers.
public int count()
Returns the number of headers.
© 2004–2016 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/3.0/Symfony/Component/HttpFoundation/HeaderBag.html