PHP Class Symfony\Component\HttpFoundation\HeaderBag

Author: Fabien Potencier ([email protected])
Afficher le fichier Open project: symfony/symfony Class Usage Examples

Protected Properties

Свойство Type Description
$cacheControl
$headers

Méthodes publiques

Méthode 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.

Méthodes protégées

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

Method Details

__construct() public méthode

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

__toString() public méthode

Returns the headers as a string.
public __toString ( ) : string
Résultat string The headers

add() public méthode

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

addCacheControlDirective() public méthode

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 méthode

Returns the headers.
public all ( ) : array
Résultat array An array of headers

contains() public méthode

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
Résultat boolean true if the value is contained in the header, false otherwise

count() public méthode

Returns the number of headers.
public count ( ) : integer
Résultat integer The number of headers

get() public méthode

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
Résultat string | array The first header value if $first is true, an array of values otherwise

getCacheControlDirective() public méthode

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

getCacheControlHeader() protected méthode

protected getCacheControlHeader ( )

getDate() public méthode

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
Résultat null | DateTime The parsed DateTime or the default value if the header does not exist

getIterator() public méthode

Returns an iterator for headers.
public getIterator ( ) : ArrayIterator
Résultat ArrayIterator An \ArrayIterator instance

has() public méthode

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

hasCacheControlDirective() public méthode

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

keys() public méthode

Returns the parameter keys.
public keys ( ) : array
Résultat array An array of parameter keys

parseCacheControl() protected méthode

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

remove() public méthode

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

removeCacheControlDirective() public méthode

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

replace() public méthode

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

set() public méthode

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