Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
3.12% covered (danger)
3.12%
2 / 64
2.63% covered (danger)
2.63%
1 / 38
CRAP
0.00% covered (danger)
0.00%
0 / 1
User
3.12% covered (danger)
3.12%
2 / 64
2.63% covered (danger)
2.63%
1 / 38
1724.02
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 __toString
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getUsername
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setUsername
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getUserIdentifier
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getRoles
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 setRoles
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getPassword
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setPassword
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getEmail
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setEmail
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getFirstName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setFirstName
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getLastName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setLastName
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getProjects
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 addProject
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 removeProject
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 getAvatar
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setAvatar
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getPages
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 addPage
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 removePage
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
12
 getCreatedAt
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setCreatedAt
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getModifiedAt
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setModifiedAt
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getAvatarUri
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 onPrePersist
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 onPreUpdate
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 isVerified
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setIsVerified
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getAgreedTermsAt
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 agreeTerms
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 eraseCredentials
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getTmpAvatar
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setTmpAvatar
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace App\Entity;
4
5use App\Repository\UserRepository;
6use DateTime;
7use DateTimeImmutable;
8use Doctrine\Common\Collections\ArrayCollection;
9use Doctrine\Common\Collections\Collection;
10use Doctrine\ORM\Mapping as ORM;
11use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
12use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
13use Symfony\Component\Security\Core\User\UserInterface;
14use Symfony\Component\Validator\Constraints as Assert;
15
16#[ORM\Entity(repositoryClass: UserRepository::class), ORM\HasLifecycleCallbacks]
17#[UniqueEntity(fields: ['username', 'email'], message: 'There is already an account with this username or email.')]
18class User implements UserInterface, PasswordAuthenticatedUserInterface
19{
20    #[ORM\Id]
21    #[ORM\GeneratedValue]
22    #[ORM\Column(type: 'integer')]
23    private int $id;
24
25    #[ORM\Column(type: 'string', length: 180, unique: true, nullable: false)]
26    private string $username;
27
28    #[ORM\Column(type: 'json')]
29    private array $roles = [];
30
31    #[ORM\Column(type: 'string', nullable: false)]
32    private string $password;
33
34    #[ORM\Column(type: 'string', length: 255, nullable: false)]
35    #[Assert\Email(
36        message: 'The eMail {{ value }} is not a valid eMail.'
37    )]
38    private string $email;
39
40    #[ORM\Column(type: 'string', length: 255, nullable: true)]
41    private ?string $firstName = '';
42
43    #[ORM\Column(type: 'string', length: 255, nullable: true)]
44    private ?string $lastName = '';
45
46    #[ORM\ManyToMany(targetEntity: Projects::class, mappedBy: 'developer')]
47    private Collection $projects;
48
49    #[ORM\Column(type: 'string', length: 255, nullable: true)]
50    private ?string $avatar;
51
52    #[ORM\OneToMany(mappedBy: 'owner', targetEntity: Pages::class)]
53    private Collection $pages;
54
55    #[ORM\Column(type: 'datetime_immutable')]
56    private DateTimeImmutable $createdAt;
57
58    #[ORM\Column(type: 'datetime_immutable', nullable: true)]
59    private DateTimeImmutable $modifiedAt;
60
61    #[ORM\Column(type: 'boolean')]
62    private bool $isVerified = false;
63
64    #[ORM\Column]
65    private ?DateTimeImmutable $agreedTermsAt = null;
66
67    #[ORM\Column(length: 255, nullable: true)]
68    private ?string $tmpAvatar = null;
69
70    public function __construct()
71    {
72        $this->projects = new ArrayCollection();
73        $this->pages = new ArrayCollection();
74    }
75
76    public function __toString(): string
77    {
78        return $this->username;
79    }
80
81    public function getId(): ?int
82    {
83        return $this->id;
84    }
85
86    public function getUsername(): ?string
87    {
88        return $this->username;
89    }
90
91    public function setUsername(string $username): self
92    {
93        $this->username = $username;
94
95        return $this;
96    }
97
98    /**
99     * A visual identifier that represents this user.
100     *
101     * @see UserInterface
102     */
103    public function getUserIdentifier(): string
104    {
105        return $this->username;
106    }
107
108    /**
109     * @see UserInterface
110     */
111    public function getRoles(): array
112    {
113        $roles = $this->roles;
114        // guarantee every user at least has ROLE_USER
115        $roles[] = 'ROLE_USER';
116
117        return array_unique(array: $roles);
118    }
119
120    public function setRoles(array $roles): self
121    {
122        $this->roles = $roles;
123
124        return $this;
125    }
126
127    /**
128     * @see PasswordAuthenticatedUserInterface
129     */
130    public function getPassword(): string
131    {
132        return $this->password;
133    }
134
135    public function setPassword(string $password): self
136    {
137        $this->password = $password;
138
139        return $this;
140    }
141
142
143    public function getEmail(): ?string
144    {
145        return $this->email;
146    }
147
148    public function setEmail(string $email): self
149    {
150        $this->email = $email;
151
152        return $this;
153    }
154
155
156    public function getFirstName(): ?string
157    {
158        return $this->firstName;
159    }
160
161    public function setFirstName(?string $firstName): self
162    {
163        $this->firstName = $firstName;
164
165        return $this;
166    }
167
168    public function getLastName(): ?string
169    {
170        return $this->lastName;
171    }
172
173    public function setLastName(?string $lastName): self
174    {
175        $this->lastName = $lastName;
176
177        return $this;
178    }
179
180    /**
181     * @return Collection<int, Projects>
182     */
183    public function getProjects(): Collection
184    {
185        return $this->projects;
186    }
187
188    public function addProject(Projects $project): self
189    {
190        if (!$this->projects->contains(element: $project)) {
191            $this->projects[] = $project;
192            $project->addDeveloper(developer: $this);
193        }
194
195        return $this;
196    }
197
198    public function removeProject(Projects $project): self
199    {
200        if ($this->projects->removeElement(element: $project)) {
201            $project->removeDeveloper(developer: $this);
202        }
203
204        return $this;
205    }
206
207    public function getAvatar(): string
208    {
209        return $this->avatar ?? '';
210    }
211
212    public function setAvatar(?string $avatar): self
213    {
214        $this->avatar = $avatar;
215
216        return $this;
217    }
218
219    /**
220     * @return Collection<int, Pages>
221     */
222    public function getPages(): Collection
223    {
224        return $this->pages;
225    }
226
227    public function addPage(Pages $page): self
228    {
229        if (!$this->pages->contains(element: $page)) {
230            $this->pages[] = $page;
231            $page->setOwner(owner: $this);
232        }
233
234        return $this;
235    }
236
237    public function removePage(Pages $page): self
238    {
239        if ($this->pages->removeElement(element: $page)) {
240            // set the owning side to null (unless already changed)
241            if ($page->getOwner() === $this) {
242                $page->setOwner(owner: null);
243            }
244        }
245
246        return $this;
247    }
248
249    public function getCreatedAt(): ?DateTimeImmutable
250    {
251        return $this->createdAt;
252    }
253
254    public function setCreatedAt(DateTimeImmutable $createdAt): self
255    {
256        $this->createdAt = $createdAt;
257
258        return $this;
259    }
260
261    public function getModifiedAt(): ?DateTimeImmutable
262    {
263        return $this->modifiedAt;
264    }
265
266    public function setModifiedAt(?DateTimeImmutable $modifiedAt): self
267    {
268        $this->modifiedAt = $modifiedAt;
269
270        return $this;
271    }
272
273    /**
274     * @return string
275     */
276    public function getAvatarUri(): string
277    {
278        return 'avatar';
279    }
280
281    #[ORM\PrePersist]
282    public function onPrePersist(): void
283    {
284        $this->createdAt = new DateTimeImmutable(datetime: 'now');
285    }
286
287    #[ORM\PreUpdate]
288    public function onPreUpdate(): void
289    {
290        $this->modifiedAt = new DateTimeImmutable(datetime: 'now');
291    }
292
293    public function isVerified(): bool
294    {
295        return $this->isVerified;
296    }
297
298    public function setIsVerified(bool $isVerified): self
299    {
300        $this->isVerified = $isVerified;
301
302        return $this;
303    }
304
305    public function getAgreedTermsAt(): ?DateTimeImmutable
306    {
307        return $this->agreedTermsAt;
308    }
309
310    public function agreeTerms(): self
311    {
312        $this->agreedTermsAt = new DateTimeImmutable();
313
314        return $this;
315    }
316
317    public function eraseCredentials()
318    {
319        // TODO: Implement eraseCredentials() method.
320    }
321
322    public function getTmpAvatar(): ?string
323    {
324        return $this->tmpAvatar;
325    }
326
327    public function setTmpAvatar(?string $tmpAvatar): self
328    {
329        $this->tmpAvatar = $tmpAvatar;
330
331        return $this;
332    }
333}