Passed
Pull Request — master (#45)
by Paweł
10:26
created

User::getNotifications()   A

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 0
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 $email;
19
20
    /**
21
     * @var string[]
22
     */
23
    private $roles = [];
24
25
    private $password;
26
27
    private $firstName;
28
29
    private $lastName;
30
31
    /**
32
     * @var string|null Temporary field used for password hashing
33
     */
34
    private $plainPassword;
35
36
    private $passwordNeedToBeChanged;
37
38
    private $passwordResetToken;
39
40
    private $courses;
41
42
    private Collection $notifications;
43
44
    public function __construct()
45
    {
46
        $this->courses = new ArrayCollection();
47
        $this->notifications = new ArrayCollection();
48
    }
49
50
    public function getEmail(): ?string
51
    {
52
        return $this->email;
53
    }
54
55
    public function setEmail(string $email): void
56
    {
57
        $this->email = $email;
58
    }
59
60
    public function getUsername(): string
61
    {
62
        return (string) $this->email;
63
    }
64
65
    public function getRoles(): array
66
    {
67
        $roles = $this->roles;
68
        $roles[] = 'ROLE_USER';
69
70
        return array_unique($roles);
71
    }
72
73
    public function setRoles(array $roles): void
74
    {
75
        $this->roles = $roles;
76
    }
77
78
    public function getPassword(): string
79
    {
80
        return (string) $this->password;
81
    }
82
83
    public function setPassword(string $password): void
84
    {
85
        $this->password = $password;
86
    }
87
88
    public function getPlainPassword(): ?string
89
    {
90
        return $this->plainPassword;
91
    }
92
93
    public function setPlainPassword(?string $plainPassword): void
94
    {
95
        $this->plainPassword = $plainPassword;
96
    }
97
98
    public function getSalt(): ?string
99
    {
100
        return null;
101
    }
102
103
    public function eraseCredentials()
104
    {
105
        $this->plainPassword = null;
106
    }
107
108
    public function getFirstName(): ?string
109
    {
110
        return $this->firstName;
111
    }
112
113
    public function setFirstName(string $firstName): void
114
    {
115
        $this->firstName = $firstName;
116
    }
117
118
    public function getLastName(): ?string
119
    {
120
        return $this->lastName;
121
    }
122
123
    public function setLastName(string $lastName): void
124
    {
125
        $this->lastName = $lastName;
126
    }
127
128
    public function getCourses(): Collection
129
    {
130
        return $this->courses;
131
    }
132
133
    public function addCourse(CourseInterface $course): void
134
    {
135
        if (!$this->courses->contains($course)) {
136
            $this->courses->add($course);
137
        }
138
    }
139
140
    public function removeCourse(CourseInterface $course): void
141
    {
142
        if ($this->courses->contains($course)) {
143
            $this->courses->removeElement($course);
144
        }
145
    }
146
147
    public function getNotifications(): Collection
148
    {
149
        return $this->notifications;
150
    }
151
152
    public function addNotification(NotificationInterface $notification): void
153
    {
154
        if (!$this->notifications->contains($notification)) {
155
            $this->notifications->add($notification);
156
        }
157
    }
158
159
    public function getPasswordNeedToBeChanged(): ?bool
160
    {
161
        return $this->passwordNeedToBeChanged;
162
    }
163
164
    public function setPasswordNeedToBeChanged($passwordNeedToBeChanged): void
165
    {
166
        $this->passwordNeedToBeChanged = $passwordNeedToBeChanged;
167
    }
168
169
    public function getPasswordResetToken(): ?string
170
    {
171
        return $this->passwordResetToken;
172
    }
173
174
    public function setPasswordResetToken(?string $passwordResetToken): void
175
    {
176
        $this->passwordResetToken = $passwordResetToken;
177
    }
178
}
179