Test Setup Failed
Branch master (354693)
by Valery
09:34
created

SwiftMailerAdapter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 23
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A send() 0 11 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Mailer\Sender\Adapter;
6
7
use Swift_Message;
8
9
final class SwiftMailerAdapter implements SenderAdapterInterface
10
{
11
    /**
12
     * @var \Swift_Mailer
13
     */
14
    private $mailer;
15
16
    public function __construct(\Swift_Mailer $mailer)
17
    {
18
        $this->mailer = $mailer;
19
    }
20
21
    public function send(string $fromName, string $fromEmail, string $toEmail, string $subject, string $body): void
22
    {
23
        // Create a message
24
        $message = (new Swift_Message($subject))
25
            ->setFrom([$fromEmail => $fromName])
26
            ->setTo([$toEmail])
27
            ->setReplyTo([$fromEmail])
28
            ->setBody($body);
29
30
        // Send the message
31
        $this->mailer->send($message);
32
    }
33
}
34