Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
22 | public function parse($attachment, string $attachmentName = null): Mime\Part |
||
23 | { |
||
24 | if (! \is_resource($attachment)) { |
||
25 | throw InvalidAttachmentException::fromExpectedType('resource'); |
||
26 | } |
||
27 | |||
28 | $resourceData = \stream_get_meta_data($attachment); |
||
29 | $name = $attachmentName ?? (isset($resourceData['uri']) ? \basename($resourceData['uri']) : null); |
||
30 | $part = new Mime\Part($attachment); |
||
31 | |||
32 | // Make sure encoding and disposition have a default value |
||
33 | $part->encoding = Mime\Mime::ENCODING_BASE64; |
||
34 | $part->disposition = Mime\Mime::DISPOSITION_ATTACHMENT; |
||
35 | |||
36 | return $this->applyNameToPart($part, $name); |
||
37 | } |
||
38 | } |
||
39 |