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