HeaderBag
    
            
            in package
            
        
    
            
            implements
                            IteratorAggregate,                             Countable                    
    
    
        
            HeaderBag is a container for HTTP headers.
Tags
Interfaces, Classes and Traits
- IteratorAggregate
 - Countable
 
Table of Contents
- LOWER = '-abcdefghijklmnopqrstuvwxyz'
 - UPPER = '_ABCDEFGHIJKLMNOPQRSTUVWXYZ'
 - $cacheControl : mixed
 - $headers : array<string, array<int, string|null>>
 - __construct() : mixed
 - __toString() : string
 - Returns the headers as a string.
 - add() : mixed
 - Adds new headers the current HTTP headers set.
 - addCacheControlDirective() : mixed
 - Adds a custom Cache-Control directive.
 - all() : array<string, array<int, string|null>>|array<int, string|null>
 - Returns the headers.
 - contains() : bool
 - Returns true if the given HTTP header contains the given value.
 - count() : int
 - Returns the number of headers.
 - get() : string|null
 - Returns the first header by name or the default one.
 - getCacheControlDirective() : bool|string|null
 - Returns a Cache-Control directive value by name.
 - getDate() : DateTimeInterface|null
 - Returns the HTTP header value converted to a date.
 - getIterator() : ArrayIterator<string, array<int, string|null>>
 - Returns an iterator for headers.
 - has() : bool
 - Returns true if the HTTP header is defined.
 - hasCacheControlDirective() : bool
 - Returns true if the Cache-Control directive is defined.
 - keys() : array<string|int, string>
 - Returns the parameter keys.
 - remove() : mixed
 - Removes a header.
 - removeCacheControlDirective() : mixed
 - Removes a Cache-Control directive.
 - replace() : mixed
 - Replaces the current HTTP headers by a new set.
 - set() : mixed
 - Sets a header by name.
 - getCacheControlHeader() : mixed
 - parseCacheControl() : array<string|int, mixed>
 - Parses a Cache-Control HTTP header.
 
Constants
LOWER
    protected
    mixed
    LOWER
    = '-abcdefghijklmnopqrstuvwxyz'
        
        
    
UPPER
    protected
    mixed
    UPPER
    = '_ABCDEFGHIJKLMNOPQRSTUVWXYZ'
        
        
    
Properties
$cacheControl
    protected
        mixed
    $cacheControl
     = []
        
        
    
$headers
    protected
        array<string, array<int, string|null>>
    $headers
     = []
    
    
    
Methods
__construct()
    public
                __construct([array<string|int, mixed> $headers = [] ]) : mixed
        
        Parameters
- $headers : array<string|int, mixed> = []
 
Return values
mixed —__toString()
Returns the headers as a string.
    public
                __toString() : string
    
    
    
        Return values
string —add()
Adds new headers the current HTTP headers set.
    public
                add(array<string|int, mixed> $headers) : mixed
    
        Parameters
- $headers : array<string|int, mixed>
 
Return values
mixed —addCacheControlDirective()
Adds a custom Cache-Control directive.
    public
                addCacheControlDirective(string $key[, bool|string $value = true ]) : mixed
    
        Parameters
- $key : string
 - $value : bool|string = true
 - 
                    
The Cache-Control directive value
 
Return values
mixed —all()
Returns the headers.
    public
                all([string|null $key = null ]) : array<string, array<int, string|null>>|array<int, string|null>
    
        Parameters
- $key : string|null = null
 - 
                    
The name of the headers to return or null to get them all
 
Return values
array<string, array<int, string|null>>|array<int, string|null> —contains()
Returns true if the given HTTP header contains the given value.
    public
                contains(string $key, string $value) : bool
    
        Parameters
- $key : string
 - $value : string
 
Return values
bool —count()
Returns the number of headers.
    public
                count() : int
    
    
    
        Return values
int —get()
Returns the first header by name or the default one.
    public
                get(string $key[, string|null $default = null ]) : string|null
    
        Parameters
- $key : string
 - $default : string|null = null
 
Return values
string|null —getCacheControlDirective()
Returns a Cache-Control directive value by name.
    public
                getCacheControlDirective(string $key) : bool|string|null
    
        Parameters
- $key : string
 
Return values
bool|string|null —getDate()
Returns the HTTP header value converted to a date.
    public
                getDate(string $key[, DateTime|null $default = null ]) : DateTimeInterface|null
    
        Parameters
- $key : string
 - $default : DateTime|null = null
 
Tags
Return values
DateTimeInterface|null —getIterator()
Returns an iterator for headers.
    public
                getIterator() : ArrayIterator<string, array<int, string|null>>
    
    
    
        Return values
ArrayIterator<string, array<int, string|null>> —has()
Returns true if the HTTP header is defined.
    public
                has(string $key) : bool
    
        Parameters
- $key : string
 
Return values
bool —hasCacheControlDirective()
Returns true if the Cache-Control directive is defined.
    public
                hasCacheControlDirective(string $key) : bool
    
        Parameters
- $key : string
 
Return values
bool —keys()
Returns the parameter keys.
    public
                keys() : array<string|int, string>
    
    
    
        Return values
array<string|int, string> —remove()
Removes a header.
    public
                remove(string $key) : mixed
    
        Parameters
- $key : string
 
Return values
mixed —removeCacheControlDirective()
Removes a Cache-Control directive.
    public
                removeCacheControlDirective(string $key) : mixed
    
        Parameters
- $key : string
 
Return values
mixed —replace()
Replaces the current HTTP headers by a new set.
    public
                replace([array<string|int, mixed> $headers = [] ]) : mixed
    
        Parameters
- $headers : array<string|int, mixed> = []
 
Return values
mixed —set()
Sets a header by name.
    public
                set(string $key, string|array<string|int, string>|null $values[, bool $replace = true ]) : mixed
    
        Parameters
- $key : string
 - $values : string|array<string|int, string>|null
 - 
                    
The value or an array of values
 - $replace : bool = true
 - 
                    
Whether to replace the actual value or not (true by default)
 
Return values
mixed —getCacheControlHeader()
    protected
                getCacheControlHeader() : mixed
        
    
    
        Return values
mixed —parseCacheControl()
Parses a Cache-Control HTTP header.
    protected
                parseCacheControl(string $header) : array<string|int, mixed>
    
        Parameters
- $header : string