EmailMessage::getViewData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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