Author::getEmail()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
ccs 0
cts 0
cp 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: davis
5
 * Date: 7/23/17
6
 * Time: 3:05 AM
7
 */
8
9
namespace DavisPeixoto\BlogCore\Entity;
10
11
use DateTime;
12
use Ramsey\Uuid\Exception\InvalidUuidStringException;
13
14
/**
15
 * Class Author
16
 * @package DavisPeixoto\BlogCore\Entity
17
 */
18
class Author extends AbstractEntity
19
{
20
    /**
21
     * @var string
22
     */
23
    private $name;
24
25
    /**
26
     * @var string
27
     */
28
    private $email;
29
30
    /**
31
     * @var string
32
     */
33
    private $bio;
34
35
    /**
36
     * @var DateTime|null
37
     */
38
    private $birthdate;
39
40
    /**
41
     * Author constructor.
42
     * @param string $name
43
     * @param string $email
44
     * @param string $bio
45
     * @param string|null $id
46
     * @param DateTime|null $birthdate
47
     * @throws InvalidUuidStringException
48
     */
49 26
    public function __construct(string $name, string $email, string $bio, string $id = null, DateTime $birthdate = null)
50
    {
51 26
        $this->setId($id);
52 24
        $this->setName($name);
53 24
        $this->setEmail($email);
54 24
        $this->setBio($bio);
55 24
        $this->setBirthdate($birthdate);
56 24
    }
57
58
    /**
59
     * @codeCoverageIgnore
60
     * @return string
61
     */
62
    public function getName(): string
63
    {
64
        return $this->name;
65
    }
66
67
    /**
68
     * @codeCoverageIgnore
69
     * @param string $name
70
     */
71
    public function setName(string $name)
72
    {
73
        $this->name = $name;
74
    }
75
76
    /**
77
     * @codeCoverageIgnore
78
     * @return string
79
     */
80
    public function getEmail(): string
81
    {
82
        return $this->email;
83
    }
84
85
    /**
86
     * @param string $email
87
     */
88 27
    public function setEmail(string $email)
89
    {
90 27
        $email = filter_var($email, FILTER_SANITIZE_EMAIL);
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $email. This often makes code more readable.
Loading history...
91 27
        $email = filter_var($email, FILTER_VALIDATE_EMAIL);
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $email. This often makes code more readable.
Loading history...
92 27
        if ($email !== false) {
93 25
            $this->email = $email;
94
        }
95 27
    }
96
97
    /**
98
     * @codeCoverageIgnore
99
     * @return string
100
     */
101
    public function getBio(): string
102
    {
103
        return $this->bio;
104
    }
105
106
    /**
107
     * @codeCoverageIgnore
108
     * @param string $bio
109
     */
110
    public function setBio(string $bio)
111
    {
112
        $this->bio = $bio;
113
    }
114
115
    /**
116
     * @codeCoverageIgnore
117
     * @return DateTime|null
118
     */
119
    public function getBirthdate()
120
    {
121
        return $this->birthdate;
122
    }
123
124
    /**
125
     * @codeCoverageIgnore
126
     * @param DateTime|null $birthdate
127
     */
128
    public function setBirthdate(DateTime $birthdate = null)
129
    {
130
        $this->birthdate = $birthdate;
131
    }
132
}
133