Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
56 / 56
100.00% covered (success)
100.00%
37 / 37
CRAP
100.00% covered (success)
100.00%
1 / 1
User
100.00% covered (success)
100.00%
56 / 56
100.00% covered (success)
100.00%
37 / 37
37
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 __serialize
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 __unserialize
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 __toString
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getUserIdentifier
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getRoles
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getRole
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setRole
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 setIdentifier
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 eraseCredentials
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setRoles
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setName
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getEmail
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setEmail
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getPassword
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getSalt
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getInqCi
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setInqCi
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getInqRuc
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setInqRuc
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getTelefono
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setTelefono
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getTelefono2
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setTelefono2
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getDireccion
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setDireccion
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 addStore
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 removeStore
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getStores
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getGender
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setGender
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getGoogleId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setGoogleId
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 isIsActive
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setIsActive
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Entity;
6
7use App\Repository\UserRepository;
8use App\Type\Gender;
9use Deprecated;
10use Doctrine\Common\Collections\ArrayCollection;
11use Doctrine\Common\Collections\Collection;
12use Doctrine\DBAL\Types\Types;
13use Doctrine\ORM\Mapping\Column;
14use Doctrine\ORM\Mapping\Entity;
15use Doctrine\ORM\Mapping\GeneratedValue;
16use Doctrine\ORM\Mapping\Id;
17use Doctrine\ORM\Mapping\OneToMany;
18use Override;
19use Stringable;
20use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
21use Symfony\Component\Security\Core\User\UserInterface;
22use Symfony\Component\Validator\Constraints\Email;
23use Symfony\Component\Validator\Constraints\NotBlank;
24
25#[UniqueEntity(fields: 'email', message: 'This email address is already in use')]
26#[Entity(repositoryClass: UserRepository::class)]
27class User implements UserInterface, Stringable
28{
29    final public const array ROLES
30        = [
31            'user' => 'ROLE_USER',
32            'cashier' => 'ROLE_CASHIER',
33            'admin' => 'ROLE_ADMIN',
34        ];
35
36    #[Column, Id, GeneratedValue]
37    private ?int $id = 0;
38
39    /**
40     * @var Collection<int, Store> $stores
41     */
42    #[OneToMany(targetEntity: Store::class, mappedBy: 'user')]
43    private Collection $stores;
44
45    #[NotBlank]
46    #[Email(message: "The email '{{ value }}' is not a valid email.")]
47    #[Column(type: Types::STRING, length: 255, unique: true)]
48    private string $email;
49
50    #[NotBlank]
51    #[Column(type: Types::STRING, length: 40)]
52    private ?string $name = null;
53
54    #[Column(type: Types::STRING, length: 50)]
55    private string $role = 'ROLE_USER';
56
57    #[Column(enumType: Gender::class)]
58    private Gender $gender;
59
60    #[NotBlank]
61    #[Column(type: Types::STRING, length: 50, nullable: false)]
62    private string $inqCi = '';
63
64    #[Column(type: Types::STRING, length: 13, nullable: true)]
65    private ?string $inqRuc = '';
66
67    #[Column(type: Types::STRING, length: 25, nullable: true)]
68    private ?string $telefono = '';
69
70    #[Column(type: Types::STRING, length: 25, nullable: true)]
71    private ?string $telefono2 = '';
72
73    #[Column(type: Types::STRING, length: 255, nullable: true)]
74    private ?string $direccion = '';
75
76    #[Column(type: Types::STRING, length: 100, nullable: true)]
77    private string $googleId = '';
78
79    #[Column(nullable: true)]
80    private ?bool $isActive = null;
81
82    public function __construct()
83    {
84        $this->stores = new ArrayCollection();
85    }
86
87    /**
88     * @return array{
89     *     id: integer|null,
90     *     email: string|null
91     * }
92     */
93    public function __serialize(): array
94    {
95        return [
96            'id' => $this->id,
97            'email' => $this->email,
98        ];
99    }
100
101    /**
102     * @param array{
103     *     id: int|null,
104     *     email: string|null
105     * } $data
106     */
107    public function __unserialize(array $data): void
108    {
109        $this->id = $data['id'] ?? null;
110        $this->email = $data['email'] ?? '';
111    }
112
113    #[Override]
114    public function __toString(): string
115    {
116        return (string)$this->name;
117    }
118
119    #[Override]
120    public function getUserIdentifier(): string
121    {
122        assert($this->email !== '');
123
124        return $this->email;
125    }
126
127    /**
128     * @return string[]
129     */
130    #[Override]
131    public function getRoles(): array
132    {
133        return [$this->getRole()];
134    }
135
136    public function getRole(): string
137    {
138        return $this->role;
139    }
140
141    public function setRole(string $role): self
142    {
143        $this->role = $role;
144
145        return $this;
146    }
147
148    public function setIdentifier(string $identifier): self
149    {
150        $this->email = $identifier;
151
152        return $this;
153    }
154
155    #[Deprecated]
156    public function eraseCredentials(): void {}
157
158    /**
159     * @param string[] $roles
160     */
161    public function setRoles(array $roles): self
162    {
163        $this->role = $roles[0];
164
165        return $this;
166    }
167
168    public function getId(): ?int
169    {
170        return $this->id;
171    }
172
173    public function getName(): ?string
174    {
175        return $this->name;
176    }
177
178    public function setName(string $name): self
179    {
180        $this->name = $name;
181
182        return $this;
183    }
184
185    public function getEmail(): string
186    {
187        return $this->email;
188    }
189
190    public function setEmail(string $email): self
191    {
192        $this->email = $email;
193
194        return $this;
195    }
196
197    public function getPassword(): ?string
198    {
199        return null;
200    }
201
202    public function getSalt(): ?string
203    {
204        return null;
205    }
206
207    public function getInqCi(): string
208    {
209        return $this->inqCi;
210    }
211
212    public function setInqCi(string $inqCi): static
213    {
214        $this->inqCi = $inqCi;
215
216        return $this;
217    }
218
219    public function getInqRuc(): ?string
220    {
221        return $this->inqRuc;
222    }
223
224    public function setInqRuc(?string $inqRuc): static
225    {
226        $this->inqRuc = $inqRuc;
227
228        return $this;
229    }
230
231    public function getTelefono(): ?string
232    {
233        return $this->telefono;
234    }
235
236    public function setTelefono(?string $telefono): static
237    {
238        $this->telefono = $telefono;
239
240        return $this;
241    }
242
243    public function getTelefono2(): ?string
244    {
245        return $this->telefono2;
246    }
247
248    public function setTelefono2(?string $telefono2): static
249    {
250        $this->telefono2 = $telefono2;
251
252        return $this;
253    }
254
255    public function getDireccion(): ?string
256    {
257        return $this->direccion;
258    }
259
260    public function setDireccion(?string $direccion): static
261    {
262        $this->direccion = $direccion;
263
264        return $this;
265    }
266
267    public function addStore(Store $store): static
268    {
269        $this->stores->add($store);
270
271        return $this;
272    }
273
274    public function removeStore(Store $store): static
275    {
276        $this->stores->removeElement($store);
277
278        return $this;
279    }
280
281    /**
282     * @return Collection<int, Store>
283     */
284    public function getStores(): Collection
285    {
286        return $this->stores;
287    }
288
289    public function getGender(): Gender
290    {
291        return $this->gender;
292    }
293
294    public function setGender(Gender $gender): static
295    {
296        $this->gender = $gender;
297
298        return $this;
299    }
300
301    public function getGoogleId(): string
302    {
303        return $this->googleId;
304    }
305
306    public function setGoogleId(string $googleId): self
307    {
308        $this->googleId = $googleId;
309
310        return $this;
311    }
312
313    public function isIsActive(): ?bool
314    {
315        return $this->isActive;
316    }
317
318    public function setIsActive(bool $isActive): self
319    {
320        $this->isActive = $isActive;
321
322        return $this;
323    }
324}