Copied!

Parses content and children of MIME parts.

CloneableInstantiable
Methods
public __construct(ZBateson\MailMimeParser\Parser\Proxy\ParserMessageProxyFactory $parserMessageProxyFactory, ZBateson\MailMimeParser\Parser\Proxy\ParserMimePartProxyFactory $parserMimePartProxyFactory, ZBateson\MailMimeParser\Parser\PartBuilderFactory $partBuilderFactory, ZBateson\MailMimeParser\Message\Factory\PartHeaderContainerFactory $partHeaderContainerFactory, ZBateson\MailMimeParser\Parser\HeaderParserService $headerParser)
public canParse(ZBateson\MailMimeParser\Parser\PartBuilder $part) : bool
 

Returns true if the passed PartBuilder::isMime() method returns true.

public ZBateson\MailMimeParser\Parser\AbstractParserService::getParserMessageProxyFactory() : ZBateson\MailMimeParser\Parser\Proxy\ParserPartProxyFactory
public ZBateson\MailMimeParser\Parser\AbstractParserService::getParserPartProxyFactory() : ZBateson\MailMimeParser\Parser\Proxy\ParserPartProxyFactory
public parseContent(ZBateson\MailMimeParser\Parser\Proxy\ParserPartProxy $proxy) : static
public parseNextChild(ZBateson\MailMimeParser\Parser\Proxy\ParserMimePartProxy $proxy) : ?ZBateson\MailMimeParser\Parser\Proxy\ParserPartProxy
public ZBateson\MailMimeParser\Parser\AbstractParserService::setParserManager(ZBateson\MailMimeParser\Parser\ParserManagerService $pm) : static
Properties
protected ZBateson\MailMimeParser\Parser\HeaderParserService $headerParser
 
  • var \HeaderParserService The HeaderParser service.
protected ZBateson\MailMimeParser\Parser\ParserManagerService ZBateson\MailMimeParser\Parser\AbstractParserService::$parserManager
 
  • var \ParserManagerService the ParserManager, which should call setParserManager when the parser is added.
protected ZBateson\MailMimeParser\Parser\Proxy\ParserPartProxyFactory ZBateson\MailMimeParser\Parser\AbstractParserService::$parserMessageProxyFactory
 
  • var \ParserPartProxyFactory the parser's message proxy factory service responsible for creating an IMessage part wrapped in a ParserPartProxy.
protected ZBateson\MailMimeParser\Parser\Proxy\ParserPartProxyFactory ZBateson\MailMimeParser\Parser\AbstractParserService::$parserPartProxyFactory
 
  • var \ParserPartProxyFactory the parser's part proxy factory service responsible for creating IMessagePart parts wrapped in a ParserPartProxy.
protected ZBateson\MailMimeParser\Parser\PartBuilderFactory ZBateson\MailMimeParser\Parser\AbstractParserService::$partBuilderFactory
 
  • var \PartBuilderFactory Service for creating PartBuilder objects for new children.
protected ZBateson\MailMimeParser\Message\Factory\PartHeaderContainerFactory $partHeaderContainerFactory
 
  • var \PartHeaderContainerFactory Factory service for creating PartHeaderContainers for headers.
Methods
private createPart(ZBateson\MailMimeParser\Parser\Proxy\ParserMimePartProxy $parent, ZBateson\MailMimeParser\Message\PartHeaderContainer $headerContainer, ZBateson\MailMimeParser\Parser\PartBuilder $child) : ?ZBateson\MailMimeParser\Parser\Proxy\ParserPartProxy
 

Calls the header parser to fill the passed $headerContainer, then calls $this->parserManager->createParserProxyFor($child);

The method first checks though if the 'part' represents hidden content past a MIME end boundary, which some messages like to include, for instance:

--outer-boundary--
--boundary
content
--boundary--
some hidden information
--outer-boundary--

In this case, $this->parserPartProxyFactory is called directly to create a part, $this->parseContent is called immediately to parse it and discard it, and null is returned.

private findContentBoundary(ZBateson\MailMimeParser\Parser\Proxy\ParserMimePartProxy $proxy) : static
 

Reads 2048-byte lines from the passed $handle, calling $partBuilder->setEndBoundaryFound with the passed line until it returns true or the stream is at EOF.

setEndBoundaryFound returns true if the passed line matches a boundary for the $partBuilder itself or any of its parents.

Lines longer than 2048 bytes are returned as single lines of 2048 bytes, the longer line is not returned separately but is simply discarded.

Once a boundary is found, setStreamPartAndContentEndPos is called with the passed $handle's read pos before the boundary and its line separator were read.

private readBoundaryLine( $handle, ZBateson\MailMimeParser\Parser\Proxy\ParserMimePartProxy $proxy) : string
 

Reads up to 2048 bytes of input from the passed resource handle, discarding portions of a line that are longer than that, and returning the read portions of the line.

The method also calls $proxy->setLastLineEndingLength which is used in findContentBoundary() to set the exact end byte of a part.

  • param resource $handle
© 2025 Bruce Wells
Search Namespaces \ Classes
Configuration