1 | <?php |
||
24 | class Message extends MimePart |
||
25 | { |
||
26 | /** |
||
27 | * @var string unique ID used to identify the object to |
||
28 | * $this->partStreamRegistry when registering the stream. The ID is |
||
29 | * used for opening stream parts with the mmp-mime-message "protocol". |
||
30 | * |
||
31 | * @see \ZBateson\MailMimeParser\SimpleDi::registerStreamExtensions |
||
32 | * @see \ZBateson\MailMimeParser\Stream\PartStream::stream_open |
||
33 | */ |
||
34 | protected $objectId; |
||
35 | |||
36 | /** |
||
37 | * @var \ZBateson\MailMimeParser\MimePart The plain text part or null if |
||
38 | * there isn't one |
||
39 | */ |
||
40 | protected $textPart; |
||
41 | |||
42 | /** |
||
43 | * @var \ZBateson\MailMimeParser\MimePart The HTML part stream or null if |
||
44 | * there isn't one |
||
45 | */ |
||
46 | protected $htmlPart; |
||
47 | |||
48 | /** |
||
49 | * @var \ZBateson\MailMimeParser\MimePart[] array of parts in this message |
||
50 | */ |
||
51 | protected $parts = []; |
||
52 | |||
53 | /** |
||
54 | * Constructs a Message. |
||
55 | * |
||
56 | * @param HeaderFactory $headerFactory |
||
57 | */ |
||
58 | 5 | public function __construct(HeaderFactory $headerFactory) |
|
63 | |||
64 | /** |
||
65 | * Returns the unique object ID registered with the PartStreamRegistry |
||
66 | * service object. |
||
67 | * |
||
68 | * @return string |
||
69 | */ |
||
70 | 1 | public function getObjectId() |
|
74 | |||
75 | /** |
||
76 | * Returns true if the $part should be assigned as this message's main |
||
77 | * text part content. |
||
78 | * |
||
79 | * @param \ZBateson\MailMimeParser\MimePart $part |
||
80 | * @return bool |
||
81 | */ |
||
82 | 3 | private function isMessageTextPart(MimePart $part) |
|
87 | |||
88 | /** |
||
89 | * Returns true if the $part should be assigned as this message's main |
||
90 | * html part content. |
||
91 | * |
||
92 | * @param \ZBateson\MailMimeParser\MimePart $part |
||
93 | * @return bool |
||
94 | */ |
||
95 | 2 | private function isMessageHtmlPart(MimePart $part) |
|
100 | |||
101 | /** |
||
102 | * Either adds the passed part to $this->textPart if its content type is |
||
103 | * text/plain, to $this->htmlPart if it's text/html, or adds the part to the |
||
104 | * parts array otherwise. |
||
105 | * |
||
106 | * @param \ZBateson\MailMimeParser\MimePart $part |
||
107 | */ |
||
108 | 3 | public function addPart(MimePart $part) |
|
118 | |||
119 | /** |
||
120 | * Returns the text part (or null if none is set.) |
||
121 | * |
||
122 | * @return \ZBateson\MailMimeParser\MimePart |
||
123 | */ |
||
124 | 3 | public function getTextPart() |
|
128 | |||
129 | /** |
||
130 | * Returns the HTML part (or null if none is set.) |
||
131 | * |
||
132 | * @return \ZBateson\MailMimeParser\MimePart |
||
133 | */ |
||
134 | 3 | public function getHtmlPart() |
|
138 | |||
139 | /** |
||
140 | * Returns the non-text, non-HTML part at the given 0-based index, or null |
||
141 | * if none is set. |
||
142 | * |
||
143 | * @param int $index |
||
144 | * @return \ZBateson\MailMimeParser\MimePart |
||
145 | */ |
||
146 | 3 | public function getAttachmentPart($index) |
|
153 | |||
154 | /** |
||
155 | * Returns all attachment parts. |
||
156 | * |
||
157 | * @return \ZBateson\MailMimeParser\MimePart[] |
||
158 | */ |
||
159 | 1 | public function getAllAttachmentParts() |
|
163 | |||
164 | /** |
||
165 | * Returns the number of attachments available. |
||
166 | * |
||
167 | * @return int |
||
168 | */ |
||
169 | 1 | public function getAttachmentCount() |
|
173 | |||
174 | /** |
||
175 | * Returns a resource handle where the text content can be read. |
||
176 | * |
||
177 | * @return resource |
||
178 | */ |
||
179 | 2 | public function getTextStream() |
|
186 | |||
187 | /** |
||
188 | * Returns the text content as a string. |
||
189 | * |
||
190 | * Reads the entire stream content into a string and returns it. Returns |
||
191 | * null if the message doesn't have a text part. |
||
192 | * |
||
193 | * @return string |
||
194 | */ |
||
195 | public function getTextContent() |
||
203 | |||
204 | /** |
||
205 | * Returns a resource handle where the HTML content can be read. |
||
206 | * |
||
207 | * @return resource |
||
208 | */ |
||
209 | 2 | public function getHtmlStream() |
|
216 | |||
217 | /** |
||
218 | * Returns the HTML content as a string. |
||
219 | * |
||
220 | * Reads the entire stream content into a string and returns it. Returns |
||
221 | * null if the message doesn't have an HTML part. |
||
222 | * |
||
223 | * @return string |
||
224 | */ |
||
225 | public function getHtmlContent() |
||
233 | |||
234 | /** |
||
235 | * Returns true if either a Content-Type or Mime-Version header are defined |
||
236 | * in this Message. |
||
237 | * |
||
238 | * @return bool |
||
239 | */ |
||
240 | 1 | public function isMime() |
|
246 | } |
||
247 |