Copied!

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.

CloneableInstantiable
Methods
public __construct(ZBateson\MailMimeParser\Stream\StreamFactory $streamFactory)
public getBinaryContentStream(?string $transferEncoding = NULL) : ?Psr\Http\Message\StreamInterface
 

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

  • param string $transferEncoding
  • return \StreamInterface
public getContentStream(?string $transferEncoding, ?string $fromCharset, ?string $toCharset)
 

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.

  • param string $transferEncoding the transfer encoding
  • param string $fromCharset the character set the content is encoded in
  • param string $toCharset the target encoding to return
  • return ?\StreamInterface
public getStream()
 

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

  • return \StreamInterface
public hasContent() : bool
 

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

public reset()
 

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

public setContentStream(?Psr\Http\Message\StreamInterface $contentStream = NULL)
 

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

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

If the content is overridden, $this->stream should point to a dynamic
{@see \ZBateson\Stream\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.

  • param \StreamInterface $contentStream
public setStream(Psr\Http\Message\StreamInterface $stream)
 

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

Properties
protected $charsetStream = NULL
 
  • var \StreamInterface attached charset stream to $decodedStream
protected $contentStream = NULL
 
  • var \StreamInterface a stream containing this part's content
protected $decodedStream = NULL
 
  • var \StreamInterface the content stream after attaching transfer encoding
    streams to $contentStream.
protected $detachParsedStream = NULL
 
  • var bool true if the stream should be detached when this container is
    destroyed.
protected $stream = NULL
 
  • var \StreamInterface stream containing the part's headers, content and
    children
protected $streamFactory = NULL
 
  • var \StreamFactory used to apply psr7 stream decorators to the
    attached StreamInterface based on encoding.
Methods
protected attachCharsetFilter(string $fromCharset, string $toCharset) : self
 

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

  • param string $fromCharset the character set the content is encoded in
  • param string $toCharset the target encoding to return
protected attachTransferEncodingFilter(?string $transferEncoding) : self
 

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

  • param string $transferEncoding
Properties
private $charset = ['from' => NULL, 'to' => NULL, 'filter' => NULL]
 
  • var array<string,null> map of the active charset filter on the current handle.
private $encoding = ['type' => NULL, 'filter' => NULL]
 
  • var array<string,null> map of the active encoding filter on the current handle.
Methods
private isCharsetFilterChanged(string $fromCharset, string $toCharset) : 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.

private isTransferEncodingFilterChanged(?string $transferEncoding) : 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.

  • param string $transferEncoding
private resetCharsetStream() : self
 

Resets just the charset stream, and rewinds the decodedStream.

© 2023 Bruce Wells
Search Namespaces \ Classes
Configuration