EmailMessage   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 40
ccs 8
cts 8
cp 1
rs 10
c 2
b 0
f 0
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setTo() 0 4 2
A getViewData() 0 3 1
A setViewData() 0 3 1
A setSubject() 0 3 1
A setFrom() 0 4 1
A getTemplate() 0 3 1
A setTemplate() 0 3 1
1
<?php
2
3
namespace Bone\Mail;
4
5
use Symfony\Component\Mime\Address;
6
use Symfony\Component\Mime\Email;
7
8
class EmailMessage extends Email
9
{
10
    private array $viewData= [];
11
    private string $template = '';
12
13
    public function getViewData(): array
14
    {
15
        return $this->viewData;
16
    }
17
18 1
    public function setViewData(array $viewData): void
19
    {
20 1
        $this->viewData = $viewData;
21
    }
22
23
    public function getTemplate(): string
24
    {
25
        return $this->template;
26 1
    }
27
28 1
    public function setTemplate(string $template): void
29
    {
30
        $this->template = $template;
31
    }
32
33
    public function setFrom(string $email, string $name = ''): void
34 1
    {
35
        $from = new Address($email, $name);
36 1
        $this->from($from);
37
    }
38
39
    public function setTo(string $email, ?string $name = null): void
40
    {
41
        $to = $name ? [$email => $name] : $email;
42 1
        $this->to($to);
0 ignored issues
show
Bug introduced by
It seems like $to can also be of type array<string,string>; however, parameter $addresses of Symfony\Component\Mime\Email::to() does only seem to accept Symfony\Component\Mime\Address|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

42
        $this->to(/** @scrutinizer ignore-type */ $to);
Loading history...
43
    }
44 1
45
    public function setSubject(string $subject): void
46
    {
47
        $this->subject($subject);
48
    }
49
}
50