MailMimeParser 3.0

MimeParserService extends AbstractParserService
in package

Parses content and children of MIME parts.

Tags
author

Zaahid Bateson

Table of Contents

$headerParser  : HeaderParserService
$parserManager  : ParserManagerService
$parserMessageProxyFactory  : ParserPartProxyFactory
$parserPartProxyFactory  : ParserPartProxyFactory
$partBuilderFactory  : PartBuilderFactory
$partHeaderContainerFactory  : PartHeaderContainerFactory
__construct()  : mixed
canParse()  : bool
Returns true if the passed PartBuilder::isMime() method returns true.
getParserMessageProxyFactory()  : ParserPartProxyFactory
Returns the ParserPartProxyFactory responsible for creating IMessage parts for this parser.
getParserPartProxyFactory()  : ParserPartProxyFactory
Returns the ParserPartProxyFactory responsible for creating IMessagePart parts for this parser.
parseContent()  : static
parseNextChild()  : ParserPartProxy|null
setParserManager()  : static
Sets up the passed ParserManager as the ParserManager for this part, which should be used when a new part is created (after its headers are read and a PartBuilder is created from it.)
createPart()  : ParserPartProxy|null
Calls the header parser to fill the passed $headerContainer, then calls $this->parserManager->createParserProxyFor($child);
findContentBoundary()  : 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.
readBoundaryLine()  : 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.

Properties

Methods

__construct()

public __construct(ParserMessageProxyFactory $parserMessageProxyFactory, ParserMimePartProxyFactory $parserMimePartProxyFactory, PartBuilderFactory $partBuilderFactory, PartHeaderContainerFactory $partHeaderContainerFactory, HeaderParserService $headerParser) : mixed
Parameters
$parserMessageProxyFactory : ParserMessageProxyFactory
$parserMimePartProxyFactory : ParserMimePartProxyFactory
$partBuilderFactory : PartBuilderFactory
$partHeaderContainerFactory : PartHeaderContainerFactory
$headerParser : HeaderParserService
Return values
mixed

getParserMessageProxyFactory()

Returns the ParserPartProxyFactory responsible for creating IMessage parts for this parser.

public getParserMessageProxyFactory() : ParserPartProxyFactory

This is called by ParserManager after 'canParse' if it returns true so a ParserPartProxy can be created out of the PartBuilder.

Return values
ParserPartProxyFactory

getParserPartProxyFactory()

Returns the ParserPartProxyFactory responsible for creating IMessagePart parts for this parser.

public getParserPartProxyFactory() : ParserPartProxyFactory

This is called by ParserManager after 'canParse' if it returns true so a ParserPartProxy can be created out of the PartBuilder.

Return values
ParserPartProxyFactory

setParserManager()

Sets up the passed ParserManager as the ParserManager for this part, which should be used when a new part is created (after its headers are read and a PartBuilder is created from it.)

public setParserManager(ParserManagerService $pm) : static
Parameters
$pm : ParserManagerService

The ParserManager to set.

Return values
static

createPart()

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

private createPart(ParserMimePartProxy $parent, PartHeaderContainer $headerContainer, PartBuilder $child) : ParserPartProxy|null

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.

Parameters
$parent : ParserMimePartProxy
$headerContainer : PartHeaderContainer
$child : PartBuilder
Return values
ParserPartProxy|null

findContentBoundary()

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.

private findContentBoundary(ParserMimePartProxy $proxy) : static

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.

Parameters
$proxy : ParserMimePartProxy
Return values
static

readBoundaryLine()

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.

private readBoundaryLine(resource $handle, ParserMimePartProxy $proxy) : string

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

Parameters
$handle : resource
$proxy : ParserMimePartProxy
Return values
string

Search results