Copied!

Maintains a collection of headers for a part.

CloneableInstantiableIterable
Methods
public __construct(ZBateson\MailMimeParser\Header\HeaderFactory $headerFactory, ?ZBateson\MailMimeParser\Message\PartHeaderContainer $cloneSource = NULL)
 

Pass a PartHeaderContainer as the second parameter. This is useful when creating a new MimePart with this PartHeaderContainer and the original container is needed for parsing and changes to the header in the part should not affect parsing.

  • param \PartHeaderContainer $cloneSource the original container to clone from
public add( $name, $value)
 

Adds the header to the collection.

  • param string $name
  • param string $value
public exists( $name, $offset = 0)
 

Returns true if the passed header exists in this collection.

  • param string $name
  • param int $offset
  • return bool
public get(string $name, int $offset = 0)
 

Returns the IHeader object for the header with the given $name, or null if none exist.

An optional offset can be provided, which defaults to the first header in the collection when more than one header with the same name exists.

Note that mime headers aren't case sensitive.

  • param string $name
  • param int $offset
  • return \ZBateson\MailMimeParser\Header\IHeader|null
public getAll( $name)
 

Returns all headers with the passed name.

  • param string $name
  • return \ZBateson\MailMimeParser\Header\IHeader[]
public getAs(string $name, string $iHeaderClass, int $offset = 0) : ?ZBateson\MailMimeParser\Header\IHeader
 

Returns the IHeader object for the header with the given $name, or null if none exist, using the passed $iHeaderClass to construct it.

An optional offset can be provided, which defaults to the first header in the collection when more than one header with the same name exists.

Note that mime headers aren't case sensitive.

  • param string $name
  • param string $iHeaderClass
  • param int $offset
  • return ?\IHeader
public getHeaderObjects()
 

Returns an array of IHeader objects representing all headers in this collection.

  • return \ZBateson\MailMimeParser\Header\IHeader[]
public 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:

[ [ 'Header-Name', 'Header Value' ], [ 'Second-Header-Name', 'Second-Header-Value' ], // etc... ]

  • return string[][]
public 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:

[ 'Header-Name', 'Header Value' ]

  • return \ArrayIterator
  • attribute ReturnTypeWillChange
public remove( $name, $offset = 0)
 

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.

  • param string $name
  • param int $offset
  • return bool if a header was removed.
public removeAll( $name)
 

Removes all headers that match the passed name.

  • param string $name
  • return bool true if one or more headers were removed.
public set( $name, $value, $offset = 0) : self
 

If a header exists with the passed name, and at the passed offset if more than one exists, its value is updated.

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).

  • param string $name
  • param string $value
  • param int $offset
Properties
protected $headerFactory = NULL
 
  • var \HeaderFactory the HeaderFactory object used for created headers
Properties
private $headerMap = []
 
  • var array Maps header names by their "normalized" (lower-cased, non-alphanumeric characters stripped) name to an array of indexes in the $headers array. For example: $headerMap['contenttype'] = [ 1, 4 ] would indicate that the headers in $headers[1] and $headers[4] are both headers with the name 'Content-Type' or 'contENTtype'.
private $headerObjects = []
 
  • var \ZBateson\MailMimeParser\Header\IHeader[] Each element is an IHeader representing the header at the same index in the $headers array. If an IHeader has not been constructed for the header at that index, the element would be set to null.
private $headers = []
 
  • var string[][] Each element in the array is an array with its first element set to the header's name, and the second its value.
private $nextIndex = 0
 
  • var int the next index to use for $headers and $headerObjects.
Methods
private getAllWithOriginalHeaderNameIfSet(string $name) : ?array
 

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.

  • return int[]|null
private getByIndex(int $index)
 

Returns the header in the headers array at the passed 0-based integer index or null if one doesn't exist.

  • return \ZBateson\MailMimeParser\Header\IHeader|null
private getByIndexAs(int $index, string $iHeaderClass) : ?ZBateson\MailMimeParser\Header\IHeader
 

Returns the header in the headers array at the passed 0-based integer index or null if one doesn't exist, using the passed $iHeaderClass to construct it.

  • return \ZBateson\MailMimeParser\Header\IHeader|null
© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration