InlineAttachment   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 12
dl 0
loc 46
ccs 12
cts 12
cp 1
rs 10
c 1
b 0
f 1
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
A getAttachment() 0 3 1
A getContentID() 0 3 1
1
<?php
2
3
namespace Kodus\Mail;
4
5
class InlineAttachment
6
{
7
    /**
8
     * @var Attachment
9
     */
10
    private $attachment;
11
12
    /**
13
     * @var string inline Content ID (in mailbox format, per RFC 2392)
14
     */
15
    private $content_id;
16
17
    /**
18
     * @var string random seed for Content ID creation
19
     */
20
    private static $seed;
21
22
    /**
23
     * @param Attachment $attachment
24
     */
25 5
    public function __construct(Attachment $attachment)
26
    {
27 5
        if (self::$seed === null) {
0 ignored issues
show
introduced by
The condition self::seed === null is always false.
Loading history...
28 1
            self::$seed = sha1(mt_rand() . microtime());
29 1
        } else {
30 5
            self::$seed = sha1("d73TfecaRMDmRPqBgy4Lv5wZavBeHagmqnLBgd5w" . self::$seed);
31
        }
32
33 5
        $this->attachment = $attachment;
34 5
        $this->content_id = sha1(self::$seed) . "@kodus.mail";
35 5
    }
36
37
    /**
38
     * @return Attachment
39
     */
40 5
    public function getAttachment(): Attachment
41
    {
42 5
        return $this->attachment;
43
    }
44
45
    /**
46
     * @return string
47
     */
48 5
    public function getContentID(): string
49
    {
50 5
        return $this->content_id;
51
    }
52
}
53