Passed
Push — master ( b4cb9f...51bac7 )
by Anthony
02:22
created

Account::getSalt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace PiouPiou\RibsAdminBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Symfony\Component\Security\Core\User\UserInterface;
7
8
/**
9
 * @ORM\Entity(repositoryClass="PiouPiou\RibsAdminBundle\Repository\AccountRepository")
10
 * @ORM\Table(name="account")
11
 */
12
class Account implements UserInterface, \Serializable
13
{
14
	/**
15
	 * @ORM\Id
16
	 * @ORM\Column(type="integer")
17
	 * @ORM\GeneratedValue(strategy="AUTO")
18
	 */
19
	protected $id;
20
	
21
	/**
22
	 * @ORM\Column(type="string", length=255, unique=true)
23
	 */
24
	private $username;
25
	
26
	/**
27
	 * @ORM\Column(type="string", length=64)
28
	 */
29
	private $password;
30
	
31
	/**
32
	 * @ORM\Column(type="string", length=100, unique=true)
33
	 */
34
	private $email;
35
	
36
	/**
37
	 * @ORM\Column(name="is_active", type="boolean")
38
	 */
39
	private $isActive;
40
	
41
	/**
42
	 * @var User
43
	 *
44
	 * @ORM\OneToOne(targetEntity="PiouPiou\RibsAdminBundle\Entity\User", cascade={"persist"})
45
	 * @ORM\JoinColumns({
46
	 *   @ORM\JoinColumn(name="id_user", referencedColumnName="id", nullable=true)
47
	 * })
48
	 */
49
	private $user;
50
	
51
	public function __construct()
52
	{
53
		$this->isActive = true;
54
		// may not be needed, see section on salt below
55
		// $this->salt = md5(uniqid('', true));
56
	}
57
	
58
	/**
59
	 * @return mixed
60
	 */
61
	public function getId()
62
	{
63
		return $this->id;
64
	}
65
	
66
	/**
67
	 * @param mixed $id
68
	 */
69
	public function setId($id)
70
	{
71
		$this->id = $id;
72
	}
73
	
74
	/**
75
	 * @return mixed
76
	 */
77
	public function getEmail()
78
	{
79
		return $this->email;
80
	}
81
	
82
	/**
83
	 * @param mixed $email
84
	 */
85
	public function setEmail($email)
86
	{
87
		$this->email = $email;
88
	}
89
	
90
	/**
91
	 * @return mixed
92
	 */
93
	public function getPassword()
94
	{
95
		return $this->password;
96
	}
97
	
98
	/**
99
	 * @param mixed $password
100
	 */
101
	public function setPassword($password)
102
	{
103
		$this->password = $password;
104
	}
105
	
106
	/**
107
	 * @return mixed
108
	 */
109
	public function getUsername()
110
	{
111
		return $this->username;
112
	}
113
	
114
	/**
115
	 * @param mixed $username
116
	 */
117
	public function setUsername($username)
118
	{
119
		$this->username = $username;
120
	}
121
	
122
	/**
123
	 * @return mixed
124
	 */
125
	public function getisActive()
126
	{
127
		return $this->isActive;
128
	}
129
	
130
	/**
131
	 * @param mixed $isActive
132
	 */
133
	public function setIsActive($isActive)
134
	{
135
		$this->isActive = $isActive;
136
	}
137
	
138
	/**
139
	 * @return User
140
	 */
141
	public function getUser()
142
	{
143
		return $this->user;
144
	}
145
	
146
	/**
147
	 * @param User $user
148
	 */
149
	public function setUser($user)
150
	{
151
		$this->user = $user;
152
	}
153
	
154
	/**
155
	 * Returns the roles granted to the user.
156
	 *
157
	 * <code>
158
	 * public function getRoles()
159
	 * {
160
	 *     return array('ROLE_USER');
161
	 * }
162
	 * </code>
163
	 *
164
	 * Alternatively, the roles might be stored on a ``roles`` property,
165
	 * and populated in any number of different ways when the user object
166
	 * is created.
167
	 *
168
	 * @return (Role|string)[] The user roles
169
	 */
170
	public function getRoles()
171
	{
172
		return ['ROLE_ADMIN'];
173
	}
174
	
175
	/**
176
	 * Returns the salt that was originally used to encode the password.
177
	 *
178
	 * This can return null if the password was not encoded using a salt.
179
	 *
180
	 * @return string|null The salt
181
	 */
182
	public function getSalt()
183
	{
184
		// you *may* need a real salt depending on your encoder
185
		// see section on salt below
186
		return null;
187
	}
188
	
189
	/**
190
	 * Removes sensitive data from the user.
191
	 *
192
	 * This is important if, at any given point, sensitive information like
193
	 * the plain-text password is stored on this object.
194
	 */
195
	public function eraseCredentials()
196
	{
197
	}
198
	
199
	/**
200
	 * String representation of object
201
	 * @link http://php.net/manual/en/serializable.serialize.php
202
	 * @return string the string representation of the object or null
203
	 * @since 5.1.0
204
	 */
205
	public function serialize()
206
	{
207
		return serialize([
208
			$this->id,
209
			$this->username,
210
			$this->password,
211
			// see section on salt below
212
			// $this->salt,
213
		]);
214
	}
215
	
216
	/**
217
	 * Constructs the object
218
	 * @link http://php.net/manual/en/serializable.unserialize.php
219
	 * @param string $serialized <p>
220
	 * The string representation of the object.
221
	 * </p>
222
	 * @return void
223
	 * @since 5.1.0
224
	 */
225
	public function unserialize($serialized)
226
	{
227
		list (
228
			$this->id,
229
			$this->username,
230
			$this->password,
231
			// see section on salt below
232
			// $this->salt
233
			) = unserialize($serialized);
234
	}
235
}