Copied!

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

CloneableInstantiable
Methods
public __construct(string $name, string $value, ?Psr\Log\LoggerInterface $logger = NULL, ?ZBateson\MailMimeParser\Header\Consumer\ParameterConsumerService $consumerService = NULL)
public ZBateson\MailMimeParser\Header\AbstractHeader::__toString() : string
public ZBateson\MailMimeParser\ErrorBag::addError(string $message, string $psrLogLevel, ?Throwable $exception = NULL) : static
public static ZBateson\MailMimeParser\Header\AbstractHeader::from(string $nameOrLine, ?string $value = NULL) : ZBateson\MailMimeParser\Header\IHeader
 

Parses the passed parameters into an IHeader object.

The type of returned IHeader is determined by the name of the header. See {@see \HeaderFactory::newInstance} for more details.

The required $nameOrLine parameter may contain either the name of a header to parse, or a full header line, e.g. From: email@example.com. If passing a full header line, the $value parameter must be set to null (the default).

Note that more specific types can be called on directly. For instance an AddressHeader may be created by calling AddressHeader::from() which will ignore the name of the header, and always return an AddressHeader, or by calling new AddressHeader('name', 'value') directly.

  • param string $nameOrLine The header's name or full header line.
  • param string|null $value The header's value, or null if passing a full header line to parse. header line to parse.
public ZBateson\MailMimeParser\ErrorBag::getAllErrors(bool $validate = false, string $minPsrLevel = 'error'Psr\Log\LogLevel::ERROR) : array
public ZBateson\MailMimeParser\Header\AbstractHeader::getAllParts() : array
 
  • return \IHeaderPart[]
public ZBateson\MailMimeParser\Header\AbstractHeader::getComments() : array
 
  • return string[]
public ZBateson\MailMimeParser\Header\AbstractHeader::getErrorLoggingContextName() : string
public ZBateson\MailMimeParser\ErrorBag::getErrors(bool $validate = false, string $minPsrLevel = 'error'Psr\Log\LogLevel::ERROR) : array
public ZBateson\MailMimeParser\Header\AbstractHeader::getName() : string
public ZBateson\MailMimeParser\Header\AbstractHeader::getParts() : array
 
  • return \IHeaderPart[]
public ZBateson\MailMimeParser\Header\AbstractHeader::getRawValue() : string
public ZBateson\MailMimeParser\Header\AbstractHeader::getValue() : ?string
public getValueFor(string $name, ?string $defaultValue = NULL) : ?string
 

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

  • param string $name The parameter to retrieve.
  • param string $defaultValue Optional default value (defaulting to null if not provided). not provided).
  • return string|null The parameter's value.
public ZBateson\MailMimeParser\ErrorBag::hasAnyErrors(bool $validate = false, string $minPsrLevel = 'error'Psr\Log\LogLevel::ERROR) : bool
public ZBateson\MailMimeParser\ErrorBag::hasErrors(bool $validate = false, string $minPsrLevel = 'error'Psr\Log\LogLevel::ERROR) : bool
public hasParameter(string $name) : bool
 

Returns true if a parameter exists with the passed name.

  • param string $name The parameter to look up.
Properties
protected array ZBateson\MailMimeParser\Header\AbstractHeader::$allParts = []
 
  • var \IHeaderPart[] the header's parts (as returned from the consumer), including commentParts including commentParts
protected Psr\Log\LoggerInterface ZBateson\MailMimeParser\ErrorBag::$logger
protected string ZBateson\MailMimeParser\Header\AbstractHeader::$name
 
  • var string the name of the header
protected array $parameters = []
 
  • var \ParameterPart[] key map of lower-case parameter names and associated ParameterParts. ParameterParts.
protected array ZBateson\MailMimeParser\Header\AbstractHeader::$parts = []
 
  • var \IHeaderPart[] all parts not including CommentParts.
protected string ZBateson\MailMimeParser\Header\AbstractHeader::$rawValue
 
  • var string the raw value
Methods
protected ZBateson\MailMimeParser\Header\AbstractHeader::filterAndAssignToParts() : void
 

Filters $this->allParts into the parts required by $this->parts and assigns it.

The AbstractHeader::filterAndAssignToParts method filters out CommentParts.

protected ZBateson\MailMimeParser\Header\AbstractHeader::getErrorBagChildren() : array
protected static ZBateson\MailMimeParser\Header\AbstractHeader::getHeaderPartsFrom(string $nameOrLine, ?string $value = NULL) : array
 

Checks if the passed $value parameter is null, and if so tries to parse a header line from $nameOrLine splitting on first occurrence of a ':' character.

The returned array always contains two elements. The first being the name (or blank if a ':' char wasn't found and $value is null), and the second being the value.

  • return string[]
protected parseHeaderValue(ZBateson\MailMimeParser\Header\Consumer\IConsumerService $consumer, string $value) : void
 

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

protected ZBateson\MailMimeParser\Header\AbstractHeader::validate() : void
Methods
public static ZBateson\MailMimeParser\Header\AbstractHeader::from(string $nameOrLine, ?string $value = NULL) : ZBateson\MailMimeParser\Header\IHeader
 

Parses the passed parameters into an IHeader object.

The type of returned IHeader is determined by the name of the header. See {@see \HeaderFactory::newInstance} for more details.

The required $nameOrLine parameter may contain either the name of a header to parse, or a full header line, e.g. From: email@example.com. If passing a full header line, the $value parameter must be set to null (the default).

Note that more specific types can be called on directly. For instance an AddressHeader may be created by calling AddressHeader::from() which will ignore the name of the header, and always return an AddressHeader, or by calling new AddressHeader('name', 'value') directly.

  • param string $nameOrLine The header's name or full header line.
  • param string|null $value The header's value, or null if passing a full header line to parse. header line to parse.
protected static ZBateson\MailMimeParser\Header\AbstractHeader::getHeaderPartsFrom(string $nameOrLine, ?string $value = NULL) : array
 

Checks if the passed $value parameter is null, and if so tries to parse a header line from $nameOrLine splitting on first occurrence of a ':' character.

The returned array always contains two elements. The first being the name (or blank if a ':' char wasn't found and $value is null), and the second being the value.

  • return string[]
© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration