HeaderContainer implements IteratorAggregate
Maintains a collection of headers for a part.
Tags
Interfaces, Classes and Traits
- IteratorAggregate
 
Table of Contents
- $headerFactory : HeaderFactory
 - $headerMap : array<string|int, mixed>
 - $headerObjects : array<string|int, AbstractHeader>
 - $headers : array<string|int, array<string|int, string>>
 - $nextIndex : int
 - __construct() : mixed
 - Constructor
 - add() : mixed
 - Adds the header to the collection.
 - exists() : bool
 - Returns true if the passed header exists in this collection.
 - get() : AbstractHeader
 - Returns the AbstractHeader object for the header with the given $name and at the optional offset (defaulting to the first header in the collection where more than one header with the same name exists).
 - getAll() : array<string|int, AbstractHeader>
 - Returns all headers with the passed name.
 - getHeaderObjects() : AbstractHeader
 - Returns an array of AbstractHeader objects representing all headers in this collection.
 - getHeaders() : array<string|int, array<string|int, string>>
 - Returns an array of headers in this collection. Each returned element in the array is an array with the first element set to the name, and the second its value:
 - getIterator() : ArrayIterator
 - Returns an iterator to the headers in this collection. Each returned element is an array with its first element set to the header's name, and the second to its value:
 - remove() : bool
 - Removes the header from the collection with the passed name. Defaults to removing the first instance of the header for a collection that contains more than one with the same passed name.
 - removeAll() : bool
 - Removes all headers that match the passed name.
 - set() : mixed
 - If a header exists with the passed name, and at the passed offset if more than one exists, its value is updated.
 - getAllWithOriginalHeaderNameIfSet() : array<string|int, int>
 - Returns an array of header indexes with names that more closely match the passed $name if available: for instance if there are two headers in an email, "Content-Type" and "ContentType", and the query is for a header with the name "Content-Type", only headers that match exactly "Content-Type" would be returned.
 - getByIndex() : AbstractHeader
 - Returns the header in the headers array at the passed 0-based integer index.
 
Properties
$headerFactory
    protected
        HeaderFactory
    $headerFactory
    
        
    
$headerMap
    private
        array<string|int, mixed>
    $headerMap
     = []
        
    
$headerObjects
    private
        array<string|int, AbstractHeader>
    $headerObjects
     = []
        
    
$headers
    private
        array<string|int, array<string|int, string>>
    $headers
     = []
        
    
$nextIndex
    private
        int
    $nextIndex
     = 0
        
    
Methods
__construct()
Constructor
    public
                __construct(HeaderFactory $headerFactory) : mixed
        
        Parameters
- $headerFactory : HeaderFactory
 
Return values
mixed —add()
Adds the header to the collection.
    public
                add(string $name, string $value) : mixed
        
        Parameters
- $name : string
 - $value : string
 
Return values
mixed —exists()
Returns true if the passed header exists in this collection.
    public
                exists(string $name, int $offset) : bool
        
        Parameters
- $name : string
 - $offset : int
 
Return values
bool —get()
Returns the AbstractHeader object for the header with the given $name and at the optional offset (defaulting to the first header in the collection where more than one header with the same name exists).
    public
                get(string $name, int $offset) : AbstractHeader
        Note that mime headers aren't case sensitive.
Parameters
- $name : string
 - $offset : int
 
Return values
AbstractHeader —getAll()
Returns all headers with the passed name.
    public
                getAll(string $name) : array<string|int, AbstractHeader>
        
        Parameters
- $name : string
 
Return values
array<string|int, AbstractHeader> —getHeaderObjects()
Returns an array of AbstractHeader objects representing all headers in this collection.
    public
                getHeaderObjects() : AbstractHeader
        
    
    
        Return values
AbstractHeader —getHeaders()
Returns an array of headers in this collection. Each returned element in the array is an array with the first element set to the name, and the second its value:
    public
                getHeaders() : array<string|int, array<string|int, string>>
        [ [ 'Header-Name', 'Header Value' ], [ 'Second-Header-Name', 'Second-Header-Value' ], // etc... ]
Return values
array<string|int, array<string|int, string>> —getIterator()
Returns an iterator to the headers in this collection. Each returned element is an array with its first element set to the header's name, and the second to its value:
    public
                getIterator() : ArrayIterator
        [ 'Header-Name', 'Header Value' ]
Return values
ArrayIterator —remove()
Removes the header from the collection with the passed name. Defaults to removing the first instance of the header for a collection that contains more than one with the same passed name.
    public
                remove(string $name, int $offset) : bool
        
        Parameters
- $name : string
 - $offset : int
 
Return values
bool —removeAll()
Removes all headers that match the passed name.
    public
                removeAll(string $name) : bool
        
        Parameters
- $name : string
 
Return values
bool —set()
If a header exists with the passed name, and at the passed offset if more than one exists, its value is updated.
    public
                set(string $name, string $value, int $offset) : mixed
        If a header with the passed name doesn't exist at the passed offset, it is created at the next available offset (offset is ignored when adding).
Parameters
- $name : string
 - $value : string
 - $offset : int
 
Return values
mixed —getAllWithOriginalHeaderNameIfSet()
Returns an array of header indexes with names that more closely match the passed $name if available: for instance if there are two headers in an email, "Content-Type" and "ContentType", and the query is for a header with the name "Content-Type", only headers that match exactly "Content-Type" would be returned.
    private
                getAllWithOriginalHeaderNameIfSet(string $name) : array<string|int, int>
        
        Parameters
- $name : string
 
Return values
array<string|int, int> —getByIndex()
Returns the header in the headers array at the passed 0-based integer index.
    private
                getByIndex(int $index) : AbstractHeader
        
        Parameters
- $index : int