Headers
in package
implements
Countable, Iterator
Basic HTTP headers collection functionality Handles aggregation of headers
Tags
Table of Contents
Interfaces
- Countable
- Iterator
Properties
- $headers : array<string|int, mixed>
- $headersKeys : array<string|int, mixed>
- $pluginClassLoader : PluginClassLocator
Methods
- addHeader() : $this
- Add a Header to this container, for raw values @see addHeaderLine() and addHeaders()
- addHeaderLine() : $this
- Add a raw header line, either in name => value, or as a single string 'name: value'
- addHeaders() : $this
- Add many headers at once
- clearHeaders() : $this
- Clear all headers
- count() : int
- 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
- current() : array<string|int, mixed>|HeaderInterface
- Return the current value for this iterator, lazy loading it if need be
- forceLoading() : bool
- By calling this, it will force parsing and loading of all headers, after this count() will be accurate
- fromString() : static
- Populates headers from string representation
- get() : bool|HeaderInterface|ArrayIterator
- Get all headers of a certain name/type
- getPluginClassLoader() : PluginClassLocator
- Return an instance of a PluginClassLocator, lazyload and inject map if necessary
- has() : bool
- Test for existence of a type of header
- key() : mixed
- Return the current key for this object as an iterator
- next() : void
- Advance the pointer for this object as an iterator
- removeHeader() : bool
- Remove a Header from the container
- rewind() : void
- Reset the internal pointer for this object as an iterator
- setPluginClassLoader() : $this
- Set an alternate implementation for the PluginClassLoader
- toArray() : array<string|int, mixed>
- Return the headers container as an array
- toString() : string
- Render all headers at once
- valid() : bool
- Is this iterator still valid?
- createKey() : string
- Create array key from header name
- lazyLoadHeader() : mixed|void
Properties
$headers
protected
array<string|int, mixed>
$headers
= []
Array of header array information or Header instances
$headersKeys
protected
array<string|int, mixed>
$headersKeys
= []
key names for $headers array
$pluginClassLoader
protected
PluginClassLocator
$pluginClassLoader
Methods
addHeader()
Add a Header to this container, for raw values @see addHeaderLine() and addHeaders()
public
addHeader(HeaderInterface $header) : $this
Parameters
- $header : HeaderInterface
Return values
$thisaddHeaderLine()
Add a raw header line, either in name => value, or as a single string 'name: value'
public
addHeaderLine(string $headerFieldNameOrLine[, string $fieldValue = null ]) : $this
This method allows for lazy-loading in that the parsing and instantiation of Header object will be delayed until they are retrieved by either get() or current()
Parameters
- $headerFieldNameOrLine : string
- $fieldValue : string = null
-
optional
Tags
Return values
$thisaddHeaders()
Add many headers at once
public
addHeaders(array<string|int, mixed>|Traversable $headers) : $this
Expects an array (or Traversable object) of type/value pairs.
Parameters
- $headers : array<string|int, mixed>|Traversable
Tags
Return values
$thisclearHeaders()
Clear all headers
public
clearHeaders() : $this
Removes all headers from queue
Return values
$thiscount()
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
public
count() : int
Attributes
Return values
int —count of currently known headers
current()
Return the current value for this iterator, lazy loading it if need be
public
current() : array<string|int, mixed>|HeaderInterface
Attributes
Return values
array<string|int, mixed>|HeaderInterfaceforceLoading()
By calling this, it will force parsing and loading of all headers, after this count() will be accurate
public
forceLoading() : bool
Return values
boolfromString()
Populates headers from string representation
public
static fromString(string $string) : static
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
Tags
Return values
staticget()
Get all headers of a certain name/type
public
get(string $name) : bool|HeaderInterface|ArrayIterator
Parameters
- $name : string
Return values
bool|HeaderInterface|ArrayIteratorgetPluginClassLoader()
Return an instance of a PluginClassLocator, lazyload and inject map if necessary
public
getPluginClassLoader() : PluginClassLocator
Return values
PluginClassLocatorhas()
Test for existence of a type of header
public
has(string $name) : bool
Parameters
- $name : string
Return values
boolkey()
Return the current key for this object as an iterator
public
key() : mixed
Attributes
next()
Advance the pointer for this object as an iterator
public
next() : void
Attributes
removeHeader()
Remove a Header from the container
public
removeHeader(HeaderInterface $header) : bool
Parameters
- $header : HeaderInterface
Return values
boolrewind()
Reset the internal pointer for this object as an iterator
public
rewind() : void
Attributes
setPluginClassLoader()
Set an alternate implementation for the PluginClassLoader
public
setPluginClassLoader(PluginClassLocator $pluginClassLoader) : $this
Parameters
- $pluginClassLoader : PluginClassLocator
Return values
$thistoArray()
Return the headers container as an array
public
toArray() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>toString()
Render all headers at once
public
toString() : string
This method handles the normal iteration of headers; it is up to the concrete classes to prepend with the appropriate status/request line.
Return values
stringvalid()
Is this iterator still valid?
public
valid() : bool
Attributes
Return values
boolcreateKey()
Create array key from header name
protected
static createKey(string $name) : string
Parameters
- $name : string
Return values
stringlazyLoadHeader()
protected
lazyLoadHeader(int|string $index[, bool $isGeneric = false ]) : mixed|void
Parameters
- $index : int|string
- $isGeneric : bool = false
-
If true, there is no need to parse $index and call the ClassLoader.