Subject::getValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

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
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 Subject implements HeaderInterface
9
{
10
    /**
11
     * @var string
12
     */
13
    private $subject;
14
15
    /**
16
     * @param string $subject
17
     */
18 42
    public function __construct(string $subject)
19
    {
20 42
        if (\preg_match('/\v/u', $subject) !== 0) {
21 3
            throw new \InvalidArgumentException('Cannot use vertical white space within subject');
22
        }
23
24 39
        $this->subject = $subject;
25 39
    }
26
27
    /**
28
     * @return HeaderName
29
     */
30 27
    public function getName(): HeaderName
31
    {
32 27
        return new HeaderName('Subject');
33
    }
34
35
    /**
36
     * @return HeaderValue
37
     */
38 37
    public function getValue(): HeaderValue
39
    {
40 37
        return new HeaderValue($this->subject);
41
    }
42
}
43