PHP Class Symfony\Component\HttpFoundation\HeaderBag

Author: Fabien Potencier ([email protected])
Mostra file Open project: symfony/symfony Class Usage Examples

Protected Properties

Property Type Description
$cacheControl
$headers

Public Methods

Method Description
__construct ( array $headers = [] ) Constructor.
__toString ( ) : string Returns the headers as a string.
add ( array $headers ) Adds new headers the current HTTP headers set.
addCacheControlDirective ( string $key, mixed $value = true ) Adds a custom Cache-Control directive.
all ( ) : array Returns the headers.
contains ( string $key, string $value ) : boolean Returns true if the given HTTP header contains the given value.
count ( ) : integer Returns the number of headers.
get ( string $key, mixed $default = null, boolean $first = true ) : string | array Returns a header value by name.
getCacheControlDirective ( string $key ) : mixed | null Returns a Cache-Control directive value by name.
getDate ( string $key, DateTime $default = null ) : null | DateTime Returns the HTTP header value converted to a date.
getIterator ( ) : ArrayIterator Returns an iterator for headers.
has ( string $key ) : boolean Returns true if the HTTP header is defined.
hasCacheControlDirective ( string $key ) : boolean Returns true if the Cache-Control directive is defined.
keys ( ) : array Returns the parameter keys.
remove ( string $key ) Removes a header.
removeCacheControlDirective ( string $key ) Removes a Cache-Control directive.
replace ( array $headers = [] ) Replaces the current HTTP headers by a new set.
set ( string $key, string | array $values, boolean $replace = true ) Sets a header by name.

Protected Methods

Method Description
getCacheControlHeader ( )
parseCacheControl ( string $header ) : array Parses a Cache-Control HTTP header.

Method Details

__construct() public method

Constructor.
public __construct ( array $headers = [] )
$headers array An array of HTTP headers

__toString() public method

Returns the headers as a string.
public __toString ( ) : string
return string The headers

add() public method

Adds new headers the current HTTP headers set.
public add ( array $headers )
$headers array An array of HTTP headers

addCacheControlDirective() public method

Adds a custom Cache-Control directive.
public addCacheControlDirective ( string $key, mixed $value = true )
$key string The Cache-Control directive name
$value mixed The Cache-Control directive value

all() public method

Returns the headers.
public all ( ) : array
return array An array of headers

contains() public method

Returns true if the given HTTP header contains the given value.
public contains ( string $key, string $value ) : boolean
$key string The HTTP header name
$value string The HTTP value
return boolean true if the value is contained in the header, false otherwise

count() public method

Returns the number of headers.
public count ( ) : integer
return integer The number of headers

get() public method

Returns a header value by name.
public get ( string $key, mixed $default = null, boolean $first = true ) : string | array
$key string The header name
$default mixed The default value
$first boolean Whether to return the first value or all header values
return string | array The first header value if $first is true, an array of values otherwise

getCacheControlDirective() public method

Returns a Cache-Control directive value by name.
public getCacheControlDirective ( string $key ) : mixed | null
$key string The directive name
return mixed | null The directive value if defined, null otherwise

getCacheControlHeader() protected method

protected getCacheControlHeader ( )

getDate() public method

Returns the HTTP header value converted to a date.
public getDate ( string $key, DateTime $default = null ) : null | DateTime
$key string The parameter key
$default DateTime The default value
return null | DateTime The parsed DateTime or the default value if the header does not exist

getIterator() public method

Returns an iterator for headers.
public getIterator ( ) : ArrayIterator
return ArrayIterator An \ArrayIterator instance

has() public method

Returns true if the HTTP header is defined.
public has ( string $key ) : boolean
$key string The HTTP header
return boolean true if the parameter exists, false otherwise

hasCacheControlDirective() public method

Returns true if the Cache-Control directive is defined.
public hasCacheControlDirective ( string $key ) : boolean
$key string The Cache-Control directive
return boolean true if the directive exists, false otherwise

keys() public method

Returns the parameter keys.
public keys ( ) : array
return array An array of parameter keys

parseCacheControl() protected method

Parses a Cache-Control HTTP header.
protected parseCacheControl ( string $header ) : array
$header string The value of the Cache-Control HTTP header
return array An array representing the attribute values

remove() public method

Removes a header.
public remove ( string $key )
$key string The HTTP header name

removeCacheControlDirective() public method

Removes a Cache-Control directive.
public removeCacheControlDirective ( string $key )
$key string The Cache-Control directive

replace() public method

Replaces the current HTTP headers by a new set.
public replace ( array $headers = [] )
$headers array An array of HTTP headers

set() public method

Sets a header by name.
public set ( string $key, string | array $values, boolean $replace = true )
$key string The key
$values string | array The value or an array of values
$replace boolean Whether to replace the actual value or not (true by default)

Property Details

$cacheControl protected_oe property

protected $cacheControl

$headers protected_oe property

protected $headers