User::setPasswordResetToken()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Entity;
4
5
use App\Model\CourseInterface;
6
use App\Model\NotificationInterface;
7
use App\Model\PersistableAwareTrait;
8
use App\Model\TimestampableAwareTrait;
9
use App\Model\UserInterface;
10
use Doctrine\Common\Collections\ArrayCollection;
11
use Doctrine\Common\Collections\Collection;
12
13
class User implements UserInterface
14
{
15
    use TimestampableAwareTrait;
16
    use PersistableAwareTrait;
17
18
    private ?string $email = null;
19
20
    private array $roles = [];
21
22
    private ?string $password = null;
23
24
    private ?string $firstName = null;
25
26
    private ?string $lastName = null;
27
28
    private ?string $plainPassword = null;
29
30
    private bool $passwordNeedToBeChanged;
31
32
    private ?string $passwordResetToken = null;
33
34
    private Collection $courses;
35
36
    private Collection $notifications;
37
38
    private ?\DateTime $lastLoginDate = null;
39
40
    public function __construct()
41
    {
42
        $this->courses = new ArrayCollection();
43
        $this->notifications = new ArrayCollection();
44
        $this->passwordNeedToBeChanged = false;
45
    }
46
47
    public function getEmail(): ?string
48
    {
49
        return $this->email;
50
    }
51
52
    public function setEmail(string $email): void
53
    {
54
        $this->email = $email;
55
    }
56
57
    public function getUsername(): string
58
    {
59
        return (string) $this->email;
60
    }
61
62
    public function getRoles(): array
63
    {
64
        $roles = $this->roles;
65
        $roles[] = 'ROLE_USER';
66
67
        return array_unique($roles);
68
    }
69
70
    public function setRoles(array $roles): void
71
    {
72
        $this->roles = $roles;
73
    }
74
75
    public function getPassword(): string
76
    {
77
        return (string) $this->password;
78
    }
79
80
    public function setPassword(string $password): void
81
    {
82
        $this->password = $password;
83
    }
84
85
    public function getPlainPassword(): ?string
86
    {
87
        return $this->plainPassword;
88
    }
89
90
    public function setPlainPassword(?string $plainPassword): void
91
    {
92
        $this->plainPassword = $plainPassword;
93
    }
94
95
    public function getSalt(): ?string
96
    {
97
        return null;
98
    }
99
100
    public function eraseCredentials()
101
    {
102
        $this->plainPassword = null;
103
    }
104
105
    public function getFirstName(): ?string
106
    {
107
        return $this->firstName;
108
    }
109
110
    public function setFirstName(string $firstName): void
111
    {
112
        $this->firstName = $firstName;
113
    }
114
115
    public function getLastName(): ?string
116
    {
117
        return $this->lastName;
118
    }
119
120
    public function setLastName(string $lastName): void
121
    {
122
        $this->lastName = $lastName;
123
    }
124
125
    public function getCourses(): Collection
126
    {
127
        return $this->courses;
128
    }
129
130
    public function addCourse(CourseInterface $course): void
131
    {
132
        if (!$this->courses->contains($course)) {
133
            $this->courses->add($course);
134
        }
135
    }
136
137
    public function removeCourse(CourseInterface $course): void
138
    {
139
        if ($this->courses->contains($course)) {
140
            $this->courses->removeElement($course);
141
        }
142
    }
143
144
    public function getNotifications(): Collection
145
    {
146
        return $this->notifications;
147
    }
148
149
    public function addNotification(NotificationInterface $notification): void
150
    {
151
        if (!$this->notifications->contains($notification)) {
152
            $this->notifications->add($notification);
153
        }
154
    }
155
156
    public function getPasswordNeedToBeChanged(): ?bool
157
    {
158
        return $this->passwordNeedToBeChanged;
159
    }
160
161
    public function setPasswordNeedToBeChanged($passwordNeedToBeChanged): void
162
    {
163
        $this->passwordNeedToBeChanged = $passwordNeedToBeChanged;
164
    }
165
166
    public function getPasswordResetToken(): ?string
167
    {
168
        return $this->passwordResetToken;
169
    }
170
171
    public function setPasswordResetToken(?string $passwordResetToken): void
172
    {
173
        $this->passwordResetToken = $passwordResetToken;
174
    }
175
176
    public function getLastLoginDate(): ?\DateTime
177
    {
178
        return $this->lastLoginDate;
179
    }
180
181
    public function setLastLoginDate(?\DateTime $lastLoginDate): void
182
    {
183
        $this->lastLoginDate = $lastLoginDate;
184
    }
185
}
186