MailMimeParser 1.0

PartStreamFilterManager

Manages attached stream filters for a MessagePart's content resource handle.

The attached stream filters are: o Content-Transfer-Encoding filter to manage decoding from a supported encoding: quoted-printable, base64 and x-uuencode. o Charset conversion filter to convert to UTF-8

Tags
author

Zaahid Bateson

Table of Contents

$filteredStream  : StreamInterface
$stream  : StreamInterface
$charset  : array<string|int, mixed>
$charsetConversionFilter  : string
$encoding  : array<string|int, mixed>
$streamFactory  : StreamFactory
__construct()  : mixed
Sets up filter names used for stream_filter_append
getContentStream()  : StreamInterface
Checks what transfer-encoding decoder filters and charset conversion filters are attached on the handle, closing/reopening the handle if different, before attaching relevant filters for the passed $transferEncoding and charset arguments, and returning a StreamInterface.
reset()  : mixed
Closes the attached resource handle, resets mapped encoding and charset filters, and reopens the handle seeking back to the current position.
setStream()  : mixed
Sets the URL used to open the content resource handle.
attachCharsetFilter()  : mixed
Attaches a charset conversion filter to the attached content handle, for the passed arguments.
attachTransferEncodingFilter()  : mixed
Attaches a decoding filter to the attached content handle, for the passed $transferEncoding.
isCharsetFilterChanged()  : bool
Returns true if the attached stream filter used for charset conversion on the current handle is different from the one needed based on the passed arguments.
isTransferEncodingFilterChanged()  : bool
Returns true if the attached stream filter used for decoding the content on the current handle is different from the one passed as an argument.

Properties

$charset

private array<string|int, mixed> $charset = ['from' => null, 'to' => null, 'filter' => null]

Methods

getContentStream()

Checks what transfer-encoding decoder filters and charset conversion filters are attached on the handle, closing/reopening the handle if different, before attaching relevant filters for the passed $transferEncoding and charset arguments, and returning a StreamInterface.

public getContentStream(string $transferEncoding, string $fromCharset, string $toCharset) : StreamInterface
Parameters
$transferEncoding : string
$fromCharset : string

the character set the content is encoded in

$toCharset : string

the target encoding to return

Return values
StreamInterface

reset()

Closes the attached resource handle, resets mapped encoding and charset filters, and reopens the handle seeking back to the current position.

public reset() : mixed

Note that closing/reopening is done because of the following differences discovered between hhvm (up to 3.18 at least) and php:

o stream_filter_remove wasn't triggering php_user_filter's onClose callback o read operations performed after stream_filter_remove weren't calling filter on php_user_filter

It seems stream_filter_remove doesn't work on hhvm, or isn't implemented in the same way -- so closing and reopening seems to solve that.

Return values
mixed

setStream()

Sets the URL used to open the content resource handle.

public setStream([StreamInterface $stream = null ]) : mixed

The function also closes the currently attached handle if any.

Parameters
$stream : StreamInterface = null
Return values
mixed

attachCharsetFilter()

Attaches a charset conversion filter to the attached content handle, for the passed arguments.

protected attachCharsetFilter(string $fromCharset, string $toCharset) : mixed
Parameters
$fromCharset : string

the character set the content is encoded in

$toCharset : string

the target encoding to return

Return values
mixed

attachTransferEncodingFilter()

Attaches a decoding filter to the attached content handle, for the passed $transferEncoding.

protected attachTransferEncodingFilter(string $transferEncoding) : mixed
Parameters
$transferEncoding : string
Return values
mixed

isCharsetFilterChanged()

Returns true if the attached stream filter used for charset conversion on the current handle is different from the one needed based on the passed arguments.

private isCharsetFilterChanged(string $fromCharset, string $toCharset) : bool
Parameters
$fromCharset : string
$toCharset : string
Return values
bool

isTransferEncodingFilterChanged()

Returns true if the attached stream filter used for decoding the content on the current handle is different from the one passed as an argument.

private isTransferEncodingFilterChanged(string $transferEncoding) : bool
Parameters
$transferEncoding : string
Return values
bool

Search results