Passed
Pull Request — master (#1904)
by Nico
39:29 queued 12:01
created

StuMail   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 40
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A send() 0 3 1
A setBody() 0 5 1
A setFrom() 0 5 1
A setSubject() 0 5 1
A addTo() 0 5 1
A __construct() 0 3 1
1
<?php
2
3
namespace Stu\Lib\Mail;
4
5
use Symfony\Component\Mailer\Mailer;
6
use Symfony\Component\Mime\Email;
7
8
class StuMail implements StuMailInterface
9
{
10
    private Email $email;
11
12
    public function __construct(private Mailer $mailer)
13
    {
14
        $this->email = new Email();
15
    }
16
17
    public function setFrom(string $from): StuMailInterface
18
    {
19
        $this->email->from($from);
20
21
        return $this;
22
    }
23
24
    public function addTo(string $to): StuMailInterface
25
    {
26
        $this->email->to($to);
27
28
        return $this;
29
    }
30
31
    public function setSubject(string $subject): StuMailInterface
32
    {
33
        $this->email->subject($subject);
34
35
        return $this;
36
    }
37
38
    public function setBody(string $text): StuMailInterface
39
    {
40
        $this->email->text($text);
41
42
        return $this;
43
    }
44
45
    public function send(): void
46
    {
47
        $this->mailer->send($this->email);
48
    }
49
}
50