Mailer::sendWelcomeEmail()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 8
rs 10
1
<?php
2
3
namespace App;
4
5
use App\Document\User;
6
use Twig\Environment;
7
8
class Mailer
9
{
10
    private $mailer;
11
    private $twig;
12
    private $sender;
13
14
    public function __construct(Environment $twig, \Swift_Mailer $mailer, $sender)
15
    {
16
        $this->mailer = $mailer;
17
        $this->twig = $twig;
18
        $this->sender = $sender;
19
    }
20
21
    public function sendResetPasswordEmail(User $user)
22
    {
23
        $message = (new \Swift_Message('Reset password instructions'))
24
            ->setFrom($this->sender)
25
            ->setTo($user->getEmail())
26
            ->setBody($this->twig->render('emails/resetPassword.txt.twig', ['user' => $user]), 'text/plain');
27
28
        $this->mailer->send($message);
29
    }
30
31
    public function sendWelcomeEmail(User $user)
32
    {
33
        $message = (new \Swift_Message('Invitation to join Twity platform'))
34
            ->setFrom($this->sender)
35
            ->setTo($user->getEmail())
36
            ->setBody($this->twig->render('emails/welcome.txt.twig', ['user' => $user]), 'text/plain');
37
38
        $this->mailer->send($message);
39
    }
40
}
41