MailMimeParser 2.4

PartStreamContainer
in package

Holds the stream and content stream objects for a part.

Note that streams are not explicitly closed or detached on destruction of the PartSreamContainer by design: the passed StreamInterfaces will be closed on their destruction when no references to them remain, which is useful when the streams are passed around.

In addition, all the streams passed to PartStreamContainer should be wrapping a ZBateson\StreamDecorators\NonClosingStream unless attached to a part by a user, this is because MMP uses a single seekable stream for content and wraps it in ZBateson\StreamDecorators\SeekingLimitStream objects for each part.

Tags
author

Zaahid Bateson

Table of Contents

$charsetStream  : StreamInterface
$contentStream  : StreamInterface
$decodedStream  : StreamInterface
$detachParsedStream  : bool
$stream  : StreamInterface
$streamFactory  : StreamFactory
$charset  : array<string, null>
$encoding  : array<string, null>
__construct()  : 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()  : 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.
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.
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

$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

true if the stream should be detached when this container is destroyed.

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

the transfer encoding

$fromCharset : string

the character set the content is encoded in

$toCharset : string

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 $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

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

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