Passed
Push — master ( da5e90...646b1f )
by Malte
02:52
created

AttachmentMask::getAttachment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
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\IMAP\Support\Masks;
14
15
use Webklex\IMAP\Attachment;
16
17
/**
18
 * Class AttachmentMask
19
 *
20
 * @package Webklex\IMAP\Support\Masks
21
 */
22
class AttachmentMask extends Mask {
23
24
    /** @var Attachment $parent */
25
    protected $parent;
26
27
    /**
28
     * Get the attachment content base64 encoded
29
     *
30
     * @return string|null
31
     */
32
    public function getContentBase64Encoded() {
33
        return base64_encode($this->parent->content);
34
    }
35
36
    /**
37
     * Get an base64 image src string
38
     *
39
     * @return string|null
40
     */
41
    public function getImageSrc() {
42
        return 'data:'.$this->parent->content_type.';base64,'.$this->getContentBase64Encoded();
43
    }
44
}