Completed
Push — SF4 ( 4059c5...3cffa6 )
by Laurent
01:58
created

User::setEnabled()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
/**
4
 * Entity User.
5
 *
6
 * PHP Version 7
7
 *
8
 * @author    Quétier Laurent <[email protected]>
9
 * @copyright 2018 Dev-Int GLSR
10
 * @license   http://opensource.org/licenses/gpl-license.php GNU Public License
11
 *
12
 * @version GIT: $Id$
13
 *
14
 * @link https://github.com/Dev-Int/glsr
15
 */
16
17
namespace App\Entity;
18
19
use Doctrine\ORM\Mapping as ORM;
20
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
21
22
/**
23
 * @ORM\Table(name="app_users")
24
 * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
25
 */
26
class User implements AdvancedUserInterface, \Serializable
27
{
28
    /**
29
     * @ORM\Column(type="integer")
30
     * @ORM\Id
31
     * @ORM\GeneratedValue(strategy="AUTO")
32
     */
33
    private $id;
34
35
    /**
36
     * @ORM\Column(type="string", length=25, unique=true)
37
     */
38
    private $username;
39
40
    /**
41
     * @ORM\Column(type="string", length=64)
42
     */
43
    private $password;
44
45
    /**
46
     * @ORM\Column(type="string", length=254, unique=true)
47
     */
48
    private $email;
49
    
50
    /**
51
     * @ORM\Column(type="array")
52
     */
53
    private $roles;
54
55
    /**
56
     * @ORM\Column(name="is_active", type="boolean")
57
     */
58
    private $isActive;
59
60
    public function __construct()
61
    {
62
        $this->isActive = true;
63
    }
64
65
    public function getUsername()
66
    {
67
        return $this->username;
68
    }
69
70
    public function getEmail()
71
    {
72
        return $this->email;
73
    }
74
75
    public function getSalt()
76
    {
77
        // you *may* need a real salt depending on your encoder
78
        // see section on salt below
79
        return null;
80
    }
81
82
    public function getPassword()
83
    {
84
        return $this->password;
85
    }
86
87
    public function getRoles()
88
    {
89
        return $this->roles;
90
    }
91
92
    public function eraseCredentials()
93
    {
94
    }
95
96
    public function isAccountNonExpired()
97
    {
98
        return true;
99
    }
100
    public function isAccountNonLocked()
101
    {
102
        return true;
103
    }
104
    public function isCredentialsNonExpired()
105
    {
106
        return true;
107
    }
108
    public function isEnabled()
109
    {
110
        return $this->isActive;
111
    }
112
113
    /** @see \Serializable::serialize() */
114
    public function serialize()
115
    {
116
        return serialize(array(
117
            $this->id,
118
            $this->username,
119
            $this->password,
120
            $this->isActive,
121
            // see section on salt below
122
            // $this->salt,
123
        ));
124
    }
125
126
    /** @see \Serializable::unserialize() */
127
    public function unserialize($serialized)
128
    {
129
        list (
130
            $this->id,
131
            $this->username,
132
            $this->password,
133
            $this->isActive,
134
            // see section on salt below
135
            // $this->salt
136
        ) = unserialize($serialized, ['allowed_classes' => false]);
137
    }
138
139
    public function getId(): ?int
140
    {
141
        return $this->id;
142
    }
143
144
    public function setUsername(string $username): self
145
    {
146
        $this->username = $username;
147
148
        return $this;
149
    }
150
151
    public function setPassword(string $password): self
152
    {
153
        $this->password = $password;
154
155
        return $this;
156
    }
157
158
    public function setEmail(string $email): self
159
    {
160
        $this->email = $email;
161
162
        return $this;
163
    }
164
165
    public function setEnabled(bool $isActive): self
166
    {
167
        $this->isActive = $isActive;
168
169
        return $this;
170
    }
171
172
    public function setRoles(array $roles): self
173
    {
174
        $this->roles = $roles;
175
176
        return $this;
177
    }
178
}
179