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

MessageOptions   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 21
c 0
b 0
f 0
dl 0
loc 62
rs 10
ccs 26
cts 26
cp 1
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A hasTextTemplate() 0 3 1
A getSubject() 0 3 1
A hasSubject() 0 3 1
A __construct() 0 10 1
A fromArray() 0 7 1
A getTextTemplate() 0 3 1
A getParticipants() 0 3 1
A hasHtmlTemplate() 0 3 1
A getHtmlTemplate() 0 3 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