Completed
Pull Request — master (#45)
by Frederik
03:54 queued 33s
created

ContentID::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Genkgo\Mail\Header;
5
6
use Genkgo\Mail\HeaderInterface;
7
8
final class ContentID implements HeaderInterface
9
{
10
    /**
11
     * @var string
12
     */
13
    private $contentID;
14
15
    /**
16
     * From constructor.
17
     * @param string $contentID
18
     */
19 13
    public function __construct(string $contentID)
20
    {
21 13
        $this->contentID = $contentID;
22 13
    }
23
24
    /**
25
     * @return HeaderName
26
     */
27 13
    public function getName(): HeaderName
28
    {
29 13
        return new HeaderName('Content-ID');
30
    }
31
32
    /**
33
     * @return HeaderValue
34
     */
35 5
    public function getValue(): HeaderValue
36
    {
37 5
        return new HeaderValue($this->contentID);
38
    }
39
40
    /**
41
     * @param string $localPart
42
     * @param string $domain
43
     * @return ContentID
44
     */
45 2
    public static function fromUrlAddress(string $localPart, string $domain): self
46
    {
47 2
        return new self(
48 2
            sprintf(
49 2
                '<%s@%s>',
50 2
                $localPart,
51 2
                \idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46) ?: $domain
52
            )
53
        );
54
    }
55
}