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

StuMail::addTo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
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