Passed
Push — master ( 00f43d...a0d391 )
by Malte
02:56
created

AttachmentMask   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getAttachment() 0 2 1
A getContentBase64Encoded() 0 2 1
A getImageSrc() 0 2 1
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
45
    /**
46
     * Alias method for better code reading
47
     *
48
     * @return Attachment
49
     */
50
    public function getAttachment(){
51
        return $this->parent;
52
    }
53
}