MailMimeParser 3.0

IHeader extends IErrorBag

A mime email header line consisting of a name and value.

The header object provides methods to access the header's name, raw value, and also its parsed value. The parsed value will depend on the type of header and in some cases may be broken up into other parts (for example email addresses in an address header, or parameters in a parameter header).

Tags
author

Zaahid Bateson

Table of Contents

__toString()  : string
Returns the string representation of the header.
addError()  : static
Creates and adds an Error object to this ErrorBag.
getAllErrors()  : array<string|int, Error>
Returns any errors on this object, and all IErrorBag children of this object at or above the passed PSR log level from Psr\Log\LogLevel (defaulting to LogLevel::ERROR).
getAllParts()  : array<string|int, IHeaderPart>
Returns an array of all IHeaderPart objects the header's value has been parsed into, including any CommentParts.
getComments()  : array<string|int, string>
Returns an array of comments parsed from the header. If there are no comments in the header, an empty array is returned.
getErrorLoggingContextName()  : string
Returns a context name for the current object to help identify it in logs.
getErrors()  : array<string|int, Error>
Returns any local errors this object has at or above the passed PSR log level in Psr\Log\LogLevel (defaulting to LogLevel::ERROR).
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, excluding any {@see \ZBateson\MailMimeParser\Header\Part\CommentPart}s.
getRawValue()  : string
Returns the raw value of the header.
getValue()  : string
Returns the parsed 'value' of the header.
hasAnyErrors()  : bool
Returns true if there are errors on this object, or any IErrorBag child of this object at or above the passed PSR log level in Psr\Log\LogLevel (defaulting to LogLevel::ERROR). Note that this will stop after finding the first error and return, so may be slightly more performant if an error actually exists over calling getAllErrors if only interested in whether an error exists.
hasErrors()  : bool
Returns true if this object has an error in its error bag at or above the passed $minPsrLevel (defaults to ERROR). If $validate is true, additional validation may be performed.

Methods

__toString()

Returns the string representation of the header.

public __toString() : string

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

Return values
string

The string representation.

addError()

Creates and adds an Error object to this ErrorBag.

public addError(string $message, string $psrLogLevel[, Throwable|null $exception = null ]) : static
Parameters
$message : string
$psrLogLevel : string
$exception : Throwable|null = null
Return values
static

getAllErrors()

Returns any errors on this object, and all IErrorBag children of this object at or above the passed PSR log level from Psr\Log\LogLevel (defaulting to LogLevel::ERROR).

public getAllErrors([bool $validate = false ][, string $minPsrLevel = LogLevel::ERROR ]) : array<string|int, Error>

Care should be taken using this if the intention is to only 'preview' a message without parsing it entirely, since this will cause the whole message to be parsed as it traverses children, and could be slow on messages with large attachments, etc...

If $validate is true, additional validation may be performed on children to check for errors.

Parameters
$validate : bool = false
$minPsrLevel : string = LogLevel::ERROR
Return values
array<string|int, Error>

getAllParts()

Returns an array of all IHeaderPart objects the header's value has been parsed into, including any CommentParts.

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

The array of parts.

getComments()

Returns an array of comments parsed from the header. If there are no comments in the header, an empty array is returned.

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

getErrorLoggingContextName()

Returns a context name for the current object to help identify it in logs.

public getErrorLoggingContextName() : string
Return values
string

getErrors()

Returns any local errors this object has at or above the passed PSR log level in Psr\Log\LogLevel (defaulting to LogLevel::ERROR).

public getErrors([bool $validate = false ][, string $minPsrLevel = LogLevel::ERROR ]) : array<string|int, Error>

If $validate is true, additional validation may be performed on the object to check for errors.

Parameters
$validate : bool = false
$minPsrLevel : string = LogLevel::ERROR
Return values
array<string|int, Error>

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, excluding any {@see \ZBateson\MailMimeParser\Header\Part\CommentPart}s.

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

To retrieve all parts /including/ CommentParts, getAllParts().

Return values
array<string|int, IHeaderPart>

The array of parts.

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 that isn't a comment.

Return values
string

The value

hasAnyErrors()

Returns true if there are errors on this object, or any IErrorBag child of this object at or above the passed PSR log level in Psr\Log\LogLevel (defaulting to LogLevel::ERROR). Note that this will stop after finding the first error and return, so may be slightly more performant if an error actually exists over calling getAllErrors if only interested in whether an error exists.

public hasAnyErrors([bool $validate = false ][, string $minPsrLevel = LogLevel::ERROR ]) : bool

Care should be taken using this if the intention is to only 'preview' a message without parsing it entirely, since this will cause the whole message to be parsed as it traverses children, and could be slow on messages with large attachments, etc...

If $validate is true, additional validation may be performed to check for errors.

Parameters
$validate : bool = false
$minPsrLevel : string = LogLevel::ERROR
Return values
bool

hasErrors()

Returns true if this object has an error in its error bag at or above the passed $minPsrLevel (defaults to ERROR). If $validate is true, additional validation may be performed.

public hasErrors([bool $validate = false ][, string $minPsrLevel = LogLevel::ERROR ]) : bool

The PSR levels are defined in Psr\Log\LogLevel.

Parameters
$validate : bool = false
$minPsrLevel : string = LogLevel::ERROR
Return values
bool

Search results