Used by MessageParser to keep information about a parsed message as an intermediary before creating a Message object and its MessagePart children.

author Zaahid Bateson
package MailMimeParser

 Methods

Sets up class dependencies.

__construct(\ZBateson\MailMimeParser\Message\Part\Factory\MessagePartFactory $mpf, \ZBateson\MailMimeParser\Header\HeaderContainer $headerContainer) 

Parameters

$mpf

\ZBateson\MailMimeParser\Message\Part\Factory\MessagePartFactory

$headerContainer

\ZBateson\MailMimeParser\Header\HeaderContainer

Registers the passed PartBuilder as a child of the current PartBuilder.

addChild(\ZBateson\MailMimeParser\Message\PartBuilder $partBuilder) 

Parameters

$partBuilder

\ZBateson\MailMimeParser\Message\PartBuilder

Adds a header with the given $name and $value to the headers array.

addHeader(string $name, string $value) 

Removes non-alphanumeric characters from $name, and sets it to lower-case to use as a key in the private headers array. Sets the original $name and $value as elements in the headers' array value for the calculated key.

Parameters

$name

string

$value

string

Returns false if this part has a parent part in which endBoundaryFound is set to true (i.e. this isn't a discardable part following the parent's end boundary line).

canHaveHeaders() : boolean

Returns

boolean

Creates a MessagePart and returns it using the PartBuilder's MessagePartFactory passed in during construction.

createMessagePart(\Psr\Http\Message\StreamInterface $stream = null) : \ZBateson\MailMimeParser\Message\Part\MessagePart

Parameters

$stream

\Psr\Http\Message\StreamInterface

Returns

\ZBateson\MailMimeParser\Message\Part\MessagePart

Returns all children PartBuilder objects.

getChildren() : array<mixed,\ZBateson\MailMimeParser\Message\PartBuilder>

Returns

array<mixed,\ZBateson\MailMimeParser\Message\PartBuilder>

Returns a ParameterHeader representing the parsed Content-Type header for this PartBuilder.

getContentType() : \ZBateson\MailMimeParser\Header\ParameterHeader

Returns

\ZBateson\MailMimeParser\Header\ParameterHeader

Returns the HeaderContainer object containing parsed headers.

getHeaderContainer() : \ZBateson\MailMimeParser\Header\HeaderContainer

Returns

\ZBateson\MailMimeParser\Header\HeaderContainer

Returns the parsed boundary parameter of the Content-Type header if set for a multipart message part.

getMimeBoundary() : string

Returns

string

Returns this PartBuilder's parent.

getParent() : \ZBateson\MailMimeParser\Message\Part\PartBuilder

Returns

\ZBateson\MailMimeParser\Message\Part\PartBuilder

Returns the value of the property with the given $name.

getProperty(string $name) : mixed

Parameters

$name

string

Returns

mixed

Returns the length of this part's content stream.

getStreamContentLength() : integer

Returns

integer

Returns the offset for this part's content within its part stream.

getStreamContentStartOffset() : integer

Returns

integer

Returns the length of this part's stream.

getStreamPartLength() : integer

Returns

integer

Returns the offset for this part's stream within its parent stream.

getStreamPartStartOffset() : integer

Returns

integer

Returns true if either a Content-Type or Mime-Version header are defined in this PartBuilder's headers.

isMime() : boolean

Returns

boolean

Returns true if this part's content-type is multipart/*

isMultiPart() : boolean

Returns

boolean

Returns true if MessageParser passed an input line to setEndBoundary that matches a parent's mime boundary, and the following input belongs to a new part under its parent.

isParentBoundaryFound() : boolean

Returns

boolean

Returns true if the passed $line of read input matches this PartBuilder's mime boundary, or any of its parent's mime boundaries for a multipart message.

setEndBoundaryFound(string $line) : boolean

If the passed $line is the ending boundary for the current PartBuilder, $this->isEndBoundaryFound will return true after.

Parameters

$line

string

Returns

boolean

Called once EOF is reached while reading content. The method sets the flag used by PartBuilder::isParentBoundaryFound to true on this part and all parent PartBuilders.

setEof() 

Sets the specified property denoted by $name to $value.

setProperty(string $name, mixed $value) 

Parameters

$name

string

$value

mixed

Sets the start position of the content in the input stream.

setStreamContentStartPos(integer $streamContentStartPos) 

Parameters

$streamContentStartPos

integer

Sets the end position of the content and part in the input stream.

setStreamPartAndContentEndPos(integer $streamContentEndPos) 

Parameters

$streamContentEndPos

integer

Sets the end position of the part in the input stream, and also calls parent->setParentStreamPartEndPos to expand to parent parts.

setStreamPartEndPos(integer $streamPartEndPos) 

Parameters

$streamPartEndPos

integer

Sets the start position of the part in the input stream.

setStreamPartStartPos(integer $streamPartStartPos) 

Parameters

$streamPartStartPos

integer

 Properties

 

an array of children found below this part for a mime email

$children : array<mixed,\ZBateson\MailMimeParser\Message\Part\PartBuilder>

Default

array()
 

set to true once the end boundary of the currently-parsed part is found.

$endBoundaryFound : boolean

Default

false
 

a container for found and parsed headers.

$headerContainer : \ZBateson\MailMimeParser\Header\HeaderContainer

Default

 

the factory needed for creating the Message or MessagePart for the parsed part.

$messagePartFactory : \ZBateson\MailMimeParser\Message\Part\Factory\MessagePartFactory

Default

 

false if not queried for in the content-type header of this part, null if the current part does not have a boundary, or the value of the boundary parameter of the content-type header if the part contains one.

$mimeBoundary : boolean | null | string

Default

false
 

the parent part.

$parent : \ZBateson\MailMimeParser\Message\Part\PartBuilder

Default

null
 

set to true once a boundary belonging to this parent's part is found.

$parentBoundaryFound : boolean

Default

false
 

key => value pairs of properties passed on to the $messagePartFactory when constructing the Message and its children.

$properties : array<mixed,string>

Default

array()
 

The offset read end position in the message's stream for the end of this part's content (body).

$streamContentEndPos : integer

Default

0
 

The offset read start position in the message's stream for the beginning of this part's content (body).

$streamContentStartPos : integer

Default

0
 

The offset read end position for this part. If the part is a multipart mime part, the end position is after all of this parts children.

$streamPartEndPos : integer

Default

0
 

The offset read start position for this part (beginning of headers) in the message's stream.

$streamPartStartPos : integer

Default

0