Zend Framework  3.0
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Headers Class Reference

Basic mail headers collection functionality. More...

Public Member Functions

 setPluginClassLoader (PluginClassLocator $pluginClassLoader)
 Set an alternate implementation for the PluginClassLoader.
 
 getPluginClassLoader ()
 Return an instance of a PluginClassLocator, lazyload and inject map if necessary.
 
 setEncoding ($encoding)
 Set the header encoding.
 
 getEncoding ()
 Get the header encoding.
 
 addHeaders ($headers)
 Add many headers at once.
 
 addHeaderLine ($headerFieldNameOrLine, $fieldValue=null)
 Add a raw header line, either in name => value, or as a single string 'name: value'.
 
 addHeader (Header\HeaderInterface $header)
 Add a Header to this container, for raw values see addHeaderLine() and addHeaders().
 
 removeHeader ($instanceOrFieldName)
 Remove a Header from the container.
 
 clearHeaders ()
 Clear all headers.
 
 get ($name)
 Get all headers of a certain name/type.
 
 has ($name)
 Test for existence of a type of header.
 
 next ()
 Advance the pointer for this object as an iterator.
 
 key ()
 Return the current key for this object as an iterator.
 
 valid ()
 Is this iterator still valid?
 
 rewind ()
 Reset the internal pointer for this object as an iterator.
 
 current ()
 Return the current value for this iterator, lazy loading it if need be.
 
 count ()
 Return the number of headers in this contain, if all headers have not been parsed, actual count could increase if MultipleHeader objects exist in the Request/Response.
 
 toString ()
 Render all headers at once.
 
 toArray ($format=Header\HeaderInterface::FORMAT_RAW)
 Return the headers container as an array.
 
 forceLoading ()
 By calling this, it will force parsing and loading of all headers, after this count() will be accurate.
 
 loadHeader ($headerLine)
 Create Header object from header line.
 

Static Public Member Functions

static fromString ($string, $EOL=self::EOL)
 Populates headers from string representation.
 

Public Attributes

const EOL = "\r\n"
 
const FOLDING = "\r\n "
 

Protected Member Functions

 lazyLoadHeader ($index)
 
 normalizeFieldName ($fieldName)
 Normalize a field name.
 

Protected Attributes

 $pluginClassLoader = null
 
 $headersKeys = []
 
 $headers = []
 
 $encoding = 'ASCII'
 

Detailed Description

Basic mail headers collection functionality.

Handles aggregation of headers

Member Function Documentation

addHeader ( Header\HeaderInterface  $header)

Add a Header to this container, for raw values see addHeaderLine() and addHeaders().

Parameters
Header\HeaderInterface$header
Returns
Headers
addHeaderLine (   $headerFieldNameOrLine,
  $fieldValue = null 
)

Add a raw header line, either in name => value, or as a single string 'name: value'.

This method allows for lazy-loading in that the parsing and instantiation of HeaderInterface object will be delayed until they are retrieved by either get() or current()

Exceptions
Exception\InvalidArgumentException
Parameters
string$headerFieldNameOrLine
string$fieldValueoptional
Returns
Headers
addHeaders (   $headers)

Add many headers at once.

Expects an array (or Traversable object) of type/value pairs.

Parameters
array | Traversable$headers
Exceptions
Exception\InvalidArgumentException
Returns
Headers
clearHeaders ( )

Clear all headers.

Removes all headers from queue

Returns
Headers
count ( )

Return the number of headers in this contain, if all headers have not been parsed, actual count could increase if MultipleHeader objects exist in the Request/Response.

If you need an exact count, iterate

Returns
int count of currently known headers
current ( )

Return the current value for this iterator, lazy loading it if need be.

Returns
Header
forceLoading ( )

By calling this, it will force parsing and loading of all headers, after this count() will be accurate.

Returns
bool
static fromString (   $string,
  $EOL = self::EOL 
)
static

Populates headers from string representation.

Parses a string for headers, and aggregates them, in order, in the current instance, primarily as strings until they are needed (they will be lazy loaded)

Parameters
string$string
string$EOLEOL string; defaults to EOL
Exceptions
Exception\RuntimeException
Returns
Headers
get (   $name)

Get all headers of a certain name/type.

Parameters
string$name
Returns
bool|ArrayIterator|Header Returns false if there is no headers with $name in this contain, an ArrayIterator if the header is a MultipleHeadersInterface instance and finally returns HeaderInterface for the rest of cases.
getEncoding ( )

Get the header encoding.

Returns
string
getPluginClassLoader ( )

Return an instance of a PluginClassLocator, lazyload and inject map if necessary.

Returns
PluginClassLocator
has (   $name)

Test for existence of a type of header.

Parameters
string$name
Returns
bool
key ( )

Return the current key for this object as an iterator.

Returns
mixed
lazyLoadHeader (   $index)
protected
Parameters
$index
Returns
mixed
loadHeader (   $headerLine)

Create Header object from header line.

Parameters
string$headerLine
Returns
Header|Header[]
next ( )

Advance the pointer for this object as an iterator.

normalizeFieldName (   $fieldName)
protected

Normalize a field name.

Parameters
string$fieldName
Returns
string
removeHeader (   $instanceOrFieldName)

Remove a Header from the container.

Parameters
string|Header\HeaderInterfacefield name or specific header instance to remove
Returns
bool
rewind ( )

Reset the internal pointer for this object as an iterator.

setEncoding (   $encoding)

Set the header encoding.

Parameters
string$encoding
Returns
Headers
setPluginClassLoader ( PluginClassLocator  $pluginClassLoader)

Set an alternate implementation for the PluginClassLoader.

Parameters
PluginClassLocator$pluginClassLoader
Returns
Headers
toArray (   $format = Header\HeaderInterface::FORMAT_RAW)

Return the headers container as an array.

Parameters
bool$formatReturn the values in Mime::Encoded or in Raw format
Returns
array
Todo:
determine how to produce single line headers, if they are supported
toString ( )

Render all headers at once.

This method handles the normal iteration of headers; it is up to the concrete classes to prepend with the appropriate status/request line.

Returns
string
valid ( )

Is this iterator still valid?

Returns
bool

Member Data Documentation

$encoding = 'ASCII'
protected
$headers = []
protected
$headersKeys = []
protected
$pluginClassLoader = null
protected
const EOL = "\r\n"
const FOLDING = "\r\n "