MailMimeParser 2.3

ParameterHeader extends AbstractHeader
in package

Represents a header containing an optional main value part and subsequent name/value pairs.

If header doesn't contain a non-parameterized 'main' value part, 'getValue()' will return the value of the first parameter.

For example: 'Content-Type: text/html; charset=utf-8; name=test.ext'

The 'text/html' portion is considered the 'main' value, and 'charset' and 'name' are added as parameterized name/value pairs.

With the Autocrypt header, there is no main value portion, for example: 'Autocrypt: addr=zb@example.com; keydata=b64-data'

In that example, calling php $header->getValue() would return 'zb@example.com', as would calling php $header->getValueFor('addr'); .

Tags
author

Zaahid Bateson

Table of Contents

$name  : string
$parameters  : array<string|int, ParameterPart>
$parts  : array<string|int, IHeaderPart>
$rawValue  : string
__construct()  : mixed
Assigns the header's name and raw value, then calls getConsumer and setParseHeaderValue to extract a parsed value.
__toString()  : string
Returns the string representation of the header.
getName()  : string
Returns the name of the header.
getParts()  : array<string|int, IHeaderPart>
Returns an array of IHeaderPart objects the header's value has been parsed into.
getRawValue()  : string
Returns the raw value of the header.
getValue()  : string
Returns the parsed 'value' of the header.
getValueFor()  : string|null
Returns the value of the parameter with the given name, or $defaultValue if not set.
hasParameter()  : bool
Returns true if a parameter exists with the passed name.
getConsumer()  : AbstractConsumer
Returns a ParameterConsumer.
setParseHeaderValue()  : static
Overridden to assign ParameterParts to a map of lower-case parameter names to ParameterParts.

Properties

$parameters

protected array<string|int, ParameterPart> $parameters = []

key map of lower-case parameter names and associated ParameterParts.

Methods

__construct()

Assigns the header's name and raw value, then calls getConsumer and setParseHeaderValue to extract a parsed value.

public __construct(ConsumerService $consumerService, string $name, string $value) : mixed
Parameters
$consumerService : ConsumerService

For parsing the value.

$name : string

Name of the header.

$value : string

Value of the header.

Return values
mixed

__toString()

Returns the string representation of the header.

public __toString() : string

i.e.: '<HeaderName>: <RawValue>'

Return values
string

The string representation.

getName()

Returns the name of the header.

public getName() : string
Return values
string

The name.

getParts()

Returns an array of IHeaderPart objects the header's value has been parsed into.

public getParts() : array<string|int, IHeaderPart>
Return values
array<string|int, IHeaderPart>

getRawValue()

Returns the raw value of the header.

public getRawValue() : string
Return values
string

The raw value.

getValue()

Returns the parsed 'value' of the header.

public getValue() : string

For headers that contain multiple parts, like address headers (To, From) or parameter headers (Content-Type), the 'value' is the value of the first parsed part.

Return values
string

The value

getValueFor()

Returns the value of the parameter with the given name, or $defaultValue if not set.

public getValueFor(string $name[, string $defaultValue = null ]) : string|null
Parameters
$name : string

The parameter to retrieve.

$defaultValue : string = null

Optional default value (defaulting to null if not provided).

Return values
string|null

The parameter's value.

hasParameter()

Returns true if a parameter exists with the passed name.

public hasParameter(string $name) : bool
Parameters
$name : string

The parameter to look up.

Return values
bool

setParseHeaderValue()

Overridden to assign ParameterParts to a map of lower-case parameter names to ParameterParts.

protected setParseHeaderValue(AbstractConsumer $consumer) : static
Parameters
$consumer : AbstractConsumer
Return values
static

Search results