Completed
Pull Request — develop (#13)
by Misha
02:55
created

MessageOptions::hasTextTemplate()   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
declare(strict_types=1);
3
4
namespace FH\Bundle\MailerBundle\Email;
5
6
final class MessageOptions
7
{
8
    private $subject;
9
    private $htmlTemplate;
10
    private $textTemplate;
11
    private $participants;
12
13 1
    public static function fromArray(array $messageOptions): self
14
    {
15 1
        return new self(
16 1
            $messageOptions['subject'],
17 1
            $messageOptions['html_template'] ?? null,
18 1
            $messageOptions['text_template'] ?? null,
19 1
            Participants::fromArray($messageOptions['participants'])
20
        );
21
    }
22
23 1
    public function __construct(
24
        ?string $subject,
25
        ?string $htmlTemplate,
26
        ?string $textTemplate,
27
        Participants $participants
28
    ) {
29 1
        $this->subject = $subject;
30 1
        $this->htmlTemplate = $htmlTemplate;
31 1
        $this->textTemplate = $textTemplate;
32 1
        $this->participants = $participants;
33 1
    }
34
35 1
    public function getSubject(): ?string
36
    {
37 1
        return $this->subject;
38
    }
39
40 1
    public function hasSubject(): bool
41
    {
42 1
        return is_string($this->subject);
43
    }
44
45 1
    public function getHtmlTemplate(): ?string
46
    {
47 1
        return $this->htmlTemplate;
48
    }
49
50 1
    public function hasHtmlTemplate(): bool
51
    {
52 1
        return is_string($this->htmlTemplate);
53
    }
54
55 1
    public function getTextTemplate(): ?string
56
    {
57 1
        return $this->textTemplate;
58
    }
59
60 1
    public function hasTextTemplate(): bool
61
    {
62 1
        return is_string($this->textTemplate);
63
    }
64
65 1
    public function getParticipants(): Participants
66
    {
67 1
        return $this->participants;
68
    }
69
}
70