Failed Conditions
Pull Request — develop (#23)
by Jeffrey
03:42
created

MessageOptions::getTextTemplate()   A

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 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FH\Bundle\MailerBundle\Email;
6
7
use FH\Bundle\MailerBundle\Exception\InvalidArgumentException;
8
9
final class MessageOptions
10
{
11
    /** @var string|null */
12
    private $subject;
13
14
    /** @var string|null */
15
    private $htmlTemplate;
16
17
    /** @var string|null */
18
    private $textTemplate;
19
20
    /** @var Participants */
21
    private $participants;
22
23 1
    public static function fromArray(array $messageOptions): self
24
    {
25 1
        return new self(
26 1
            $messageOptions['subject'],
27 1
            $messageOptions['html_template'] ?? null,
28 1
            $messageOptions['text_template'] ?? null,
29 1
            Participants::fromArray($messageOptions['participants'])
30
        );
31
    }
32
33 1
    public function __construct(
34
        ?string $subject,
35
        ?string $htmlTemplate,
36
        ?string $textTemplate,
37
        Participants $participants
38
    ) {
39 1
        $this->subject = $subject;
40 1
        $this->htmlTemplate = $htmlTemplate;
41 1
        $this->textTemplate = $textTemplate;
42 1
        $this->participants = $participants;
43 1
    }
44
45 1
    public function getSubject(): string
46
    {
47 1
        if (!\is_string($this->subject)) {
48
            throw new InvalidArgumentException('Invalid subject');
49
        }
50
51 1
        return $this->subject;
52
    }
53
54 1
    public function hasSubject(): bool
55
    {
56 1
        return \is_string($this->subject);
57
    }
58
59 1
    public function getHtmlTemplate(): ?string
60
    {
61 1
        return $this->htmlTemplate;
62
    }
63
64 1
    public function hasHtmlTemplate(): bool
65
    {
66 1
        return \is_string($this->htmlTemplate);
67
    }
68
69 1
    public function getTextTemplate(): ?string
70
    {
71 1
        return $this->textTemplate;
72
    }
73
74 1
    public function hasTextTemplate(): bool
75
    {
76 1
        return \is_string($this->textTemplate);
77
    }
78
79 1
    public function getParticipants(): Participants
80
    {
81 1
        return $this->participants;
82
    }
83
}
84