ApplyEmailMessageOptions   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
dl 0
loc 35
ccs 18
cts 18
cp 1
rs 10
c 1
b 0
f 0
wmc 9

2 Methods

Rating   Name   Duplication   Size   Complexity  
B applyParticipants() 0 24 7
A apply() 0 6 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FH\Bundle\MailerBundle\Composer;
6
7
use FH\Bundle\MailerBundle\Email\MessageOptions;
8
use FH\Bundle\MailerBundle\Email\Participants;
9
use Symfony\Component\Mime\Email;
10
11
final class ApplyEmailMessageOptions
12
{
13 1
    public function apply(Email $email, MessageOptions $messageOptions): void
14
    {
15 1
        $this->applyParticipants($email, $messageOptions->getParticipants());
16
17 1
        if ($messageOptions->hasSubject()) {
18 1
            $email->subject((string) $messageOptions->getSubject());
19
        }
20 1
    }
21
22 1
    private function applyParticipants(Email $email, Participants $participants): void
23
    {
24 1
        if ($participants->hasSender()) {
25 1
            $email->sender($participants->getSender());
26
        }
27
28 1
        if ($participants->hasFrom()) {
29 1
            $email->from(...$participants->getFrom());
30
        }
31
32 1
        if ($participants->hasReplyTo()) {
33 1
            $email->replyTo(...$participants->getReplyTo());
34
        }
35
36 1
        if ($participants->hasTo()) {
37 1
            $email->to(...$participants->getTo());
38
        }
39
40 1
        if ($participants->hasCc()) {
41 1
            $email->cc(...$participants->getCc());
42
        }
43
44 1
        if ($participants->hasBcc()) {
45 1
            $email->bcc(...$participants->getBcc());
46
        }
47 1
    }
48
}
49