MailMimeParser 2.1

HeaderFactory
in package

Constructs various IHeader types depending on the type of header passed.

If the passed header resolves to a specific defined header type, it is parsed as such. Otherwise, a GenericHeader is instantiated and returned. Headers are mapped as follows:

  • AddressHeader: From, To, Cc, Bcc, Sender, Reply-To, Resent-From, Resent-To, Resent-Cc, Resent-Bcc, Resent-Reply-To, Return-Path, Delivered-To
  • DateHeader: Date, Resent-Date, Delivery-Date, Expires, Expiry-Date, Reply-By
  • ParameterHeader: Content-Type, Content-Disposition, Received-SPF, Authentication-Results, DKIM-Signature, Autocrypt
  • SubjectHeader: Subject
  • IdHeader: Message-ID, Content-ID, In-Reply-To, References
  • ReceivedHeader: Received
Tags
author

Zaahid Bateson

Table of Contents

$consumerService  : ConsumerService
$genericType  : string
$mimeLiteralPartFactory  : MimeLiteralPartFactory
$types  : array<string|int, array<string|int, string>>
__construct()  : mixed
Instantiates member variables with the passed objects.
getNormalizedHeaderName()  : string
Returns the string in lower-case, and with non-alphanumeric characters stripped out.
newInstance()  : IHeader
Creates an IHeader instance for the passed header name and value, and returns it.
getClassFor()  : string
Returns the name of an IHeader class for the passed header name.

Properties

$genericType

protected string $genericType = 'ZBateson\MailMimeParser\Header\GenericHeader'

Defines the generic IHeader type to use for headers that aren't mapped in $types

$types

protected array<string|int, array<string|int, string>> $types = ['ZBateson\MailMimeParser\Header\AddressHeader' => ['from', 'to', 'cc', 'bcc', 'sender', 'replyto', 'resentfrom', 'resentto', 'resentcc', 'resentbcc', 'resentreplyto', 'returnpath', 'deliveredto'], 'ZBateson\MailMimeParser\Header\DateHeader' => ['date', 'resentdate', 'deliverydate', 'expires', 'expirydate', 'replyby'], 'ZBateson\MailMimeParser\Header\ParameterHeader' => ['contenttype', 'contentdisposition', 'receivedspf', 'authenticationresults', 'dkimsignature', 'autocrypt'], 'ZBateson\MailMimeParser\Header\SubjectHeader' => ['subject'], 'ZBateson\MailMimeParser\Header\IdHeader' => ['messageid', 'contentid', 'inreplyto', 'references'], 'ZBateson\MailMimeParser\Header\ReceivedHeader' => ['received']]

maps IHeader types to headers.

Methods

getNormalizedHeaderName()

Returns the string in lower-case, and with non-alphanumeric characters stripped out.

public getNormalizedHeaderName(string $header) : string
Parameters
$header : string

The header name

Return values
string

The normalized header name

newInstance()

Creates an IHeader instance for the passed header name and value, and returns it.

public newInstance(string $name, string $value) : IHeader
Parameters
$name : string

The header name.

$value : string

The header value.

Return values
IHeader

The created header object.

getClassFor()

Returns the name of an IHeader class for the passed header name.

private getClassFor(string $name) : string
Parameters
$name : string

The header name.

Return values
string

The Fully Qualified class name.

Search results