Completed
Push — Recipes ( 630f49...c8afb0 )
by Laurent
12:15 queued 03:48
created

User::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Entity User.
4
 *
5
 * PHP Version 7
6
 *
7
 * @author    Quétier Laurent <[email protected]>
8
 * @copyright 2014 Dev-Int GLSR
9
 * @license   http://opensource.org/licenses/gpl-license.php GNU Public License
10
 *
11
 * @version GIT: <git_id>
12
 *
13
 * @link https://github.com/Dev-Int/glsr
14
 */
15
namespace  App\Entity\Staff;
16
17
use FOS\UserBundle\Model\User as BaseUser;
18
use Doctrine\ORM\Mapping as ORM;
19
use Doctrine\Common\Collections\ArrayCollection;
20
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
21
 
22
/**
23
 * User Entity.
24
 *
25
 * @category Entity
26
 *
27
 * @ORM\Entity(repositoryClass="App\Repository\Staff\UserRepository")
28
 * @ORM\Table(name="fos_user")
29
 * @UniqueEntity(fields="usernameCanonical", errorPath="username",
30
 *     message="fos_user.username.already_used", groups={"Default", "Registration", "Profile"})
31
 * @UniqueEntity(fields="emailCanonical", errorPath="email",
32
 *     message="fos_user.email.already_used", groups={"Default", "Registration", "Profile"})
33
 */
34
class User extends BaseUser
35
{
36
    /**
37
     * @var int $usrId User id
38
     *
39
     * @ORM\Id
40
     * @ORM\Column(name="id", type="integer")
41
     * @ORM\GeneratedValue(strategy="AUTO")
42
     */
43
    protected $usrId;
44
 
45
    /**
46
     * @var Group $groups Objects App\Entity\Staff\Group
47
     *
48
     * @ORM\ManyToMany(targetEntity="App\Entity\Staff\Group", inversedBy="users")
49
     * @ORM\JoinTable(name="fos_user_user_group",
50
     *      joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
51
     *      inverseJoinColumns={@ORM\JoinColumn(name="group_id", referencedColumnName="id")}
52
     * )
53
     */
54
    protected $groups;
55
 
56
    /**
57
     * @ORM\Column(type="integer", length=6, options={"default":0})
58
     */
59
    protected $loginCount = 0;
60
 
61
    /**
62
     * @var \DateTime
63
     *
64
     * @ORM\Column(type="datetime", nullable=true)
65
     */
66
    protected $firstLogin;
67
 
68
    public function __construct()
69
    {
70
        parent::__construct();
71
        $this->groups = new ArrayCollection();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Doctrine\Common\Collections\ArrayCollection() of type object<Doctrine\Common\C...ctions\ArrayCollection> is incompatible with the declared type object<App\Entity\Staff\Group> of property $groups.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
72
    }
73
74
    public function getId()
75
    {
76
        return $this->usrId;
77
    }
78
    /**
79
     * Set loginCount
80
     *
81
     * @param integer $loginCount
82
     *
83
     * @return User
84
     */
85
    public function setLoginCount($loginCount)
86
    {
87
        $this->loginCount = $loginCount;
88
        return $this;
89
    }
90
 
91
    /**
92
     * Get loginCount
93
     *
94
     * @return integer
95
     */
96
    public function getLoginCount()
97
    {
98
        return $this->loginCount;
99
    }
100
 
101
    /**
102
     * Set firstLogin
103
     *
104
     * @param \DateTime $firstLogin
105
     *
106
     * @return User
107
     */
108
    public function setFirstLogin($firstLogin)
109
    {
110
        $this->firstLogin = $firstLogin;
111
        return $this;
112
    }
113
 
114
    /**
115
     * Get firstLogin
116
     *
117
     * @return \DateTime
118
     */
119
    public function getFirstLogin()
120
    {
121
        return $this->firstLogin;
122
    }
123
 
124
    public function isEnabled()
125
    {
126
        return $this->enabled;
127
    }
128
 
129
    public function setSalt($salt)
130
    {
131
        $this->salt = $salt;
132
    }
133
 
134
    public function setPassword($password)
135
    {
136
        if ($password !== null) {
137
            $this->password = $password;
138
        }
139
        return $this;
140
    }
141
 
142
    public function setGroups(ArrayCollection $groups = null)
143
    {
144
        if ($groups !== null) {
145
            $this->groups = $groups;
0 ignored issues
show
Documentation Bug introduced by
It seems like $groups of type object<Doctrine\Common\C...ctions\ArrayCollection> is incompatible with the declared type object<App\Entity\Staff\Group> of property $groups.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
146
        }
147
    }
148
 
149
    public function setRoles(array $roles = array())
150
    {
151
        $this->roles = array();
152
        foreach ($roles as $role) {
153
            $this->addRole($role);
154
        }
155
        return $this;
156
    }
157
 
158
    public function hasGroup($name = '')
159
    {
160
        return in_array($name, $this->getGroupNames());
161
    }
162
}
163