MailMimeParser 3.0

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

$consumerServices  : array<string|int, mixed>
$genericType  : string
$logger  : LoggerInterface
$mimeTokenPartFactory  : MimeTokenPartFactory
$types  : array<string|int, array<string|int, string>>
__construct()  : mixed
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 using the passed IHeader class, and returns it.
getClassFor()  : string
Returns the name of an IHeader class for the passed header name.

Properties

$consumerServices

protected array<string|int, mixed> $consumerServices

array of available consumer service classes

$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

__construct()

public __construct(LoggerInterface $logger, MimeTokenPartFactory $mimeTokenPartFactory, AddressBaseConsumerService $addressBaseConsumerService, DateConsumerService $dateConsumerService, GenericConsumerMimeLiteralPartService $genericConsumerMimeLiteralPartService, IdBaseConsumerService $idBaseConsumerService, ParameterConsumerService $parameterConsumerService, ReceivedConsumerService $receivedConsumerService, SubjectConsumerService $subjectConsumerService) : mixed
Parameters
$logger : LoggerInterface
$mimeTokenPartFactory : MimeTokenPartFactory
$addressBaseConsumerService : AddressBaseConsumerService
$dateConsumerService : DateConsumerService
$genericConsumerMimeLiteralPartService : GenericConsumerMimeLiteralPartService
$idBaseConsumerService : IdBaseConsumerService
$parameterConsumerService : ParameterConsumerService
$receivedConsumerService : ReceivedConsumerService
$subjectConsumerService : SubjectConsumerService
Return values
mixed

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 using the passed IHeader class, 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

The class to use for header creation

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