Passed
Push — master ( d32758...1d7877 )
by Davis
44s
created

src/BlogCore/Entity/Author.php (2 issues)

Check that parameter names are not overwritten

Coding Style Informational

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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\UuidInterface;
14
use stdClass;
15
16
/**
17
 * Class Author
18
 * @package DavisPeixoto\BlogCore\Entity
19
 */
20
class Author extends stdClass
21
{
22
    /**
23
     * @var UuidInterface
24
     */
25
    private $authorId;
26
27
    /**
28
     * @var string
29
     */
30
    private $name;
31
32
    /**
33
     * @var string
34
     */
35
    private $email;
36
37
    /**
38
     * @var string
39
     */
40
    private $bio;
41
42
    /**
43
     * @var DateTime|null
44
     */
45
    private $birthdate;
46
47
    /**
48
     * Author constructor.
49
     * @param UuidInterface $authorId
50
     * @param string $name
51
     * @param string $email
52
     * @param string $bio
53
     * @param DateTime|null $birthdate
54
     */
55 34
    public function __construct(UuidInterface $authorId, $name, $email, $bio, DateTime $birthdate = null)
56
    {
57 34
        $this->authorId = $authorId;
58 34
        $this->name = $name;
59 34
        $this->email = $email;
60 34
        $this->bio = $bio;
61 34
        $this->birthdate = $birthdate;
62 34
    }
63
64
    /**
65
     * @codeCoverageIgnore
66
     * @return UuidInterface
67
     */
68
    public function getAuthorId(): UuidInterface
69
    {
70
        return $this->authorId;
71
    }
72
73
    /**
74
     * @codeCoverageIgnore
75
     * @param UuidInterface $authorId
76
     */
77
    public function setAuthorId(UuidInterface $authorId)
78
    {
79
        $this->authorId = $authorId;
80
    }
81
82
    /**
83
     * @codeCoverageIgnore
84
     * @return string
85
     */
86
    public function getName(): string
87
    {
88
        return $this->name;
89
    }
90
91
    /**
92
     * @codeCoverageIgnore
93
     * @param string $name
94
     */
95
    public function setName(string $name)
96
    {
97
        $this->name = $name;
98
    }
99
100
    /**
101
     * @codeCoverageIgnore
102
     * @return string
103
     */
104
    public function getEmail(): string
105
    {
106
        return $this->email;
107
    }
108
109
    /**
110
     * @param string $email
111
     */
112 3
    public function setEmail(string $email)
113
    {
114 3
        $email = filter_var($email, FILTER_SANITIZE_EMAIL);
0 ignored issues
show
Consider using a different name than the parameter $email. This often makes code more readable.
Loading history...
115 3
        $email = filter_var($email, FILTER_VALIDATE_EMAIL);
0 ignored issues
show
Consider using a different name than the parameter $email. This often makes code more readable.
Loading history...
116 3
        if ($email !== false) {
117 1
            $this->email = $email;
118
        }
119 3
    }
120
121
    /**
122
     * @codeCoverageIgnore
123
     * @return string
124
     */
125
    public function getBio(): string
126
    {
127
        return $this->bio;
128
    }
129
130
    /**
131
     * @codeCoverageIgnore
132
     * @param string $bio
133
     */
134
    public function setBio(string $bio)
135
    {
136
        $this->bio = $bio;
137
    }
138
139
    /**
140
     * @codeCoverageIgnore
141
     * @return DateTime|null
142
     */
143
    public function getBirthdate()
144
    {
145
        return $this->birthdate;
146
    }
147
148
    /**
149
     * @codeCoverageIgnore
150
     * @param DateTime|null $birthdate
151
     */
152
    public function setBirthdate(DateTime $birthdate = null)
153
    {
154
        $this->birthdate = $birthdate;
155
    }
156
}
157