UUEncodedPart extends NonMimePart
A specialized NonMimePart representing a uuencoded part.
This represents part of a message that is not a mime message. A multi-part mime message may have a part with a Content-Transfer-Encoding of x-uuencode but that would be represented by a normal MimePart.
UUEncodedPart extends NonMimePart to return a Content-Transfer-Encoding of x-uuencode, a Content-Type of application-octet-stream, and a Content-Disposition of 'attachment'. It also expects a mode and filename to initialize it, and adds 'filename' parts to the Content-Disposition and 'name' to Content-Type.
Tags
Table of Contents
- $filename : string
- $handle : resource
- $headerFactory : HeaderFactory
- $headers : array<string|int, AbstractHeader>
- $mode : int
- $originalStreamHandle : mixed
- $parent : MimePart
- $parts : array<string|int, MimePart>
- $partWriter : MimePartWriter
- __construct() : mixed
- Initiates the UUEncodedPart with the passed mode and filename.
- __destruct() : mixed
- Closes the attached resource handle.
- addPart() : mixed
- Registers the passed part as a child of the current part.
- attachContentResourceHandle() : mixed
- Attaches the resource handle for the part's content. The attached handle is closed when the MimePart object is destroyed.
- attachOriginalStreamHandle() : mixed
- Attaches the resource handle representing the original stream that created this part (including any sub-parts). The attached handle is closed when the MimePart object is destroyed.
- getAllParts() : array<string|int, MimePart>
- Returns the current part, all child parts, and child parts of all children optionally filtering them with the provided PartFilter.
- getAllPartsByMimeType() : array<string|int, MimePart>
- Returns an array of all parts associated with the passed mime type if any exist or null otherwise.
- getChild() : MimePart
- Returns the direct child at the given 0-based index, or null if none is set.
- getChildCount() : int
- Returns the number of direct children under this part.
- getChildParts() : array<string|int, MimePart>
- Returns all direct child parts.
- getContent() : string
- Shortcut to reading stream content and assigning it to a string. Returns null if the part doesn't have a content stream.
- getContentResourceHandle() : resource
- Returns the resource stream handle for the part's content or null if not set. rewind() is called on the stream before returning it.
- getCountOfPartsByMimeType() : int
- Returns the number of parts matching the passed $mimeType
- getFilename() : string
- Returns the filename included in the uuencoded header for this part.
- getHeader() : AbstractHeader
- Returns the AbstractHeader object for the header with the given $name
- getHeaderParameter() : string
- Returns a parameter of the header $header, given the parameter named $param.
- getHeaders() : array<string|int, AbstractHeader>
- Returns the full array of headers for this part.
- getHeaderValue() : string
- Returns the string value for the header with the given $name.
- getOriginalStreamHandle() : resource
- Returns a resource stream handle allowing a user to read the original stream (including headers and child parts) that was used to create the current part.
- getParent() : MimePart
- Returns this part's parent.
- getPart() : MimePart
- Returns the part at the given 0-based index, or null if none is set.
- getPartByMimeType() : MimePart
- Returns the part associated with the passed mime type if it exists.
- getPartCount() : int
- Returns the total number of parts in this and all children.
- getUnixFileMode() : int
- Returns the file mode included in the uuencoded header for this part.
- hasContent() : bool
- Returns true if there's a content stream associated with the part.
- isMultiPart() : bool
- Returns true if this part's mime type is multipart/*
- isTextPart() : bool
- Returns true if this part's mime type is text/plain, text/html or has a text/* and has a defined 'charset' attribute.
- removeAllParts() : mixed
- Removes all parts that are matched by the passed PartFilter.
- removeHeader() : mixed
- Removes the header with the given name
- removePart() : int
- Removes the child part from this part and returns its position or null if it wasn't found.
- setContent() : mixed
- Sets the content of the part to the passed string (effectively creates a php://temp stream with the passed content and calls attachContentResourceHandle with the opened stream).
- setParent() : mixed
- Sets the parent part.
- setRawHeader() : mixed
- Adds a header with the given $name and $value.
- detachContentResourceHandle() : mixed
- Detaches the content resource handle from this part but does not close it.
Properties
$filename
protected
string
$filename
= null
$handle
protected
resource
$handle
$headerFactory
protected
HeaderFactory
$headerFactory
$headers
protected
array<string|int, AbstractHeader>
$headers
$mode
protected
int
$mode
= null
$originalStreamHandle
protected
mixed
$originalStreamHandle
$parent
protected
MimePart
$parent
$parts
protected
array<string|int, MimePart>
$parts
= []
$partWriter
protected
MimePartWriter
$partWriter
= null
Methods
__construct()
Initiates the UUEncodedPart with the passed mode and filename.
public
__construct(HeaderFactory $headerFactory, MimePartWriter $partWriter, int $mode, string $filename) : mixed
Parameters
- $headerFactory : HeaderFactory
- $partWriter : MimePartWriter
- $mode : int
-
the unix file mode
- $filename : string
-
the filename
Return values
mixed —__destruct()
Closes the attached resource handle.
public
__destruct() : mixed
Return values
mixed —addPart()
Registers the passed part as a child of the current part.
public
addPart(MimePart $part[, int $position = null ]) : mixed
If the $position parameter is non-null, adds the part at the passed position index.
Parameters
- $part : MimePart
- $position : int = null
Return values
mixed —attachContentResourceHandle()
Attaches the resource handle for the part's content. The attached handle is closed when the MimePart object is destroyed.
public
attachContentResourceHandle(resource $contentHandle) : mixed
Parameters
- $contentHandle : resource
Return values
mixed —attachOriginalStreamHandle()
Attaches the resource handle representing the original stream that created this part (including any sub-parts). The attached handle is closed when the MimePart object is destroyed.
public
attachOriginalStreamHandle(resource $handle) : mixed
This stream is not modified or changed as the part is changed and is only set during parsing in MessageParser.
Parameters
- $handle : resource
Return values
mixed —getAllParts()
Returns the current part, all child parts, and child parts of all children optionally filtering them with the provided PartFilter.
public
getAllParts([PartFilter $filter = null ]) : array<string|int, MimePart>
The first part returned is always the current MimePart. This is often desirable as it may be a valid MimePart for the provided PartFilter.
Parameters
- $filter : PartFilter = null
-
an optional filter
Return values
array<string|int, MimePart> —getAllPartsByMimeType()
Returns an array of all parts associated with the passed mime type if any exist or null otherwise.
public
getAllPartsByMimeType(string $mimeType) : array<string|int, MimePart>
Parameters
- $mimeType : string
Return values
array<string|int, MimePart> —or null
getChild()
Returns the direct child at the given 0-based index, or null if none is set.
public
getChild(int $index[, PartFilter $filter = null ]) : MimePart
Parameters
- $index : int
- $filter : PartFilter = null
Return values
MimePart —getChildCount()
Returns the number of direct children under this part.
public
getChildCount([PartFilter $filter = null ]) : int
Parameters
- $filter : PartFilter = null
Return values
int —getChildParts()
Returns all direct child parts.
public
getChildParts([PartFilter $filter = null ]) : array<string|int, MimePart>
If a PartFilter is provided, the PartFilter is applied before returning.
Parameters
- $filter : PartFilter = null
Return values
array<string|int, MimePart> —getContent()
Shortcut to reading stream content and assigning it to a string. Returns null if the part doesn't have a content stream.
public
getContent() : string
Return values
string —getContentResourceHandle()
Returns the resource stream handle for the part's content or null if not set. rewind() is called on the stream before returning it.
public
getContentResourceHandle() : resource
The resource is automatically closed by MimePart's destructor and should not be closed otherwise.
The returned resource handle is a stream with decoding filters appended to it. The attached filters are determined by looking at the part's Content-Encoding header. The following encodings are currently supported:
- Quoted-Printable
- Base64
- X-UUEncode
UUEncode may be automatically attached for a message without a defined Content-Encoding and Content-Type if it has a UUEncoded part to support older non-mime message attachments.
In addition, character encoding for text streams is converted to UTF-8 if MimePart::isTextPart returns true.
Return values
resource —getCountOfPartsByMimeType()
Returns the number of parts matching the passed $mimeType
public
getCountOfPartsByMimeType(string $mimeType) : int
Parameters
- $mimeType : string
Return values
int —getFilename()
Returns the filename included in the uuencoded header for this part.
public
getFilename() : string
Return values
string —getHeader()
Returns the AbstractHeader object for the header with the given $name
public
getHeader(string $name) : AbstractHeader
Note that mime headers aren't case sensitive.
Parameters
- $name : string
Return values
AbstractHeader —getHeaderParameter()
Returns a parameter of the header $header, given the parameter named $param.
public
getHeaderParameter(string $header, string $param[, string $defaultValue = null ]) : string
Only headers of type \ZBateson\MailMimeParser\Header\ParameterHeader have parameters. Content-Type and Content-Disposition are examples of headers with parameters. "Charset" is a common parameter of Content-Type.
Parameters
- $header : string
- $param : string
- $defaultValue : string = null
Return values
string —getHeaders()
Returns the full array of headers for this part.
public
getHeaders() : array<string|int, AbstractHeader>
Return values
array<string|int, AbstractHeader> —getHeaderValue()
Returns the string value for the header with the given $name.
public
getHeaderValue(string $name[, string $defaultValue = null ]) : string
Note that mime headers aren't case sensitive.
Parameters
- $name : string
- $defaultValue : string = null
Return values
string —getOriginalStreamHandle()
Returns a resource stream handle allowing a user to read the original stream (including headers and child parts) that was used to create the current part.
public
getOriginalStreamHandle() : resource
The part contains an original stream handle only if it was explicitly set by a call to MimePart::attachOriginalStreamHandle. MailMimeParser only sets this during the parsing phase in MessageParser, and is not otherwise changed or updated. New parts added below this part, changed headers, etc... would not be reflected in the returned stream handle.
Return values
resource —the resource handle or null if not set
getParent()
Returns this part's parent.
public
getParent() : MimePart
Return values
MimePart —getPart()
Returns the part at the given 0-based index, or null if none is set.
public
getPart(int $index[, PartFilter $filter = null ]) : MimePart
Note that the first part returned is the current part itself. This is often desirable for queries with a PartFilter, e.g. looking for a MimePart with a specific Content-Type that may be satisfied by the current part.
Parameters
- $index : int
- $filter : PartFilter = null
Return values
MimePart —getPartByMimeType()
Returns the part associated with the passed mime type if it exists.
public
getPartByMimeType(string $mimeType, mixed $index) : MimePart
Parameters
- $mimeType : string
- $index : mixed
Return values
MimePart —or null
getPartCount()
Returns the total number of parts in this and all children.
public
getPartCount([PartFilter $filter = null ]) : int
Note that the current part is considered, so the minimum getPartCount is 1 without a filter.
Parameters
- $filter : PartFilter = null
Return values
int —getUnixFileMode()
Returns the file mode included in the uuencoded header for this part.
public
getUnixFileMode() : int
Return values
int —hasContent()
Returns true if there's a content stream associated with the part.
public
hasContent() : bool
Return values
bool —isMultiPart()
Returns true if this part's mime type is multipart/*
public
isMultiPart() : bool
Return values
bool —isTextPart()
Returns true if this part's mime type is text/plain, text/html or has a text/* and has a defined 'charset' attribute.
public
isTextPart() : bool
Return values
bool —removeAllParts()
Removes all parts that are matched by the passed PartFilter.
public
removeAllParts([PartFilter $filter = null ]) : mixed
Parameters
- $filter : PartFilter = null
Return values
mixed —removeHeader()
Removes the header with the given name
public
removeHeader(string $name) : mixed
Parameters
- $name : string
Return values
mixed —removePart()
Removes the child part from this part and returns its position or null if it wasn't found.
public
removePart(MimePart $part) : int
Note that if the part is not a direct child of this part, the returned position is its index within its parent (calls removePart on its direct parent).
Parameters
- $part : MimePart
Return values
int —or null if not found
setContent()
Sets the content of the part to the passed string (effectively creates a php://temp stream with the passed content and calls attachContentResourceHandle with the opened stream).
public
setContent(string $string) : mixed
Parameters
- $string : string
Return values
mixed —setParent()
Sets the parent part.
public
setParent(MimePart $part) : mixed
Parameters
- $part : MimePart
Return values
mixed —setRawHeader()
Adds a header with the given $name and $value.
public
setRawHeader(string $name, string $value) : mixed
Creates a new \ZBateson\MailMimeParser\Header\AbstractHeader object and registers it as a header.
Parameters
- $name : string
- $value : string
Return values
mixed —detachContentResourceHandle()
Detaches the content resource handle from this part but does not close it.
protected
detachContentResourceHandle() : mixed