]> Raphaël G. Git Repositories - airbundle/blob - Entity/User.php
Add mail id and ip to user entity
[airbundle] / Entity / User.php
1 <?php declare(strict_types=1);
2
3 /*
4 * This file is part of the Rapsys AirBundle package.
5 *
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Rapsys\AirBundle\Entity;
13
14 use Doctrine\Common\Collections\Collection;
15 use Doctrine\Common\Collections\ArrayCollection;
16
17 use Rapsys\UserBundle\Entity\Civility;
18 use Rapsys\UserBundle\Entity\User as BaseUser;
19
20 /**
21 * {@inheritdoc}
22 */
23 class User extends BaseUser {
24 /**
25 * City
26 */
27 private ?string $city = null;
28
29 /**
30 * Country
31 */
32 private ?Country $country = null;
33
34 /**
35 * Phone
36 */
37 private ?string $phone = null;
38
39 /**
40 * Pseudonym
41 */
42 private ?string $pseudonym = null;
43
44 /**
45 * Zipcode
46 */
47 private ?string $zipcode = null;
48
49 /**
50 * Mail id
51 */
52 private ?string $mid = null;
53
54 /**
55 * Mail ip
56 */
57 private ?string $mip = null;
58
59 /**
60 * Applications collection
61 */
62 private Collection $applications;
63
64 /**
65 * Dances collection
66 */
67 private Collection $dances;
68
69 /**
70 * Locations collection
71 */
72 private Collection $locations;
73
74 /**
75 * Snippets collection
76 */
77 private Collection $snippets;
78
79 /**
80 * Subscribers collection
81 */
82 private Collection $subscribers;
83
84 /**
85 * Subscriptions collection
86 */
87 private Collection $subscriptions;
88
89 /**
90 * Google tokens collection
91 */
92 private Collection $googleTokens;
93
94 /**
95 * Constructor
96 *
97 * @param string $mail The user mail
98 * @param string $password The user password
99 * @param ?Civility $civility The user civility
100 * @param ?string $forename The user forename
101 * @param ?string $surname The user surname
102 * @param bool $active The user active
103 * @param bool $enable The user enable
104 */
105 public function __construct(protected string $mail, protected string $password, protected ?Civility $civility = null, protected ?string $forename = null, protected ?string $surname = null, protected bool $active = false, protected bool $enable = true) {
106 //Call parent constructor
107 parent::__construct($this->mail, $this->password, $this->civility, $this->forename, $this->surname, $this->active, $this->enable);
108
109 //Set collections
110 $this->applications = new ArrayCollection();
111 $this->dances = new ArrayCollection();
112 $this->locations = new ArrayCollection();
113 $this->snippets = new ArrayCollection();
114 $this->subscribers = new ArrayCollection();
115 $this->subscriptions = new ArrayCollection();
116 $this->googleTokens = new ArrayCollection();
117 }
118
119 /**
120 * Set city
121 *
122 * @param string $city
123 *
124 * @return User
125 */
126 public function setCity(?string $city): User {
127 $this->city = $city;
128
129 return $this;
130 }
131
132 /**
133 * Get city
134 *
135 * @return string
136 */
137 public function getCity(): ?string {
138 return $this->city;
139 }
140
141 /**
142 * Set country
143 *
144 * @param Country $country
145 *
146 * @return User
147 */
148 public function setCountry(?Country $country): User {
149 $this->country = $country;
150
151 return $this;
152 }
153
154 /**
155 * Get country
156 *
157 * @return Country
158 */
159 public function getCountry(): ?Country {
160 return $this->country;
161 }
162
163 /**
164 * Set phone
165 *
166 * @param string $phone
167 *
168 * @return User
169 */
170 public function setPhone(?string $phone): User {
171 $this->phone = $phone;
172
173 return $this;
174 }
175
176 /**
177 * Get phone
178 *
179 * @return string
180 */
181 public function getPhone(): ?string {
182 return $this->phone;
183 }
184
185 /**
186 * Set pseudonym
187 *
188 * @param string $pseudonym
189 *
190 * @return User
191 */
192 public function setPseudonym(?string $pseudonym): User {
193 $this->pseudonym = $pseudonym;
194
195 return $this;
196 }
197
198 /**
199 * Get pseudonym
200 *
201 * @return string
202 */
203 public function getPseudonym(): ?string {
204 return $this->pseudonym;
205 }
206
207 /**
208 * Set zipcode
209 *
210 * @param string $zipcode
211 *
212 * @return User
213 */
214 public function setZipcode(?string $zipcode): User {
215 $this->zipcode = $zipcode;
216
217 return $this;
218 }
219
220 /**
221 * Get zipcode
222 *
223 * @return string
224 */
225 public function getZipcode(): ?string {
226 return $this->zipcode;
227 }
228
229 /**
230 * Set mail id
231 *
232 * @param string $mid
233 *
234 * @return User
235 */
236 public function setMid(?string $mid): User {
237 $this->mid = $mid;
238
239 return $this;
240 }
241
242 /**
243 * Get mail id
244 *
245 * @return string
246 */
247 public function getMid(): ?string {
248 return $this->mid;
249 }
250
251 /**
252 * Set mail ip
253 *
254 * @param string $mip
255 *
256 * @return User
257 */
258 public function setMip(?string $mip): User {
259 $this->mip = $mip;
260
261 return $this;
262 }
263
264 /**
265 * Get mail ip
266 *
267 * @return string
268 */
269 public function getMip(): ?string {
270 return $this->mip;
271 }
272
273 /**
274 * Add application
275 *
276 * @param Application $application
277 *
278 * @return User
279 */
280 public function addApplication(Application $application): User {
281 $this->applications[] = $application;
282
283 return $this;
284 }
285
286 /**
287 * Remove application
288 *
289 * @param Application $application
290 */
291 public function removeApplication(Application $application): bool {
292 return $this->applications->removeElement($application);
293 }
294
295 /**
296 * Get applications
297 *
298 * @return \Doctrine\Common\Collections\Collection
299 */
300 public function getApplications(): Collection {
301 return $this->applications;
302 }
303
304 /**
305 * Add dance
306 *
307 * @param Dance $dance
308 *
309 * @return User
310 */
311 public function addDance(Dance $dance): User {
312 $this->dances[] = $dance;
313
314 return $this;
315 }
316
317 /**
318 * Remove dance
319 *
320 * @param Dance $dance
321 *
322 * @return bool
323 */
324 public function removeDance(Dance $dance): bool {
325 return $this->dances->removeElement($dance);
326 }
327
328 /**
329 * Get dances
330 *
331 * @return \Doctrine\Common\Collections\Collection
332 */
333 public function getDances(): Collection {
334 return $this->dances;
335 }
336
337 /**
338 * Add location
339 *
340 * @param Location $location
341 *
342 * @return User
343 */
344 public function addLocation(Location $location): User {
345 $this->locations[] = $location;
346
347 return $this;
348 }
349
350 /**
351 * Remove location
352 *
353 * @param Location $location
354 */
355 public function removeLocation(Location $location): bool {
356 return $this->locations->removeElement($location);
357 }
358
359 /**
360 * Get locations
361 *
362 * @return \Doctrine\Common\Collections\Collection
363 */
364 public function getLocations(): Collection {
365 return $this->locations;
366 }
367
368 /**
369 * Add snippet
370 *
371 * @param Snippet $snippet
372 *
373 * @return User
374 */
375 public function addSnippet(Snippet $snippet): User {
376 $this->snippets[] = $snippet;
377
378 return $this;
379 }
380
381 /**
382 * Remove snippet
383 *
384 * @param Snippet $snippet
385 */
386 public function removeSnippet(Snippet $snippet): bool {
387 return $this->snippets->removeElement($snippet);
388 }
389
390 /**
391 * Get snippets
392 *
393 * @return \Doctrine\Common\Collections\Collection
394 */
395 public function getSnippets(): Collection {
396 return $this->snippets;
397 }
398
399 /**
400 * Add subscriber
401 *
402 * @param User $subscriber
403 *
404 * @return User
405 */
406 public function addSubscriber(User $subscriber): User {
407 //Add from owning side
408 $subscriber->addSubscription($this);
409
410 $this->subscribers[] = $subscriber;
411
412 return $this;
413 }
414
415 /**
416 * Remove subscriber
417 *
418 * @param User $subscriber
419 */
420 public function removeSubscriber(User $subscriber): bool {
421 if (!$this->subscriptions->contains($subscriber)) {
422 return true;
423 }
424
425 //Remove from owning side
426 $subscriber->removeSubscription($this);
427
428 return $this->subscribers->removeElement($subscriber);
429 }
430
431 /**
432 * Get subscribers
433 *
434 * @return \Doctrine\Common\Collections\Collection
435 */
436 public function getSubscribers(): Collection {
437 return $this->subscribers;
438 }
439
440 /**
441 * Add subscription
442 *
443 * @param User $subscription
444 *
445 * @return User
446 */
447 public function addSubscription(User $subscription): User {
448 $this->subscriptions[] = $subscription;
449
450 return $this;
451 }
452
453 /**
454 * Remove subscription
455 *
456 * @param User $subscription
457 */
458 public function removeSubscription(User $subscription): bool {
459 return $this->subscriptions->removeElement($subscription);
460 }
461
462 /**
463 * Get subscriptions
464 *
465 * @return \Doctrine\Common\Collections\Collection
466 */
467 public function getSubscriptions(): Collection {
468 return $this->subscriptions;
469 }
470
471 /**
472 * Add google token
473 *
474 * @param GoogleToken $googleToken
475 *
476 * @return User
477 */
478 public function addGoogleToken(GoogleToken $googleToken): User {
479 $this->googleTokens[] = $googleToken;
480
481 return $this;
482 }
483
484 /**
485 * Remove google token
486 *
487 * @param GoogleToken $googleToken
488 */
489 public function removeGoogleToken(GoogleToken $googleToken): bool {
490 return $this->googleTokens->removeElement($googleToken);
491 }
492
493 /**
494 * Get googleTokens
495 *
496 * @return \Doctrine\Common\Collections\Collection
497 */
498 public function getGoogleTokens(): Collection {
499 return $this->googleTokens;
500 }
501 }