MailMimeParser 2.4

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.
newInstanceOf()  : 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::class

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::class => ['from', 'to', 'cc', 'bcc', 'sender', 'replyto', 'resentfrom', 'resentto', 'resentcc', 'resentbcc', 'resentreplyto', 'returnpath', 'deliveredto'], \ZBateson\MailMimeParser\Header\DateHeader::class => ['date', 'resentdate', 'deliverydate', 'expires', 'expirydate', 'replyby'], \ZBateson\MailMimeParser\Header\ParameterHeader::class => ['contenttype', 'contentdisposition', 'receivedspf', 'authenticationresults', 'dkimsignature', 'autocrypt'], \ZBateson\MailMimeParser\Header\SubjectHeader::class => ['subject'], \ZBateson\MailMimeParser\Header\IdHeader::class => ['messageid', 'contentid', 'inreplyto', 'references'], \ZBateson\MailMimeParser\Header\ReceivedHeader::class => ['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.

newInstanceOf()

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

public newInstanceOf(string $name, string $value, string $iHeaderClass) : IHeader
Parameters
$name : string

The header name.

$value : string

The header value.

$iHeaderClass : string
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