@@ 249-259 (lines=11) @@ | ||
246 | * @return $this |
|
247 | * @throws \InvalidArgumentException When $attachment is neither of the supported types. |
|
248 | */ |
|
249 | public function attach($attachment) : Message |
|
250 | { |
|
251 | // Let's try to resolve the input into something usable. |
|
252 | if (!($attachment = $this->resolveAttachment($attachment)) instanceof message\Attachment) { |
|
253 | throw new \InvalidArgumentException("Expected a callable, an array or an instance of ".message\Attachment::class.", got [".diagnostics\Debug::getTypeName($attachment)."] instead."); |
|
254 | } |
|
255 | ||
256 | $this->attachments[] = $attachment; |
|
257 | ||
258 | return $this; |
|
259 | } |
|
260 | ||
261 | /** |
|
262 | * Checks whether an Attachment with the specified $index is set. |
|
@@ 295-305 (lines=11) @@ | ||
292 | * @return $this |
|
293 | * @throws \InvalidArgumentException |
|
294 | */ |
|
295 | public function setAttachment(int $index, $attachment) : Message |
|
296 | { |
|
297 | // Let's try to resolve the input into something usable. |
|
298 | if (!($attachment = $this->resolveAttachment($attachment)) instanceof message\Attachment) { |
|
299 | throw new \InvalidArgumentException("Expected a callable, an array or an instance of ".message\Attachment::class.", got [".diagnostics\Debug::getTypeName($attachment)."] instead."); |
|
300 | } |
|
301 | ||
302 | $this->attachments[$index] = $attachment; |
|
303 | ||
304 | return $this; |
|
305 | } |
|
306 | ||
307 | /** |
|
308 | * Returns the Attachments of the Message. |