Passed
Push — master ( d7e8d7...5cd27e )
by
unknown
26:58 queued 24:20
created

EmailAddress   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 53
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getEmail() 0 3 1
A getName() 0 3 1
A parseToMailer() 0 3 1
A make() 0 3 1
1
<?php
2
3
namespace Da\Mailer\Mail\Dto;
4
5
use Symfony\Component\Mime\Address;
6
7
class EmailAddress
8
{
9
    /**
10
     * @var string
11
     */
12
    private string $email;
13
    /**
14
     * @var string|null
15
     */
16
    private ?string $name;
17
18
    /**
19
     * @param string $email
20
     * @param string|null $name
21
     */
22
    private function __construct(string $email, ?string $name = null)
23
    {
24
        $this->email = $email;
25
        $this->name = $name;
26
    }
27
28
    /**
29
     * @param string $email
30
     * @param string|null $name
31
     * @return static
32
     */
33
    public static function make(string $email, ?string $name = null): self
34
    {
35
        return new self($email, $name);
36
    }
37
38
    /**
39
     * @return string
40
     */
41
    public function getEmail(): string
42
    {
43
        return $this->email;
44
    }
45
46
    /**
47
     * @return string|null
48
     */
49
    public function getName(): ?string
50
    {
51
        return $this->name;
52
    }
53
54
    /**
55
     * @return Address
56
     */
57
    public function parseToMailer(): Address
58
    {
59
        return new Address($this->getEmail(), $this->getName());
0 ignored issues
show
Bug introduced by
It seems like $this->getName() can also be of type null; however, parameter $name of Symfony\Component\Mime\Address::__construct() does only seem to accept 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

59
        return new Address($this->getEmail(), /** @scrutinizer ignore-type */ $this->getName());
Loading history...
60
    }
61
}
62