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