InlineAttachment::getContentID()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 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