MailMimeParser 2.3

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, Traits and Enums

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, null>
$encoding  : array<string, null>
__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|null
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()  : self
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()  : void
attachCharsetFilter()  : self
Attaches a charset conversion filter to the attached content handle, for the passed arguments.
attachTransferEncodingFilter()  : self
Attaches a decoding filter to the attached content handle, for the passed $transferEncoding.
requestParsedContentStream()  : self
Requests content from the parser if not previously requested, and calls PartStreamContainer::setContentStream().
requestParsedStream()  : self
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()  : self
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, null> $charset = ['from' => null, 'to' => null, 'filter' => null]

map of the active charset filter on the current handle.

$encoding

private array<string, null> $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([string|null $transferEncoding = null ]) : StreamInterface
Parameters
$transferEncoding : string|null = null
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(string|null $transferEncoding, string|null $fromCharset, string|null $toCharset) : StreamInterface|null
Parameters
$transferEncoding : string|null

the transfer encoding

$fromCharset : string|null

the character set the content is encoded in

$toCharset : string|null

the target encoding to return

Return values
StreamInterface|null

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|null $contentStream = null ]) : self

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 = null
Return values
self

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) : void
Parameters
$subject : SplSubject
Return values
void

attachCharsetFilter()

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

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

the character set the content is encoded in

$toCharset : string

the target encoding to return

Return values
self

attachTransferEncodingFilter()

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

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

requestParsedContentStream()

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

protected requestParsedContentStream() : self
Return values
self

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() : self
Return values
self

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() : self
Return values
self

Search results