Copied!

Represents a single mime header part token, with the possibility of it being MIME-Encoded as per RFC-2047.

MimeToken automatically decodes the value if it's encoded.

CloneableInstantiable
Constants
public ZBateson\MailMimeParser\Header\Part\MimeToken::MIME_PART_PATTERN = '=\?[^?=]+\?[QBqb]\?[^\?]+\?='
 
  • var string regex pattern matching a mime-encoded part
public ZBateson\MailMimeParser\Header\Part\MimeToken::MIME_PART_PATTERN_NO_QUOTES = '=\?[^\?=]+\?[QBqb]\?[^\?"]+\?='
 
  • var string regex pattern used when parsing parameterized headers
Methods
public __construct(Psr\Log\LoggerInterface $logger, ZBateson\MbWrapper\MbWrapper $charsetConverter, string $value)
public ZBateson\MailMimeParser\Header\Part\HeaderPart::__toString() : string
 

Returns the value of the part (which is a string).

  • return string the value
public ZBateson\MailMimeParser\ErrorBag::addError(string $message, string $psrLogLevel, ?Throwable $exception = NULL) : static
public ZBateson\MailMimeParser\ErrorBag::getAllErrors(bool $validate = false, string $minPsrLevel = 'error'Psr\Log\LogLevel::ERROR) : array
public getCharset() : ?string
 

Returns the charset for the encoded part.

public ZBateson\MailMimeParser\Header\Part\HeaderPart::getComments() : array
public ZBateson\MailMimeParser\ErrorBag::getErrorLoggingContextName() : string
 

Returns the class name. Override to identify objects in logs.

public ZBateson\MailMimeParser\ErrorBag::getErrors(bool $validate = false, string $minPsrLevel = 'error'Psr\Log\LogLevel::ERROR) : array
public getLanguage() : ?string
 

Returns the language code for the mime part.

public getRawValue() : string
public ZBateson\MailMimeParser\Header\Part\Token::getValue() : string
 

Returns the part's representative value after any necessary processing has been performed. For the raw value, call getRawValue().

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
Properties
protected bool ZBateson\MailMimeParser\Header\Part\HeaderPart::$canIgnoreSpacesAfter = false
 
  • var bool set to true to ignore spaces after this part
protected bool ZBateson\MailMimeParser\Header\Part\HeaderPart::$canIgnoreSpacesBefore = false
 
  • var bool set to true to ignore spaces before this part
protected ?string $charset = NULL
 
  • var ?string the charset if any, or null otherwise
protected ZBateson\MbWrapper\MbWrapper ZBateson\MailMimeParser\Header\Part\HeaderPart::$charsetConverter
 
  • var \MbWrapper $charsetConverter the charset converter used for converting strings in HeaderPart::convertEncoding
protected bool ZBateson\MailMimeParser\Header\Part\HeaderPart::$isSpace = false
 

True if the part is a space token

protected ?string $language = NULL
 
  • var ?string the language code if any, or null otherwise
protected Psr\Log\LoggerInterface ZBateson\MailMimeParser\ErrorBag::$logger
protected string ZBateson\MailMimeParser\Header\Part\Token::$rawValue
 
  • var string the raw value of the part.
protected string ZBateson\MailMimeParser\Header\Part\HeaderPart::$value
 
  • var string the representative value of the part after any conversion or processing has been done on it (e.g. removing new lines, converting, whatever else).
Methods
protected ZBateson\MailMimeParser\Header\Part\HeaderPart::convertEncoding(string $str, string $from = 'ISO-8859-1', bool $force = false) : string
 

Ensures the encoding of the passed string is set to UTF-8.

The method does nothing if the passed $from charset is UTF-8 already, or if $force is set to false and mb_check_encoding for $str returns true for 'UTF-8'.

  • return string utf-8 string
protected decodeMime(string $value) : string
 

Finds and replaces mime parts with their values.

The method splits the token value into an array on mime-part-patterns, either replacing a mime part with its value by calling iconv_mime_decode or converts the encoding on the text part by calling convertEncoding.

protected ZBateson\MailMimeParser\Header\Part\HeaderPart::getErrorBagChildren() : array
 

Default implementation returns an empty array.

protected ZBateson\MailMimeParser\ErrorBag::validate() : void
 

Perform any extra validation and call 'addError'.

getErrors and getAllErrors call validate() if their $validate parameter is true. validate() is only called once on an object with getErrors getAllErrors.

Methods
private decodeMatchedEntity(array $matches) : string
 

Decodes a matched mime entity part into a string and returns it, after adding the string into the languages array.

  • param string[] $matches
© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration