MailMimeParser 2.1

ParserPartStreamContainer extends PartStreamContainer
in package
implements SplObserver

A part stream container that proxies requests for content streams to a parser to read the content.

Keeps reference to the original stream a part was parsed from, using that stream as the part's stream instead of the PartStreamContainer's MessagePartStream (which dynamically creates a stream from an IMessagePart) unless the part changed.

The ParserPartStreamContainer must also be attached to its underlying part with SplSubject::attach() so the ParserPartStreamContainer gets notified of any changes.

Tags
author

Zaahid Bateson

Interfaces, Classes and Traits

SplObserver

Table of Contents

$charsetStream  : StreamInterface
$contentParseRequested  : bool
$contentStream  : StreamInterface
$decodedStream  : StreamInterface
$detachParsedStream  : bool
$parsedStream  : StreamInterface
$parserProxy  : ParserPartProxy
$partUpdated  : bool
$stream  : StreamInterface
$streamFactory  : StreamFactory
$charset  : array<string|int, mixed>
$encoding  : array<string|int, mixed>
__construct()  : mixed
__destruct()  : mixed
getBinaryContentStream()  : StreamInterface
Checks what transfer-encoding decoder stream is attached on the underlying stream, and resets it if the requested arguments differ.
getContentStream()  : StreamInterface
Checks what transfer-encoding decoder stream and charset conversion stream are currently attached on the underlying contentStream, and resets them if the requested arguments differ from the currently assigned ones.
getStream()  : StreamInterface
Returns the part's stream containing the part's headers, content, and children.
hasContent()  : bool
Returns true if there's a content stream associated with the part.
reset()  : mixed
Resets cached encoding and charset streams, and rewinds the stream.
setContentStream()  : mixed
Attaches the passed stream as the content portion of this StreamContainer.
setStream()  : mixed
Sets the part's stream containing the part's headers, content, and children.
update()  : mixed
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.
requestParsedContentStream()  : mixed
Requests content from the parser if not previously requested, and calls PartStreamContainer::setContentStream().
requestParsedStream()  : mixed
Ensures the parser has parsed the entire part, and sets $this->parsedStream to the original parsed stream (or a limited part of it corresponding to the current part this stream container belongs to).
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.
resetCharsetStream()  : mixed
Resets just the charset stream, and rewinds the decodedStream.

Properties

$charsetStream

protected StreamInterface $charsetStream

attached charset stream to $decodedStream

$contentParseRequested

protected bool $contentParseRequested = false

false if the content for the part represented by this container has not yet been requested from the parser.

$contentStream

protected StreamInterface $contentStream

a stream containing this part's content

$decodedStream

protected StreamInterface $decodedStream

the content stream after attaching transfer encoding streams to $contentStream.

$detachParsedStream

protected bool $detachParsedStream = false

true if the stream should be detached when this container is destroyed (thereby not closing the stream).

$parsedStream

protected StreamInterface $parsedStream

the original stream for a parsed message, used when the message hasn't changed

$partUpdated

protected bool $partUpdated = false

set to true if the part's been updated since it was created.

$stream

protected StreamInterface $stream

stream containing the part's headers, content and children

$charset

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

map of the active charset filter on the current handle.

$encoding

private array<string|int, mixed> $encoding = ['type' => null, 'filter' => null]

map of the active encoding filter on the current handle.

Methods

getBinaryContentStream()

Checks what transfer-encoding decoder stream is attached on the underlying stream, and resets it if the requested arguments differ.

public getBinaryContentStream(mixed $transferEncoding) : StreamInterface
Parameters
$transferEncoding : mixed
Return values
StreamInterface

getContentStream()

Checks what transfer-encoding decoder stream and charset conversion stream are currently attached on the underlying contentStream, and resets them if the requested arguments differ from the currently assigned ones.

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

the transfer encoding

$fromCharset : mixed

the character set the content is encoded in

$toCharset : mixed

the target encoding to return

Return values
StreamInterface

getStream()

Returns the part's stream containing the part's headers, content, and children.

public getStream() : StreamInterface
Return values
StreamInterface

hasContent()

Returns true if there's a content stream associated with the part.

public hasContent() : bool
Return values
bool

reset()

Resets cached encoding and charset streams, and rewinds the stream.

public reset() : mixed
Return values
mixed

setContentStream()

Attaches the passed stream as the content portion of this StreamContainer.

public setContentStream([StreamInterface $contentStream = null ]) : mixed

The content stream would represent the content portion of $this->stream.

If the content is overridden, $this->stream should point to a dynamic MessagePartStream that dynamically creates the RFC822 formatted message based on the IMessagePart this PartStreamContainer belongs to.

setContentStream can be called with 'null' to indicate the IMessagePart does not contain any content.

Parameters
$contentStream : StreamInterface = null
Return values
mixed

setStream()

Sets the part's stream containing the part's headers, content, and children.

public setStream(StreamInterface $stream) : mixed
Parameters
$stream : StreamInterface
Return values
mixed

update()

public update(SplSubject $subject) : mixed
Parameters
$subject : SplSubject
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

requestParsedContentStream()

Requests content from the parser if not previously requested, and calls PartStreamContainer::setContentStream().

protected requestParsedContentStream() : mixed
Return values
mixed

requestParsedStream()

Ensures the parser has parsed the entire part, and sets $this->parsedStream to the original parsed stream (or a limited part of it corresponding to the current part this stream container belongs to).

protected requestParsedStream() : mixed
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

resetCharsetStream()

Resets just the charset stream, and rewinds the decodedStream.

private resetCharsetStream() : mixed
Return values
mixed

Search results