Completed
Push — master ( b9c500...b355e1 )
by Allan
03:25
created

User   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 66.67%

Importance

Changes 9
Bugs 4 Features 1
Metric Value
wmc 7
c 9
b 4
f 1
lcom 0
cbo 1
dl 0
loc 64
ccs 12
cts 18
cp 0.6667
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A getId() 0 4 1
A getPhoneNumber() 0 4 1
A getUserRoles() 0 4 1
A setPhoneNumber() 0 6 1
A isAccountNonExpired() 0 4 1
A isCredentialsNonExpired() 0 4 1
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 30
    public function __construct()
49
    {
50 30
        parent::__construct();
51 30
        $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 30
        $this->emailCanonical = null;
57 30
    }
58
59 27
    public function getId()
60
    {
61 27
        return $this->id;
62
    }
63
64 29
    public function getPhoneNumber()
65
    {
66 29
        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 30
    public function setPhoneNumber($phoneNumber)
82
    {
83 30
        $this->phoneNumber = $phoneNumber;
84
85 30
        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