Issues (62)

src/Entity/User.php (1 issue)

Severity
1
<?php
2
namespace App\Entity;
3
4
use Doctrine\ORM\Mapping as ORM;
5
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
6
use Symfony\Component\Security\Core\User\UserInterface;
7
use App\Traits\HasTimestamps;
8
use Gedmo\Mapping\Annotation as Gedmo;
9
use Ramsey\Uuid\UuidInterface;
10
use App\Entity\Enum\UserStatusEnum;
11
12
/**
13
 * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
14
 * @ORM\Table(name="user")
15
 * @UniqueEntity("email")
16
 * @ORM\HasLifecycleCallbacks()
17
 * @Gedmo\SoftDeleteable(fieldName="deletedAt", hardDelete=false)
18
 */
19
class User implements UserInterface
20
{
21
    use HasTimestamps;
22
23
    /**
24
     * @var UuidInterface
25
     * @ORM\Id()
26
     * @ORM\Column(type="uuid", unique=true)
27
     * @ORM\GeneratedValue(strategy="NONE")
28
     */
29
    private $id;
30
31
    /**
32
     * @var string
33
     *
34
     * @ORM\Column(type="string", length=250, unique=true)
35
     */
36
    protected $email;
37
38
    /**
39
     * @var string
40
     *
41
     * @ORM\Column(name="first_name", type="string", length=250)
42
     */
43
    protected $firstName;
44
45
    /**
46
     * @var string
47
     *
48
     * @ORM\Column(name="last_name", type="string", length=250)
49
     */
50
    protected $lastName;
51
52
    /**
53
     * @var UserStatusEnum
54
     * @ORM\Embedded(class="App\Entity\Enum\UserStatusEnum")
55
     */
56
    private $status;
57
58
    /**
59
     * @var string
60
     *
61
     * @ORM\Column(name="password", type="string", length=250)
62
     */
63
    protected $password;
64
65
    /**
66
     * @var string|null
67
     *
68
     * @ORM\Column(type="string", length=255, nullable=true)
69
     */
70
    protected $passwordRequestToken;
71
72
    /**
73
     * @var array $roles
74
     *
75
     * @ORM\Column(type="array")
76
     */
77
    private $roles = ['ROLE_USER'];
78
79
    /**
80
     * @var ?\DateTime
81
     * @ORM\Column(type="datetime", nullable=true)
82
     */
83
    private $deletedAt;
0 ignored issues
show
The private property $deletedAt is not used, and could be removed.
Loading history...
84
85
    /**
86
     * This is never stored in DB, only used in form
87
     * 
88
     * @var string|null
89
     */
90
    protected $plainPassword;
91
92
    /**
93
     * @param UuidInterface $id
94
     */
95 39
    public function __construct(UuidInterface $id)
96
    {
97 39
        $this->setId($id);
98 39
    }
99
100
    /**
101
     * @param UuidInterface $id
102
     * @return User
103
     */
104 39
    public function setId(UuidInterface $id): self
105
    {
106 39
        $this->id = $id;
107
        
108 39
        return $this;
109
    }
110
111
    /**
112
     * @return UuidInterface
113
     */
114 18
    public function getId(): UuidInterface
115
    {
116 18
        return $this->id;
117
    }
118
119
    /**
120
     * @return string
121
     */
122 4
    public function getEmail(): string
123
    {
124 4
        return $this->email;
125
    }
126
127
    /**
128
     * @param string $email
129
     *
130
     * @return User
131
     */
132 39
    public function setEmail(string $email): User
133
    {
134 39
        $this->email = $email;
135 39
        return $this;
136
    }
137
138
    /**
139
     * @param string $firstName
140
     *
141
     * @return User
142
     */
143 39
    public function setFirstName(string $firstName): User
144
    {
145 39
        $this->firstName = $firstName;
146 39
        return $this;
147
    }
148
149
    /**
150
     * @param string $lastName
151
     *
152
     * @return User
153
     */
154 39
    public function setLastName(string $lastName): User
155
    {
156 39
        $this->lastName = $lastName;
157 39
        return $this;
158
    }
159
160
    /**
161
     * @return string
162
     */
163 2
    public function getPassword(): string
164
    {
165 2
        return $this->password;
166
    }
167
168
    /**
169
     * @param string $password
170
     *
171
     * @return User
172
     */
173 39
    public function setPassword(string $password): User
174
    {
175 39
        $this->password = $password;
176 39
        return $this;
177
    }
178
179
180
    /**
181
     * @return null|string
182
     */
183
    public function getPasswordRequestToken(): ?string
184
    {
185
        return $this->passwordRequestToken;
186
    }
187
188
    /**
189
     * @param null|string $passwordRequestToken
190
     *
191
     * @return User
192
     */
193
    public function setPasswordRequestToken(?string $passwordRequestToken): User
194
    {
195
        $this->passwordRequestToken = $passwordRequestToken;
196
        return $this;
197
    }
198
199
    /**
200
     * @return array
201
     */
202
    public function getRoles(): array
203
    {
204
        return $this->roles;
205
    }
206
207
    /**
208
     * @param array $roles
209
     *
210
     * @return User
211
     */
212
    public function setRoles(array $roles): User
213
    {
214
        $this->roles = $roles;
215
        return $this;
216
    }
217
218
    /**
219
     * @return string|null The salt
220
     */
221
    public function getSalt()
222
    {
223
        return null;
224
    }
225
226
    /**
227
     * @return string
228
     */
229 4
    public function getFirstName(): string
230
    {
231 4
        return $this->firstName;
232
    }
233
234
    /**
235
     * @return string
236
     */
237 4
    public function getLastName(): string
238
    {
239 4
        return $this->lastName;
240
    }
241
242
    /**
243
     * @return string The username
244
     */
245
    public function getUsername(): string
246
    {
247
        return $this->email;
248
    }
249
250
    /**
251
     * Removes sensitive data from the user.
252
     */
253
    public function eraseCredentials(): void
254
    {
255
    }
256
257
    /**
258
     * This is never stored in DB, only used in form
259
     *
260
     * @return null|string
261
     */
262 2
    public function getPlainPassword(): ?string
263
    {
264 2
        return $this->plainPassword;
265
    }
266
267
    /**
268
     * This is never stored in DB, only used in form
269
     * 
270
     * @param null|string $plainPassword
271
     * @return User
272
     */
273 39
    public function setPlainPassword(?string $plainPassword): User
274
    {
275 39
        $this->plainPassword = $plainPassword;
276 39
        return $this;
277
    }
278
279
    /**
280
     * @return UserStatusEnum
281
     */
282 2
    public function getStatus(): UserStatusEnum
283
    {
284 2
        return $this->status;
285
    }
286
287
    /**
288
     * @param UserStatusEnum $status
289
     * @return User
290
     */
291 39
    public function setStatus(UserStatusEnum $status): self
292
    {
293 39
        $this->status = $status;
294
295 39
        return $this;
296
    }
297
}