Completed
Pull Request — dev (#18)
by
unknown
26:42
created

User::getEmail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace AppBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
7
use Knp\DoctrineBehaviors\Model as ORMBehaviors;
8
use Doctrine\Common\Collections\ArrayCollection;
9
use Symfony\Component\Validator\Constraints as Assert;
10
11
/**
12
 * User.
13
 *
14
 * @ORM\Entity(repositoryClass="AppBundle\Repository\UserRepository")
15
 */
16
class User implements AdvancedUserInterface, \Serializable
17
{
18
    use ORMBehaviors\Timestampable\Timestampable;
19
    /**
20
     * @var int
21
     *
22
     * @ORM\Column(type="integer")
23
     * @ORM\Id
24
     * @ORM\GeneratedValue(strategy="AUTO")
25
     */
26
    private $id;
27
28
    /**
29
     * @var string
30
     * @Assert\NotBlank()
31
     * @Assert\Type("string")
32
     * @Assert\Length(
33
     *      min = 2,
34
     *      max = 190
35
     * )
36
     * @ORM\Column(type="string", length=190, unique=true)
37
     */
38
    private $userName;
39
40
    /**
41
     * @var string
42
     * @Assert\NotBlank()
43
     * @Assert\Regex(
44
     *     pattern="/\d/",
45
     *     match=false,
46
     *     message="Your name cannot contain a number"
47
     * )
48
     * @Assert\Type("string")
49
     * @Assert\Length(
50
     *      min = 2,
51
     *      max = 190
52
     * )
53
     * @ORM\Column(type="string", length=190)
54
     */
55
    private $firstName;
56
57
    /**
58
     * @var string
59
     * @Assert\Regex(
60
     *     pattern="/\d/",
61
     *     match=false,
62
     *     message="Your lastname cannot contain a number"
63
     * )
64
     * @Assert\Type("string")
65
     * @Assert\Length(
66
     *      max = 190
67
     * )
68
     * @ORM\Column(type="string", length=190, nullable=true)
69
     */
70
    private $lastName;
71
72
    /**
73
     * @var string
74
     * @Assert\Image()
75
     * @ORM\Column(type="string", nullable=true)
76
     */
77
    private $image;
78
79
    /**
80
     * @var string
81
     * @Assert\Email(
82
     *     checkMX = true
83
     * )
84
     * @Assert\Type("string")
85
     * @Assert\Length(
86
     *      max = 250
87
     * )
88
     * @ORM\Column(type="string", length=250, unique=true)
89
     */
90
    private $email;
91
92
    /**
93
     * @var string
94
     * @Assert\NotBlank()
95
     * @Assert\Type("string")
96
     * @Assert\Length(
97
     *      max = 255
98
     * )
99
     * @ORM\Column(type="string", length=255)
100
     */
101
    private $password;
102
103
    /**
104
     * @var string
105
     */
106
    private $plainPassword;
107
108
    /**
109
     * @ORM\Column(type="boolean")
110
     */
111
    private $isActive = true;
112
113
    /**
114
     * @var
115
     * @ORM\Column(type="json_array")
116
     */
117
    protected $roles;
118
119
    /**
120
     * @var string
121
     *
122
     * @ORM\Column(type="string", unique=true, nullable=true)
123
     */
124
    private $apiToken;
125
126
    /**
127
     * @var ArrayCollection|Event[]
128
     * @ORM\ManyToMany(targetEntity="Event", inversedBy="users")
129
     */
130
    private $events;
131
132
    /**
133
     * @var ArrayCollection|FormRequest[]
134
     * @ORM\OneToMany(targetEntity="FormRequest", mappedBy="user")
135
     */
136
    private $formRequests;
137
138
    /**
139
     * @var ArrayCollection|Survey[]
140
     * @ORM\OneToMany(targetEntity="Survey", mappedBy="user")
141
     */
142
    private $surveys;
143
144
    /**
145
     * @var ArrayCollection|SurveyAnswer[]
146
     * @ORM\OneToMany(targetEntity="SurveyAnswer", mappedBy="user")
147
     */
148
    private $answers;
149
150
    public function __construct()
151
    {
152
        $this->events = new ArrayCollection();
153
        $this->formRequests = new ArrayCollection();
154
        $this->surveys = new ArrayCollection();
155
        $this->answers = new ArrayCollection();
156
        $this->roles = array('ROLE_USER');
157
    }
158
159
    /**
160
     * Get id.
161
     *
162
     * @return int
163
     */
164
    public function getId()
165
    {
166
        return $this->id;
167
    }
168
169
    /**
170
     * Set username.
171
     *
172
     * @param string $name
173
     *
174
     * @return User
175
     */
176
    public function setUsername($name)
177
    {
178
        $this->userName = $name;
179
180
        return $this;
181
    }
182
183
    /**
184
     * Get name.
185
     *
186
     * @return string
187
     */
188
    public function getUsername()
189
    {
190
        return $this->userName;
191
    }
192
193
    /**
194
     * Set firstname.
195
     *
196
     * @param string $name
197
     *
198
     * @return User
199
     */
200
    public function setFirstName($name)
201
    {
202
        $this->firstName = $name;
203
204
        return $this;
205
    }
206
207
    /**
208
     * Get first name.
209
     *
210
     * @return string
211
     */
212
    public function getFirstName()
213
    {
214
        return $this->firstName;
215
    }
216
217
    /**
218
     * Set lastName.
219
     *
220
     * @param string $lastName
221
     *
222
     * @return User
223
     */
224
    public function setLastName($lastName)
225
    {
226
        $this->lastName = $lastName;
227
228
        return $this;
229
    }
230
231
    /**
232
     * Get lastName.
233
     *
234
     * @return string
235
     */
236
    public function getLastName()
237
    {
238
        return $this->lastName;
239
    }
240
241
    /**
242
     * Set image.
243
     *
244
     * @param string $image
245
     *
246
     * @return User
247
     */
248
    public function setImage($image)
249
    {
250
        $this->image = $image;
251
252
        return $this;
253
    }
254
255
    /**
256
     * Get image.
257
     *
258
     * @return string
259
     */
260
    public function getImage()
261
    {
262
        return $this->image;
263
    }
264
265
    /**
266
     * Set email.
267
     *
268
     * @param string $email
269
     *
270
     * @return User
271
     */
272
    public function setEmail($email)
273
    {
274
        $this->email = $email;
275
276
        return $this;
277
    }
278
279
    /**
280
     * Get email.
281
     *
282
     * @return string
283
     */
284
    public function getEmail()
285
    {
286
        return $this->email;
287
    }
288
289
    /**
290
     * Set password.
291
     *
292
     * @param string $password
293
     *
294
     * @return User
295
     */
296
    public function setPassword($password)
297
    {
298
        $this->password = $password;
299
300
        return $this;
301
    }
302
303
    /**
304
     * Get password.
305
     *
306
     * @return string
307
     */
308
    public function getPassword()
309
    {
310
        return $this->password;
311
    }
312
313
    /**
314
     * @return string
315
     */
316
    public function getPlainPassword()
317
    {
318
        return $this->plainPassword;
319
    }
320
321
    /**
322
     * @param string $plainPassword
323
     */
324
    public function setPlainPassword($plainPassword)
325
    {
326
        $this->plainPassword = $plainPassword;
327
    }
328
329
    /**
330
     * @param bool $status
331
     *
332
     * @return $this
333
     */
334
    public function setIsEnabled($status)
335
    {
336
        $this->isActive = $status;
337
338
        return $this;
339
    }
340
341
    /**
342
     * @return bool
343
     */
344
    public function isEnabled()
345
    {
346
        return $this->isActive;
347
    }
348
349
    /**
350
     * @param mixed $roles
351
     */
352
    public function setRoles($roles)
353
    {
354
        $this->roles = $roles;
355
    }
356
357
    /**
358
     * @return mixed
359
     */
360
    public function getRoles()
361
    {
362
        return $this->roles;
363
    }
364
365
    /**
366
     * Set api token.
367
     *
368
     * @param string $apiToken
369
     *
370
     * @return User
371
     */
372
    public function setApiToken($apiToken)
373
    {
374
        $this->apiToken = $apiToken;
375
376
        return $this;
377
    }
378
379
    /**
380
     * @return string
381
     */
382
    public function getApiToken()
383
    {
384
        return $this->apiToken;
385
    }
386
387
    /**
388
     * @param Event $event
389
     *
390
     * @return User
391
     */
392
    public function setEvent($event)
393
    {
394
        if (!$this->events->contains($event)) {
395
            $this->events->add($event);
396
            $event->setUsers($this);
397
        }
398
399
        return $this;
400
    }
401
402
    /**
403
     * @return ArrayCollection
404
     */
405
    public function getEvents()
406
    {
407
        return $this->events;
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->events; of type Doctrine\Common\Collecti...ppBundle\Entity\Event[] adds the type AppBundle\Entity\Event[] to the return on line 407 which is incompatible with the return type documented by AppBundle\Entity\User::getEvents of type Doctrine\Common\Collections\ArrayCollection.
Loading history...
408
    }
409
410
    /**
411
     * @return ArrayCollection
412
     */
413
    public function getFormRequests()
414
    {
415
        return $this->formRequests;
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->formRequests; of type Doctrine\Common\Collecti...le\Entity\FormRequest[] adds the type AppBundle\Entity\FormRequest[] to the return on line 415 which is incompatible with the return type documented by AppBundle\Entity\User::getFormRequests of type Doctrine\Common\Collections\ArrayCollection.
Loading history...
416
    }
417
418
    /**
419
     * @return ArrayCollection
420
     */
421
    public function getSurveys()
422
    {
423
        return $this->surveys;
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->surveys; of type Doctrine\Common\Collecti...pBundle\Entity\Survey[] adds the type AppBundle\Entity\Survey[] to the return on line 423 which is incompatible with the return type documented by AppBundle\Entity\User::getSurveys of type Doctrine\Common\Collections\ArrayCollection.
Loading history...
424
    }
425
    /**
426
     * @return ArrayCollection
427
     */
428
    public function getAnswers()
429
    {
430
        return $this->answers;
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->answers; of type Doctrine\Common\Collecti...e\Entity\SurveyAnswer[] adds the type AppBundle\Entity\SurveyAnswer[] to the return on line 430 which is incompatible with the return type documented by AppBundle\Entity\User::getAnswers of type Doctrine\Common\Collections\ArrayCollection.
Loading history...
431
    }
432
433
    public function isAccountNonExpired()
434
    {
435
        return true;
436
    }
437
438
    public function isAccountNonLocked()
439
    {
440
        return true;
441
    }
442
443
    public function isCredentialsNonExpired()
444
    {
445
        return true;
446
    }
447
448
    public function getSalt()
449
    {
450
        // TODO: Implement getSalt() method.
451
    }
452
453
    public function eraseCredentials()
454
    {
455
        $this->setPlainPassword(null);
456
    }
457
458
    /** @see \Serializable::serialize() */
459
    public function serialize()
460
    {
461
        return serialize(array(
462
            $this->id,
463
            $this->userName,
464
            $this->email,
465
            $this->isActive,
466
        ));
467
    }
468
469
    /** @see \Serializable::unserialize() */
470
    public function unserialize($serialized)
471
    {
472
        list(
473
            $this->id,
474
            $this->userName,
475
            $this->email,
476
            $this->isActive) = unserialize($serialized);
477
    }
478
}
479