| 1 | <?php |
| 2 | /* |
| 3 | * File: AttachmentMask.php |
| 4 | * Category: Mask |
| 5 | * Author: M.Goldenbaum |
| 6 | * Created: 14.03.19 20:49 |
| 7 | * Updated: - |
| 8 | * |
| 9 | * Description: |
| 10 | * - |
| 11 | */ |
| 12 | |
| 13 | namespace Webklex\PHPIMAP\Support\Masks; |
| 14 | |
| 15 | use Webklex\PHPIMAP\Attachment; |
| 16 | |
| 17 | /** |
| 18 | * Class AttachmentMask |
| 19 | * |
| 20 | * @package Webklex\PHPIMAP\Support\Masks |
| 21 | * @mixin Attachment |
| 22 | */ |
| 23 | class AttachmentMask extends Mask { |
| 24 | |
| 25 | /** @var Attachment $parent */ |
| 26 | protected mixed $parent; |
| 27 | |
| 28 | /** |
| 29 | * Get the attachment content base64 encoded |
| 30 | * |
| 31 | * @return string|null |
| 32 | */ |
| 33 | public function getContentBase64Encoded(): ?string { |
| 34 | return base64_encode($this->parent->content); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Get a base64 image src string |
| 39 | * |
| 40 | * @return string|null |
| 41 | */ |
| 42 | public function getImageSrc(): ?string { |
| 43 | return 'data:'.$this->parent->content_type.';base64,'.$this->getContentBase64Encoded(); |
| 44 | } |
| 45 | } |