Copied!

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.

CloneableInstantiable
Methods
public __construct(Psr\Log\LoggerInterface $logger, ZBateson\MailMimeParser\Stream\StreamFactory $streamFactory, ZBateson\MbWrapper\MbWrapper $mbWrapper, bool $throwExceptionReadingPartContentFromUnsupportedCharsets, ZBateson\MailMimeParser\Parser\Proxy\ParserPartProxy $parserProxy)
public __destruct()
public ZBateson\MailMimeParser\ErrorBag::addError(string $message, string $psrLogLevel, ?Throwable $exception = NULL) : static
public ZBateson\MailMimeParser\ErrorBag::getAllErrors(bool $validate = false, string $minPsrLevel = 'error'Psr\Log\LogLevel::ERROR) : array
public getBinaryContentStream(ZBateson\MailMimeParser\Message\IMessagePart $part, ?string $transferEncoding = NULL) : ?ZBateson\MailMimeParser\Stream\MessagePartStreamDecorator
public getContentStream(ZBateson\MailMimeParser\Message\IMessagePart $part, ?string $transferEncoding, ?string $fromCharset, ?string $toCharset) : ?ZBateson\MailMimeParser\Stream\MessagePartStreamDecorator
public ZBateson\MailMimeParser\ErrorBag::getErrorLoggingContextName() : string
 

Returns the class name. Override to identify objects in logs.

public ZBateson\MailMimeParser\ErrorBag::getErrors(bool $validate = false, string $minPsrLevel = 'error'Psr\Log\LogLevel::ERROR) : array
public getStream() : ZBateson\MailMimeParser\Stream\MessagePartStreamDecorator
public ZBateson\MailMimeParser\ErrorBag::hasAnyErrors(bool $validate = false, string $minPsrLevel = 'error'Psr\Log\LogLevel::ERROR) : bool
public hasContent() : bool
public ZBateson\MailMimeParser\ErrorBag::hasErrors(bool $validate = false, string $minPsrLevel = 'error'Psr\Log\LogLevel::ERROR) : bool
public ZBateson\MailMimeParser\Message\PartStreamContainer::reset() : static
 

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

public setContentStream(?Psr\Http\Message\StreamInterface $contentStream = NULL) : static
public ZBateson\MailMimeParser\Message\PartStreamContainer::setStream(ZBateson\MailMimeParser\Stream\MessagePartStreamDecorator $stream) : static
 

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

public update(SplSubject $subject) : void
Properties
protected ?Psr\Http\Message\StreamInterface ZBateson\MailMimeParser\Message\PartStreamContainer::$charsetStream = NULL
 
  • var \StreamInterface attached charset stream to $decodedStream
protected bool $contentParseRequested = false
 
  • var bool false if the content for the part represented by this container has not yet been requested from the parser.
protected ?Psr\Http\Message\StreamInterface ZBateson\MailMimeParser\Message\PartStreamContainer::$contentStream = NULL
 
  • var \StreamInterface a stream containing this part's content
protected ?Psr\Http\Message\StreamInterface ZBateson\MailMimeParser\Message\PartStreamContainer::$decodedStream = NULL
 
  • var \StreamInterface the content stream after attaching transfer encoding streams to $contentStream.
protected bool ZBateson\MailMimeParser\Message\PartStreamContainer::$detachParsedStream = false
 
  • var bool true if the stream should be detached when this container is destroyed.
protected Psr\Log\LoggerInterface ZBateson\MailMimeParser\ErrorBag::$logger
protected ZBateson\MbWrapper\MbWrapper ZBateson\MailMimeParser\Message\PartStreamContainer::$mbWrapper
 
  • var \MbWrapper to test charsets and see if they're supported.
protected ?ZBateson\MailMimeParser\Stream\MessagePartStreamDecorator $parsedStream = NULL
 
  • var \MessagePartStreamDecorator the original stream for a parsed message, wrapped in a MessagePartStreamDecorator, and used when the message hasn't changed
protected ZBateson\MailMimeParser\Parser\Proxy\ParserPartProxy $parserProxy
 
  • var \ParserPartProxy The parser proxy to ferry requests to on-demand.
protected bool $partUpdated = false
 
  • var bool set to true if the part's been updated since it was created.
protected ZBateson\MailMimeParser\Stream\MessagePartStreamDecorator ZBateson\MailMimeParser\Message\PartStreamContainer::$stream
 
  • var \MessagePartStreamDecorator stream containing the part's headers, content and children wrapped in a MessagePartStreamDecorator
protected ZBateson\MailMimeParser\Stream\StreamFactory ZBateson\MailMimeParser\Message\PartStreamContainer::$streamFactory
 
  • var \StreamFactory used to apply psr7 stream decorators to the attached StreamInterface based on encoding.
protected bool ZBateson\MailMimeParser\Message\PartStreamContainer::$throwExceptionReadingPartContentFromUnsupportedCharsets
 
  • var bool if false, reading from a content stream with an unsupported charset will be tried with the default charset, otherwise the stream created with the unsupported charset, and an exception will be thrown when read from.
Methods
protected ZBateson\MailMimeParser\Message\PartStreamContainer::attachCharsetFilter(string $fromCharset, string $toCharset) : static
 

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 ZBateson\MailMimeParser\Message\PartStreamContainer::attachTransferEncodingFilter(?string $transferEncoding) : static
 

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

protected ZBateson\MailMimeParser\Message\PartStreamContainer::getErrorBagChildren() : array
protected requestParsedContentStream() : static
 

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

protected requestParsedStream() : static
 

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 ZBateson\MailMimeParser\ErrorBag::validate() : void
 

Perform any extra validation and call 'addError'.

getErrors and getAllErrors call validate() if their $validate parameter is true. validate() is only called once on an object with getErrors getAllErrors.

© 2025 Bruce Wells
Search Namespaces \ Classes
Configuration