Test Failed
Push — issue#666 ( f5ce0d...ce3976 )
by Guilherme
28:08
created

Person::getPasswordEncoderName()   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
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the login-cidadao project or it's bundles.
4
 *
5
 * (c) Guilherme Donato <guilhermednt on github>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace LoginCidadao\CoreBundle\Entity;
12
13
use Doctrine\ORM\Mapping as ORM;
14
use Doctrine\Common\Collections\ArrayCollection;
15
use Doctrine\Common\Collections\Collection;
16
use libphonenumber\PhoneNumber;
17
use Symfony\Component\HttpFoundation\File\File;
18
use Symfony\Component\Validator\Constraints as Assert;
19
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
20
use Scheb\TwoFactorBundle\Model\BackupCodeInterface;
21
use Vich\UploaderBundle\Mapping\Annotation as Vich;
22
use JMS\Serializer\Annotation as JMS;
23
use FOS\UserBundle\Model\User as BaseUser;
24
use LoginCidadao\OAuthBundle\Entity\Client;
25
use LoginCidadao\CoreBundle\Model\LocationSelectData;
26
use LoginCidadao\CoreBundle\Model\PersonInterface;
27
use LoginCidadao\OAuthBundle\Model\ClientInterface;
28
use LoginCidadao\ValidationBundle\Validator\Constraints as LCAssert;
29
use Donato\PathWellBundle\Validator\Constraints\PathWell;
30
use Misd\PhoneNumberBundle\Validator\Constraints\PhoneNumber as AssertPhoneNumber;
31
use Rollerworks\Bundle\PasswordStrengthBundle\Validator\Constraints as RollerworksPassword;
32
33
/**
34
 * @ORM\Entity(repositoryClass="LoginCidadao\CoreBundle\Entity\PersonRepository")
35
 * @ORM\Table(name="person")
36
 * @UniqueEntity("cpf", message="person.validation.cpf.already_used", groups={"LoginCidadaoRegistration", "Registration", "Profile", "LoginCidadaoProfile", "Dynamic", "Documents"})
37
 * @UniqueEntity("username")
38
 * @UniqueEntity(fields="emailCanonical", errorPath="email", message="fos_user.email.already_used", groups={"LoginCidadaoRegistration", "Registration", "LoginCidadaoEmailForm", "LoginCidadaoProfile", "Dynamic"})
39
 * @ORM\HasLifecycleCallbacks
40
 * @JMS\ExclusionPolicy("all")
41
 * @Vich\Uploadable
42
 */
43
class Person extends BaseUser implements PersonInterface, BackupCodeInterface
44
{
45
    /**
46
     * @ORM\Id
47
     * @ORM\Column(type="integer")
48
     * @ORM\GeneratedValue(strategy="AUTO")
49
     * @JMS\Since("1.0")
50
     */
51
    protected $id;
52
53
    /**
54
     * @JMS\Expose
55
     * @JMS\Groups({"first_name","full_name","public_profile","given_name","name"})
56
     * @ORM\Column(type="string", nullable=true)
57
     * @Assert\NotBlank(message="Please enter your name.", groups={"Profile", "LoginCidadaoProfile"})
58
     * @Assert\Length(
59
     *     min=3,
60
     *     max="255",
61
     *     minMessage="The name is too short.",
62
     *     maxMessage="The name is too long.",
63
     *     groups={"Registration", "Profile", "LoginCidadaoProfile"}
64
     * )
65
     * @JMS\Since("1.0")
66
     */
67
    protected $firstName;
68
69
    /**
70
     * @JMS\Expose
71
     * @JMS\Groups({"last_name","full_name","family_name","middle_name","name"})
72
     * @ORM\Column(type="string", nullable=true)
73
     * @Assert\NotBlank(message="Please enter your surname.", groups={"Profile", "LoginCidadaoProfile"})
74
     * @Assert\Length(
75
     *     min=1,
76
     *     max="255",
77
     *     minMessage="The surname is too short.",
78
     *     maxMessage="The surname is too long.",
79
     *     groups={"Registration", "Profile", "LoginCidadaoProfile"}
80
     * )
81
     * @JMS\Since("1.0")
82
     */
83
    protected $surname;
84
85
    /**
86
     * @JMS\Expose
87
     * @JMS\Groups({"username","preferred_username"})
88
     * @Assert\NotBlank
89
     * @Assert\Length(
90
     *     min="1",
91
     *     max="40",
92
     *     groups={"Registration", "Profile", "LoginCidadaoProfile"}
93
     * )
94
     * @JMS\Since("1.0")
95
     */
96
    protected $username;
97
98
    /**
99
     * @JMS\Exclude
100
     * @PathWell(
101
     *     groups={"Registration", "ResetPassword", "ChangePassword", "LoginCidadaoRegistration"}
102
     * )
103
     * @RollerworksPassword\PasswordRequirements(
104
     *     minLength=false,
105
     *     requireLetters=true,
106
     *     requireNumbers=true,
107
     *     missingLettersMessage="person.validation.password.missingLetters",
108
     *     missingNumbersMessage="person.validation.password.missingNumbers",
109
     *     groups={"Registration", "ResetPassword", "ChangePassword", "LoginCidadaoRegistration"}
110
     * )
111
     * @Assert\Length(
112
     *     min=8,
113
     *     max=72,
114
     *     maxMessage="person.validation.password.length.max",
115
     *     minMessage="person.validation.password.length.min",
116
     *     groups={"Registration", "ResetPassword", "ChangePassword", "LoginCidadaoRegistration"}
117
     * )
118
     * @Assert\NotBlank(message="person.validation.password.not_blank", groups={"Registration", "ResetPassword", "ChangePassword", "LoginCidadaoRegistration"})
119
     */
120
    protected $plainPassword;
121
122
    /**
123
     * @JMS\Expose
124
     * @JMS\Groups({"cpf"})
125
     * @ORM\Column(type="string", nullable=true, unique=true)
126
     * @LCAssert\CPF(groups={"Documents", "Dynamic", "LoginCidadaoRegistration"})
127
     * @JMS\Since("1.0")
128
     */
129
    protected $cpf;
130
131
    /**
132
     * @JMS\Expose
133
     * @JMS\Groups({"email"})
134
     * @JMS\Since("1.0")
135
     * @Assert\Email(strict=true, groups={"Profile", "LoginCidadaoProfile", "Registration", "ResetPassword", "ChangePassword", "LoginCidadaoRegistration", "LoginCidadaoEmailForm"})
136
     * @Assert\NotBlank(message="person.validation.email.not_blank", groups={"Profile", "LoginCidadaoProfile", "Registration", "ResetPassword", "ChangePassword", "LoginCidadaoRegistration", "LoginCidadaoEmailForm"})
137
     */
138
    protected $email;
139
140
    /**
141
     * @JMS\Expose
142
     * @JMS\Groups({"birthdate"})
143
     * @ORM\Column(type="date", nullable=true)
144
     * @JMS\Since("1.0")
145
     * @LCAssert\Age(max="150", groups={"Profile", "LoginCidadaoProfile", "Registration", "ResetPassword", "ChangePassword", "LoginCidadaoRegistration", "LoginCidadaoEmailForm"})
146
     */
147
    protected $birthdate;
148
149
    /**
150
     * @ORM\Column(name="email_expiration", type="datetime", nullable=true)
151
     * @JMS\Since("1.0")
152
     */
153
    protected $emailExpiration;
154
155
    /**
156
     * @JMS\Expose
157
     * @JMS\Groups({"mobile","phone_number"})
158
     * @JMS\Type("libphonenumber\PhoneNumber")
159
     * @ORM\Column(type="phone_number", nullable=true)
160
     * @JMS\Since("1.0")
161
     * @LCAssert\E164PhoneNumber(
162
     *     maxMessage="person.validation.mobile.length.max",
163
     *     groups={"Registration", "LoginCidadaoRegistration", "Dynamic", "Profile", "LoginCidadaoProfile"}
164
     * )
165
     * @LCAssert\MobilePhoneNumber(
166
     *     missing9thDigit="person.validation.mobile.9thDigit",
167
     *     groups={"Registration", "LoginCidadaoRegistration", "Dynamic", "Profile", "LoginCidadaoProfile"}
168
     * )
169
     * @AssertPhoneNumber(
170
     *     type="mobile",
171
     *     groups={"Registration", "LoginCidadaoRegistration", "Dynamic", "Profile", "LoginCidadaoProfile"}
172
     * )
173
     */
174
    protected $mobile;
175
176
    /**
177
     * @ORM\Column(type="string", length=255, nullable=true)
178
     * @var string
179
     * @JMS\Since("1.0")
180
     */
181
    protected $twitterPicture;
182
183
    /**
184
     * @JMS\Expose
185
     * @JMS\Groups({"city"})
186
     * @ORM\ManyToOne(targetEntity="LoginCidadao\CoreBundle\Entity\City")
187
     * @ORM\JoinColumn(name="city_id", referencedColumnName="id")
188
     * @JMS\Since("1.0")
189
     */
190
    protected $city;
191
192
    /**
193
     * @var string
194
     *
195
     * @ORM\Column(name="facebookId", type="string", length=255, nullable=true, unique=true)
196
     * @JMS\Since("1.0")
197
     */
198
    protected $facebookId;
199
200
    /**
201
     * @var string
202
     *
203
     * @ORM\Column(name="facebookUsername", type="string", length=255, nullable=true)
204
     * @JMS\Since("1.0")
205
     */
206
    protected $facebookUsername;
207
208
    /**
209
     * @var string
210
     *
211
     * @ORM\Column(name="facebookAccessToken", type="string", length=255, nullable=true)
212
     * @JMS\Since("1.1")
213
     */
214
    protected $facebookAccessToken;
215
216
    /**
217
     * @var string
218
     *
219
     * @ORM\Column(name="twitterId", type="string", length=255, nullable=true, unique=true)
220
     * @JMS\Since("1.0")
221
     */
222
    protected $twitterId;
223
224
    /**
225
     * @var string
226
     *
227
     * @ORM\Column(name="twitterUsername", type="string", length=255, nullable=true)
228
     * @JMS\Since("1.0")
229
     */
230
    protected $twitterUsername;
231
232
    /**
233
     * @var string
234
     *
235
     * @ORM\Column(name="twitterAccessToken", type="string", length=255, nullable=true)
236
     * @JMS\Since("1.0")
237
     */
238
    protected $twitterAccessToken;
239
240
    /**
241
     * @ORM\OneToMany(targetEntity="Authorization", mappedBy="person", cascade={"remove"}, orphanRemoval=true)
242
     */
243
    protected $authorizations;
244
245
    /**
246
     * @ORM\Column(type="datetime", nullable=false)
247
     * @var \DateTime
248
     * @JMS\Since("1.0")
249
     */
250
    protected $createdAt;
251
252
    /**
253
     * @ORM\Column(type="datetime", nullable=true)
254
     * @var \DateTime
255
     * @JMS\Since("1.0")
256
     */
257
    protected $emailConfirmedAt;
258
259
    /**
260
     * @ORM\Column(type="string", length=255, nullable=true)
261
     * @var string
262
     * @JMS\Since("1.0")
263
     */
264
    protected $previousValidEmail;
265
266
    /**
267
     * @ORM\ManyToMany(targetEntity="LoginCidadao\OAuthBundle\Entity\Client", mappedBy="owners")
268
     */
269
    protected $clients;
270
271
    /**
272
     * @ORM\OneToMany(targetEntity="ClientSuggestion", mappedBy="person")
273
     */
274
    protected $suggestions;
275
276
    /**
277
     * @JMS\Expose
278
     * @JMS\Groups({"state"})
279
     * @ORM\ManyToOne(targetEntity="LoginCidadao\CoreBundle\Entity\State")
280
     * @ORM\JoinColumn(name="state_id", referencedColumnName="id")
281
     * @JMS\Since("1.0.2")
282
     */
283
    protected $state;
284
285
    /**
286
     * @JMS\Expose
287
     * @JMS\Groups({"country"})
288
     * @ORM\ManyToOne(targetEntity="LoginCidadao\CoreBundle\Entity\Country")
289
     * @ORM\JoinColumn(name="country_id", referencedColumnName="id")
290
     * @JMS\Since("1.0.2")
291
     */
292
    protected $country;
293
294
    /**
295
     * @Assert\File(
296
     *      maxSize="2M",
297
     *      maxSizeMessage="The maxmimum allowed file size is 2MB.",
298
     *      mimeTypes={"image/png", "image/jpeg", "image/pjpeg"},
299
     *      mimeTypesMessage="Only JPEG and PNG images are allowed."
300
     * )
301
     * @Vich\UploadableField(mapping="user_image", fileNameProperty="imageName")
302
     * @var File $image
303
     * @JMS\Since("1.0.2")
304
     */
305
    protected $image;
306
307
    /**
308
     * @ORM\Column(type="string", length=255, name="image_name", nullable=true)
309
     *
310
     * @var string $imageName
311
     * @JMS\Since("1.0.2")
312
     */
313
    protected $imageName;
314
315
    /**
316
     * @JMS\Expose
317
     * @JMS\Groups({"public_profile","picture"})
318
     * @JMS\Since("1.0.2")
319
     */
320
    protected $profilePictureUrl;
321
322
    /**
323
     * @ORM\Column(type="datetime", nullable=true)
324
     * @JMS\Expose
325
     * @JMS\Groups({"public_profile","updated_at"})
326
     * @var \DateTime $updatedAt
327
     * @JMS\Since("1.0.2")
328
     */
329
    protected $updatedAt;
330
331
    /**
332
     * @var string
333
     *
334
     * @ORM\Column(name="googleId", type="string", length=255, nullable=true, unique=true)
335
     * @JMS\Since("1.0.3")
336
     */
337
    protected $googleId;
338
339
    /**
340
     * @var string
341
     *
342
     * @ORM\Column(name="googleUsername", type="string", length=255, nullable=true)
343
     * @JMS\Since("1.0.3")
344
     */
345
    protected $googleUsername;
346
347
    /**
348
     * @var string
349
     *
350
     * @ORM\Column(name="googleAccessToken", type="string", length=255, nullable=true)
351
     * @JMS\Since("1.0.3")
352
     */
353
    protected $googleAccessToken;
354
355
    /**
356
     * @JMS\Expose
357
     * @JMS\Groups({"id_cards"})
358
     * @ORM\OneToMany(targetEntity="LoginCidadao\CoreBundle\Entity\IdCard", mappedBy="person")
359
     * @JMS\Since("1.0.3")
360
     */
361
    protected $idCards;
362
363
    /**
364
     * @JMS\Expose
365
     * @JMS\Groups({"public_profile"})
366
     * @var array
367
     */
368
    protected $badges = array();
369
370
    /**
371
     * @ORM\OneToMany(targetEntity="LoginCidadao\APIBundle\Entity\LogoutKey", mappedBy="person", cascade={"remove"}, orphanRemoval=true)
372
     */
373
    protected $logoutKeys;
374
375
    /**
376
     * @JMS\Expose
377
     * @JMS\Groups({"addresses","address"})
378
     * @ORM\OneToMany(targetEntity="LoginCidadao\CoreBundle\Entity\PersonAddress", mappedBy="person", cascade={"remove"}, orphanRemoval=true)
379
     */
380
    protected $addresses;
381
382
    /**
383
     * @ORM\Column(name="google_authenticator_secret", type="string", nullable=true)
384
     */
385
    protected $googleAuthenticatorSecret;
386
387
    /**
388
     * @JMS\Expose
389
     * @JMS\Groups({"nationality"})
390
     * @ORM\ManyToOne(targetEntity="LoginCidadao\CoreBundle\Entity\Country")
391
     * @ORM\JoinColumn(name="nationality_id", referencedColumnName="id")
392
     * @JMS\Since("1.0.2")
393
     */
394
    protected $nationality;
395
396
    /**
397
     * @JMS\Exclude
398
     * @ORM\OneToMany(targetEntity="BackupCode", mappedBy="person", cascade={"remove"}, orphanRemoval=true)
399
     */
400
    protected $backupCodes;
401
402
    /**
403
     * @JMS\Exclude
404
     * @ORM\Column(name="password_encoder_name", type="string", length=255, nullable=true)
405
     */
406
    protected $passwordEncoderName;
407
408
    /**
409
     * @JMS\Expose
410
     * @JMS\Groups({"public_profile"})
411
     * @JMS\SerializedName("phone_number_verified")
412
     * @var bool
413
     */
414
    protected $phoneNumberVerified = false;
415
416 20
    public function __construct()
417
    {
418 20
        parent::__construct();
419 20
        $this->authorizations = new ArrayCollection();
420 20
        $this->clients = new ArrayCollection();
421 20
        $this->logoutKeys = new ArrayCollection();
422 20
        $this->addresses = new ArrayCollection();
423 20
        $this->backupCodes = new ArrayCollection();
424 20
    }
425
426
    public function getEmail()
427
    {
428
        return $this->email;
429
    }
430
431
    public function setEmail($email)
432
    {
433
        $this->email = $email;
434
435
        return $this;
436
    }
437
438
    public function getFirstName()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
439
    {
440
        return $this->firstName;
441
    }
442
443
    public function setFirstName($firstName)
444
    {
445
        $this->firstName = $firstName;
446
447
        return $this;
448
    }
449
450
    public function getSurname()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
451
    {
452
        return $this->surname;
453
    }
454
455
    public function setSurname($suname)
456
    {
457
        $this->surname = $suname;
458
459
        return $this;
460
    }
461
462
    public function getBirthdate()
463
    {
464
        return $this->birthdate;
465
    }
466
467
    public function setBirthdate($birthdate)
468
    {
469
        $this->birthdate = $birthdate;
470
471
        return $this;
472
    }
473
474 6
    public function getMobile()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
475
    {
476 6
        return $this->mobile;
477
    }
478
479 5
    public function setMobile($mobile)
480
    {
481 5
        if (!($mobile instanceof PhoneNumber)) {
482 1
            $mobile = preg_replace('/[^0-9+]/', '', $mobile);
483
484
            // PhoneNumberBundle won't work with empty strings.
485
            // See https://github.com/misd-service-development/phone-number-bundle/issues/58
486 1
            if (strlen(trim($mobile)) === 0) {
487 1
                $mobile = null;
488
            }
489
        }
490 5
        $this->mobile = $mobile;
491
492 5
        return $this;
493
    }
494
495
    public function addAuthorization(Authorization $authorization)
496
    {
497
        $this->authorizations->add($authorization);
498
        $authorization->setPerson($this);
499
500
        return $this;
501
    }
502
503
    public function removeAuthorization(Authorization $authorization)
504
    {
505
        if ($this->authorizations->contains($authorization)) {
506
            $this->authorizations->removeElement($authorization);
507
        }
508
509
        return $this;
510
    }
511
512
    /**
513
     * @return Authorization[]
0 ignored issues
show
Documentation introduced by
Should the return type not be array|ArrayCollection? Also, consider making the array more specific, something like array<String>, or String[].

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

If the return type contains the type array, this check recommends the use of a more specific type like String[] or array<String>.

Loading history...
514
     */
515
    public function getAuthorizations($uidToIgnore = null)
516
    {
517
        if ($uidToIgnore !== null) {
518
            return array_filter(
519
                $this->authorizations->toArray(),
520
                function (Authorization $authorization) use ($uidToIgnore) {
521
                    return $authorization->getClient()->getUid() != $uidToIgnore;
522
                }
523
            );
524
        }
525
526
        return $this->authorizations;
527
    }
528
529
    /**
530
     * Checks if a given Client can access this Person's specified scope.
531
     * @param ClientInterface $client
532
     * @param mixed $scope can be a single scope or an array with several.
533
     * @return boolean
534
     */
535
    public function isAuthorizedClient(ClientInterface $client, $scope)
536
    {
537
        $authorizations = $this->getAuthorizations();
538
        foreach ($authorizations as $auth) {
539
            $c = $auth->getClient();
540
            if ($c->getId() == $client->getId()) {
541
                return $auth->hasScopes($scope);
542
            }
543
        }
544
545
        return false;
546
    }
547
548
    /**
549
     * @param Client $client
550
     * @return array
551
     */
552
    public function getClientScope(Client $client)
553
    {
554
        $authorizations = $this->getAuthorizations();
555
        foreach ($authorizations as $auth) {
556
            $c = $auth->getClient();
557
            if ($c->getId() == $client->getId()) {
558
                return $auth->getScope();
559
            }
560
        }
561
562
        return null;
563
    }
564
565
    /**
566
     * Checks if this Person has any authorization for a given Client.
567
     * WARNING: Note that it does NOT validate scope!
568
     * @param \LoginCidadao\OAuthBundle\Entity\Client | integer $client
569
     */
570
    public function hasAuthorization($client)
571
    {
572
        if ($client instanceof ClientInterface) {
573
            $id = $client->getId();
574
        } else {
575
            $id = $client;
576
        }
577
        $authorizations = $this->getAuthorizations();
578
        if (is_array($authorizations) || $authorizations instanceof Collection) {
579
            foreach ($authorizations as $auth) {
580
                $c = $auth->getClient();
581
                if ($c->getId() == $id) {
582
                    return true;
583
                }
584
            }
585
        }
586
587
        return false;
588
    }
589
590
    public function setFacebookId($facebookId)
591
    {
592
        $this->facebookId = $facebookId;
593
594
        return $this;
595
    }
596
597
    public function getFacebookId()
598
    {
599
        return $this->facebookId;
600
    }
601
602
    public function setTwitterId($twitterId)
603
    {
604
        $this->twitterId = $twitterId;
605
606
        return $this;
607
    }
608
609
    public function getTwitterId()
610
    {
611
        return $this->twitterId;
612
    }
613
614
    public function setTwitterUsername($twitterUsername)
615
    {
616
        $this->twitterUsername = $twitterUsername;
617
618
        return $this;
619
    }
620
621
    public function getTwitterUsername()
622
    {
623
        return $this->twitterUsername;
624
    }
625
626
    public function setTwitterAccessToken($twitterAccessToken)
627
    {
628
        $this->twitterAccessToken = $twitterAccessToken;
629
630
        return $this;
631
    }
632
633
    public function getTwitterAccessToken()
634
    {
635
        return $this->twitterAccessToken;
636
    }
637
638
    public function serialize()
639
    {
640
        return serialize(array($this->facebookId, parent::serialize()));
641
    }
642
643
    public function unserialize($data)
644
    {
645
        list($this->facebookId, $parentData) = unserialize($data);
646
        parent::unserialize($parentData);
647
    }
648
649
    /**
650
     * Get the full name of the user (first + last name)
651
     * @JMS\Groups({"full_name", "name"})
652
     * @JMS\VirtualProperty
653
     * @JMS\SerializedName("full_name")
654
     * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
655
     */
656
    public function getFullName()
657
    {
658
        $fullName = array();
659
        if ($this->getFirstname() !== null) {
660
            $fullName[] = $this->getFirstname();
661
        }
662
        if ($this->getSurname() !== null) {
663
            $fullName[] = $this->getSurname();
664
        }
665
666
        if (count($fullName) > 0) {
667
            return implode(' ', $fullName);
668
        } else {
669
            return null;
670
        }
671
    }
672
673
    /**
674
     * Get the full name of the user (first + last name)
675
     * @JMS\Groups({"full_name", "name"})
676
     * @JMS\VirtualProperty
677
     * @JMS\SerializedName("name")
678
     * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
679
     */
680
    public function getOIDCName()
681
    {
682
        return $this->getFullName();
683
    }
684
685
    /**
686
     * @JMS\Groups({"badges", "public_profile"})
687
     * @JMS\VirtualProperty
688
     * @JMS\SerializedName("deprecated_badges")
689
     * @return array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use array<string,boolean>.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
690
     */
691
    public function getDataValid()
692
    {
693
        $terms['cpf'] = is_numeric($this->cpf);
0 ignored issues
show
Coding Style Comprehensibility introduced by
$terms was never initialized. Although not strictly required by PHP, it is generally a good practice to add $terms = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
694
        $terms['email'] = is_null($this->getConfirmationToken());
695
696
        return $terms;
697
    }
698
699
    public function setCpf($cpf)
700
    {
701
        $cpf = trim(preg_replace('/[^0-9]/', '', $cpf));
702
703
        if ($cpf === '') {
704
            $cpf = null;
705
        }
706
707
        $this->cpf = $cpf;
708
709
        return $this;
710
    }
711
712
    public function getCpf()
713
    {
714
        return $this->cpf;
715
    }
716
717
    /**
718
     * @param \LoginCidadao\CoreBundle\Entity\City $city
0 ignored issues
show
Documentation introduced by
Should the type for parameter $city not be null|City?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
719
     * @return City
0 ignored issues
show
Documentation introduced by
Should the return type not be Person?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
720
     */
721 1
    public function setCity(\LoginCidadao\CoreBundle\Entity\City $city = null)
722
    {
723 1
        $this->city = $city;
724
725 1
        return $this;
726
    }
727
728
    /**
729
     * @return \LoginCidadao\CoreBundle\Entity\City
0 ignored issues
show
Documentation introduced by
Should the return type not be City|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
730
     */
731
    public function getCity()
732
    {
733
        return $this->city;
734
    }
735
736
    public function setCreatedAt(\DateTime $createdAt)
737
    {
738
        $this->createdAt = $createdAt;
739
740
        return $this;
741
    }
742
743
    public function getCreatedAt()
744
    {
745
        return $this->createdAt;
746
    }
747
748
    /**
749
     * @ORM\PrePersist
750
     */
751
    public function setCreatedAtValue()
752
    {
753
        if (!($this->getCreatedAt() instanceof \DateTime)) {
754
            $this->createdAt = new \DateTime();
755
        }
756
        if (!$this->updatedAt) {
757
            $this->updatedAt = new \DateTime();
758
        }
759
    }
760
761
    public function setEmailConfirmedAt(\DateTime $emailConfirmedAt = null)
762
    {
763
        $this->emailConfirmedAt = $emailConfirmedAt;
764
765
        return $this;
766
    }
767
768
    public function getEmailConfirmedAt()
769
    {
770
        return $this->emailConfirmedAt;
771
    }
772
773
    public function getSocialNetworksPicture()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
774
    {
775
        if (!is_null($this->getFacebookId())) {
776
            return "https://graph.facebook.com/{$this->getFacebookId()}/picture?height=245&width=245";
777
        }
778
779
        return null;
780
    }
781
782
    public function getClients()
783
    {
784
        return $this->clients;
785
    }
786
787
    public function setClients($var)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
788
    {
789
        return $this->clients = $var;
790
    }
791
792
    public function setEmailExpiration($emailExpiration)
793
    {
794
        $this->emailExpiration = $emailExpiration;
795
796
        return $this;
797
    }
798
799
    public function getEmailExpiration()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
800
    {
801
        return $this->emailExpiration;
802
    }
803
804
    public function setFacebookUsername($facebookUsername)
805
    {
806
        $this->facebookUsername = $facebookUsername;
807
808
        return $this;
809
    }
810
811
    public function getFacebookUsername()
812
    {
813
        return $this->facebookUsername;
814
    }
815
816
    public function getFacebookAccessToken()
817
    {
818
        return $this->facebookAccessToken;
819
    }
820
821
    public function setFacebookAccessToken($facebookAccessToken)
822
    {
823
        $this->facebookAccessToken = $facebookAccessToken;
824
825
        return $this;
826
    }
827
828
    public function setPreviousValidEmail($previousValidEmail)
829
    {
830
        $this->previousValidEmail = $previousValidEmail;
831
832
        return $this;
833
    }
834
835
    public function getPreviousValidEmail()
836
    {
837
        return $this->previousValidEmail;
838
    }
839
840
    public function hasPassword()
841
    {
842
        $password = $this->getPassword();
843
844
        return strlen($password) > 0;
845
    }
846
847 1
    public function setState(State $state = null)
848
    {
849 1
        $this->state = $state;
850
851 1
        return $this;
852
    }
853
854
    public function getState()
855
    {
856
        return $this->state;
857
    }
858
859
    /**
860
     * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
861
     * of 'UploadedFile' is injected into this setter to trigger the  update. If this
862
     * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
863
     * must be able to accept an instance of 'File' as the bundle will inject one here
864
     * during Doctrine hydration.
865
     *
866
     * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image
867
     */
868
    public function setImage($image)
869
    {
870
        $this->image = $image;
871
872
        if ($this->image) {
873
            $this->updatedAt = new \DateTime('now');
874
        }
875
    }
876
877
    /**
878
     * @return File
879
     */
880
    public function getImage()
881
    {
882
        return $this->image;
883
    }
884
885
    /**
886
     * @param string $imageName
887
     */
888
    public function setImageName($imageName)
889
    {
890
        $this->imageName = $imageName;
891
    }
892
893
    /**
894
     * @return string
895
     */
896
    public function getImageName()
897
    {
898
        return $this->imageName;
899
    }
900
901
    public function setProfilePictureUrl($profilePictureUrl)
902
    {
903
        $this->profilePictureUrl = $profilePictureUrl;
904
905
        return $this;
906
    }
907
908
    public function getProfilePictureUrl()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
909
    {
910
        return $this->profilePictureUrl;
911
    }
912
913
    /**
914
     * @JMS\Groups({"public_profile"})
915
     * @JMS\VirtualProperty
916
     * @JMS\SerializedName("age_range")
917
     * @JMS\Type("array")
918
     * @return array
919
     */
920
    public function getAgeRange()
921
    {
922
        $today = new \DateTime('today');
923
        if (!$this->getBirthdate()) {
924
            return array();
925
        }
926
        $age = $this->getBirthdate()->diff($today)->y;
927
928
        $range = array();
929
        if ($age < 13) {
930
            $range['max'] = 13;
931
        }
932
        if ($age >= 13 && $age < 18) {
933
            $range['min'] = 13;
934
            $range['max'] = 17;
935
        }
936
        if ($age >= 18 && $age < 21) {
937
            $range['min'] = 18;
938
            $range['max'] = 20;
939
        }
940
        if ($age >= 21) {
941
            $range['min'] = 21;
942
        }
943
944
        return $range;
945
    }
946
947
    public function hasLocalProfilePicture()
948
    {
949
        return !is_null($this->getImageName());
950
    }
951
952
    public function getSuggestions()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
953
    {
954
        return $this->suggestions;
955
    }
956
957
    public function setSuggestions($suggestions)
958
    {
959
        $this->suggestions = $suggestions;
960
961
        return $this;
962
    }
963
964
    public function prepareAPISerialize(
965
        $imageHelper,
966
        $templateHelper,
967
        $isDev,
968
        $request
969
    ) {
970
        // User's profile picture
971
        if ($this->hasLocalProfilePicture()) {
972
            $picturePath = $imageHelper->asset($this, 'image');
973
            $pictureUrl = $request->getUriForPath($picturePath);
974
            if ($isDev) {
975
                $pictureUrl = str_replace('/app_dev.php', '', $pictureUrl);
976
            }
977
        } else {
978
            $pictureUrl = $this->getSocialNetworksPicture();
979
        }
980
        if (is_null($pictureUrl)) {
981
            // TODO: fix this and make it comply to DRY
982
            $picturePath = $templateHelper->getUrl('bundles/logincidadaocore/images/userav.png');
983
            $pictureUrl = $request->getUriForPath($picturePath);
984
            if ($isDev) {
985
                $pictureUrl = str_replace('/app_dev.php', '', $pictureUrl);
986
            }
987
        }
988
        $this->setProfilePictureUrl($pictureUrl);
989
        $this->serialize();
990
    }
991
992
    public function isClientAuthorized($app_id)
0 ignored issues
show
Coding Style Naming introduced by
The parameter $app_id is not named in camelCase.

This check marks parameter names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
993
    {
994
        foreach ($this->getAuthorizations() as $auth) {
995
            if ($auth->getClient()->getPublicId() === $app_id) {
0 ignored issues
show
Coding Style introduced by
$app_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
996
                return true;
997
            }
998
        }
999
1000
        return false;
1001
    }
1002
1003
    /**
1004
     * @ORM\PreUpdate
1005
     */
1006
    public function setUpdatedAt($updatedAt = null)
1007
    {
1008
        if ($updatedAt instanceof \DateTime) {
1009
            $this->updatedAt = $updatedAt;
1010
        } else {
1011
            $this->updatedAt = new \DateTime('now');
1012
        }
1013
1014
        return $this;
1015
    }
1016
1017
    public function getUpdatedAt()
1018
    {
1019
        return $this->updatedAt;
1020
    }
1021
1022
    public function setGoogleId($var)
1023
    {
1024
        $this->googleId = $var;
1025
1026
        return $this;
1027
    }
1028
1029
    public function getGoogleId()
1030
    {
1031
        return $this->googleId;
1032
    }
1033
1034
    public function setGoogleUsername($var)
1035
    {
1036
        $this->googleUsername = $var;
1037
1038
        return $this;
1039
    }
1040
1041
    public function getGoogleUsername()
1042
    {
1043
        return $this->googleUsername;
1044
    }
1045
1046
    public function setGoogleAccessToken($var)
1047
    {
1048
        $this->googleAccessToken = $var;
1049
1050
        return $this;
1051
    }
1052
1053
    public function getGoogleAccessToken()
1054
    {
1055
        return $this->googleAccessToken;
1056
    }
1057
1058 1
    public function setCountry(Country $country = null)
1059
    {
1060 1
        $this->country = $country;
1061
1062 1
        return $this;
1063
    }
1064
1065
    public function getCountry()
1066
    {
1067
        return $this->country;
1068
    }
1069
1070
    public function setComplement($var)
1071
    {
1072
        $this->complement = $var;
0 ignored issues
show
Bug introduced by
The property complement does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
1073
1074
        return $this;
1075
    }
1076
1077
    public function getComplement()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
1078
    {
1079
        return $this->complement;
1080
    }
1081
1082
    public function getIdCards()
1083
    {
1084
        return $this->idCards;
1085
    }
1086
1087
    public function getBadges()
1088
    {
1089
        return $this->badges;
1090
    }
1091
1092
    public function mergeBadges(array $badges)
1093
    {
1094
        $this->badges = array_merge($this->badges, $badges);
1095
1096
        return $this;
1097
    }
1098
1099
    public function getFullNameOrUsername()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
1100
    {
1101
        if (null === $this->firstName) {
1102
            return $this->username;
1103
        }
1104
1105
        return $this->getFullName();
1106
    }
1107
1108
    public function getLogoutKeys()
1109
    {
1110
        return $this->logoutKeys;
1111
    }
1112
1113
    /**
1114
     * @return ArrayCollection
1115
     */
1116
    public function getAddresses()
1117
    {
1118
        return $this->addresses;
1119
    }
1120
1121
    public function setLogoutKeys($logoutKeys)
1122
    {
1123
        $this->logoutKeys = $logoutKeys;
1124
1125
        return $this;
1126
    }
1127
1128
    public function setAddresses($addresses)
1129
    {
1130
        $this->addresses = $addresses;
1131
1132
        return $this;
1133
    }
1134
1135
    /**
1136
     * Checks whether 2FA is enabled.
1137
     *
1138
     * @return boolean
1139
     */
1140
    public function isTwoFactorAuthenticationEnabled()
1141
    {
1142
        return $this->googleAuthenticatorSecret !== null;
1143
    }
1144
1145
    public function getGoogleAuthenticatorSecret()
1146
    {
1147
        return $this->googleAuthenticatorSecret;
1148
    }
1149
1150
    public function setGoogleAuthenticatorSecret($googleAuthenticatorSecret)
1151
    {
1152
        $this->googleAuthenticatorSecret = $googleAuthenticatorSecret;
1153
1154
        return $this;
1155
    }
1156
1157
    public function getBackupCodes()
1158
    {
1159
        return $this->backupCodes;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $this->backupCodes; (Doctrine\Common\Collections\ArrayCollection) is incompatible with the return type declared by the interface LoginCidadao\CoreBundle\...terface::getBackupCodes of type LoginCidadao\CoreBundle\Entity\BackupCode[].

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
1160
    }
1161
1162
    public function setBackupCodes(ArrayCollection $backupCodes)
1163
    {
1164
        $this->backupCodes = $backupCodes;
1165
1166
        return $this;
1167
    }
1168
1169
    public function invalidateBackupCode($code)
1170
    {
1171
        $backupCode = $this->findBackupCode($code);
1172
        $backupCode->setUsed(true);
1173
1174
        return $this;
1175
    }
1176
1177
    public function isBackupCode($code)
1178
    {
1179
        $backupCode = $this->findBackupCode($code);
1180
1181
        return $backupCode !== false && $backupCode->getUsed() === false;
1182
    }
1183
1184
    /**
1185
     * @param string $code
1186
     * @return BackupCode
1187
     */
1188
    private function findBackupCode($code)
1189
    {
1190
        $backupCodes = $this->getBackupCodes();
1191
        foreach ($backupCodes as $backupCode) {
1192
            if ($backupCode->getCode() === $code) {
1193
                return $backupCode;
1194
            }
1195
        }
1196
1197
        return false;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return false; (false) is incompatible with the return type documented by LoginCidadao\CoreBundle\...\Person::findBackupCode of type LoginCidadao\CoreBundle\Entity\BackupCode.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
1198
    }
1199
1200
    public function setNationality($var)
1201
    {
1202
        $this->nationality = $var;
1203
1204
        return $this;
1205
    }
1206
1207
    public function getNationality()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
1208
    {
1209
        return $this->nationality;
1210
    }
1211
1212
    public function getPlaceOfBirth()
1213
    {
1214
        $location = new LocationSelectData();
1215
        $location->getFromObject($this);
1216
1217
        return $location;
1218
    }
1219
1220
    public function setPlaceOfBirth(LocationSelectData $location)
1221
    {
1222
        $location->toObject($this);
1223
    }
1224
1225
    /**
1226
     * @JMS\Groups({"public_profile"})
1227
     * @JMS\VirtualProperty
1228
     * @JMS\SerializedName("given_name")
1229
     */
1230
    public function getGivenName()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
1231
    {
1232
        return $this->getFirstName();
1233
    }
1234
1235
    /**
1236
     * @JMS\Groups({"full_name","name"})
1237
     * @JMS\VirtualProperty
1238
     * @JMS\SerializedName("family_name")
1239
     */
1240
    public function getFamilyName()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
1241
    {
1242
        return $this->getSurname();
1243
    }
1244
1245
    /**
1246
     * @JMS\Groups({"mobile", "phone_number"})
1247
     * @JMS\VirtualProperty
1248
     * @JMS\SerializedName("phone_number")
1249
     */
1250
    public function getPhoneNumber()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
1251
    {
1252
        return $this->getMobile();
1253
    }
1254
1255
    /**
1256
     * @param bool $verified
1257
     * @return $this
1258
     */
1259 1
    public function setPhoneNumberVerified($verified = false)
1260
    {
1261 1
        $this->phoneNumberVerified = $verified;
1262
1263 1
        return $this;
1264
    }
1265
1266
    /**
1267
     * @return bool
1268
     */
1269 2
    public function getPhoneNumberVerified()
1270
    {
1271 2
        return $this->phoneNumberVerified;
1272
    }
1273
1274
    public function getPasswordEncoderName()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
1275
    {
1276
        return $this->passwordEncoderName;
1277
    }
1278
1279
    public function setPasswordEncoderName($passwordEncoderName)
1280
    {
1281
        $this->passwordEncoderName = $passwordEncoderName;
1282
1283
        return $this;
1284
    }
1285
1286
    public function getEncoderName()
1287
    {
1288
        $encoder = $this->passwordEncoderName;
1289
1290
        // BC for PR #357
1291
        if ($encoder === null || strlen($encoder) < 1) {
1292
            return null;
1293
        }
1294
1295
        return $encoder;
1296
    }
1297
1298
    public function getLongDisplayName()
1299
    {
1300
        if ($this->getFullName()) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->getFullName() of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
1301
            return $this->getFullName();
1302
        } else {
1303
            return $this->getEmail();
1304
        }
1305
    }
1306
1307
    public function getShortDisplayName()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
1308
    {
1309
        if ($this->getGivenName()) {
1310
            return $this->getGivenName();
1311
        } else {
1312
            return $this->getEmail();
1313
        }
1314
    }
1315
}
1316