Completed
Push — master ( 817fef...b9c500 )
by Allan
06:04
created

User::setPhoneNumber()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 6
ccs 0
cts 5
cp 0
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
crap 2
1
<?php
2
3
namespace SMG\UserBundle\Entity;
4
5
use FOS\UserBundle\Entity\User as BaseUser;
6
use Doctrine\ORM\Mapping as ORM;
7
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
8
use JMS\Serializer\Annotation as Serializer;
9
10
/**
11
 * SMG\UserBundle\Entity\User.
12
 *
13
 * @ORM\Entity
14
 * @ORM\Table(name="oauth_users")
15
 * @ORM\AttributeOverrides({
16
 *     @ORM\AttributeOverride(
17
 *         name="email",
18
 *         column=@ORM\Column(
19
 *             type="string",
20
 *             nullable=true
21
 *         )
22
 *     ),
23
 *     @ORM\AttributeOverride(
24
 *          name="emailCanonical",
25
 *          column=@ORM\Column(
26
 *              type="string",
27
 *              name="email_canonical",
28
 *              length=255,
29
 *              nullable=true
30
 *          )
31
 *     ),
32
 * })
33
 */
34
class User extends BaseUser implements AdvancedUserInterface
35
{
36
    /**
37
     * @ORM\Column(type="integer")
38
     * @ORM\Id
39
     * @ORM\GeneratedValue(strategy="AUTO")
40
     */
41
    protected $id;
42
43
    /**
44
     * @ORM\Column(type="string", nullable=true)
45
     */
46
    protected $phoneNumber = null;
47
48
    public function __construct()
49
    {
50
        parent::__construct();
51
        $this->email = null;
52
        // note: when saving the user manager will put the email canonical
53
        // to empty string hence why we removed the unique constraint,
54
        // to avoid error being thrown when registering a user only with
55
        // phone number
56
        $this->emailCanonical = null;
57
    }
58
59
    public function getId()
60
    {
61
        return $this->id;
62
    }
63
64
    public function getPhoneNumber()
65
    {
66
        return $this->phoneNumber;
67
    }
68
69
    /**
70
     * TODO: problem on Symfony client side when use 
71
     * an already declared function name, need to
72
     * investigate why.
73
     *
74
     * @Serializer\VirtualProperty
75
     */
76
    public function getUserRoles()
77
    {
78
        return $this->roles;
79
    }
80
81
    public function setPhoneNumber($phoneNumber)
82
    {
83
        $this->phoneNumber = $phoneNumber;
84
85
        return $this;
86
    }
87
88
    public function isAccountNonExpired()
89
    {
90
        return true;
91
    }
92
93
    public function isCredentialsNonExpired()
94
    {
95
        return true;
96
    }
97
}
98