Completed
Pull Request — master (#7)
by Davis
02:05
created

Author::getAuthorId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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