Completed
Push — master ( 985877...b2fa88 )
by Frederik
02:11
created

From::fromEmailAddress()   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 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Genkgo\Mail\Header;
5
6
use Genkgo\Mail\Address;
7
use Genkgo\Mail\EmailAddress;
8
use Genkgo\Mail\HeaderInterface;
9
10
final class From implements HeaderInterface
11
{
12
    /**
13
     * @var Address
14
     */
15
    private $from;
16
17
    /**
18
     * From constructor.
19
     * @param Address $from
20
     */
21 9
    public function __construct(Address $from)
22
    {
23 9
        $this->from = $from;
24 9
    }
25
26
    /**
27
     * @return HeaderName
28
     */
29 8
    public function getName(): HeaderName
30
    {
31 8
        return new HeaderName('From');
32
    }
33
34
    /**
35
     * @return HeaderValue
36
     */
37 9
    public function getValue(): HeaderValue
38
    {
39 9
        return new HeaderValue((string)$this->from);
40
    }
41
42
    /**
43
     * @param string $emailAddress
44
     * @return From
45
     */
46 1
    public static function fromEmailAddress(string $emailAddress): From
47
    {
48 1
        return new self(new Address(new EmailAddress($emailAddress)));
49
    }
50
}