Completed
Pull Request — dev (#36)
by nonanerz
03:13
created

Admin::setUsername()   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 1
Bugs 0 Features 0
Metric Value
dl 0
loc 6
rs 9.4285
c 1
b 0
f 0
ccs 0
cts 3
cp 0
cc 1
eloc 3
nc 1
nop 1
crap 2
1
<?php
2
3
namespace AppBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Knp\DoctrineBehaviors\Model as ORMBehaviors;
7
use Symfony\Component\Security\Core\User\UserInterface;
8
use Symfony\Component\Validator\Constraints as Assert;
9
10
/**
11
 * Admin.
12
 *
13
 * @ORM\Entity(repositoryClass="AppBundle\Repository\AdminRepository")
14
 */
15
class Admin implements UserInterface
16
{
17
    use ORMBehaviors\Timestampable\Timestampable;
18
    /**
19
     * @var int
20
     *
21
     * @ORM\Column(type="integer")
22
     * @ORM\Id
23
     * @ORM\GeneratedValue(strategy="AUTO")
24
     */
25
    private $id;
26
27
    /**
28
     * @var string
29
     * @Assert\Type("string")
30
     * @Assert\Length(
31
     *      min = 2,
32
     *      max = 190
33
     * )
34
     * @ORM\Column(type="string", length=190, unique=true)
35
     */
36
    private $userName;
37
38
    /**
39
     * @var string
40
     * @Assert\Email(
41
     *     checkMX = true
42
     * )
43
     * @Assert\Type("string")
44
     * @Assert\Length(
45
     *      max = 250
46
     * )
47
     * @ORM\Column(type="string", length=250, unique=true)
48
     */
49
    private $email;
50
51
    /**
52
     * @var string
53
     * @Assert\Type("string")
54
     * @Assert\Length(
55
     *      max = 255
56
     * )
57
     * @ORM\Column(type="string", length=255)
58
     */
59
    private $password;
60
61
    /**
62
     * @var string
63
     */
64
    private $plainPassword;
65
66
    /**
67
     * @var
68
     * @ORM\Column(type="json_array")
69
     */
70
    protected $roles;
71
72
    public function __construct()
73
    {
74
        $this->roles = array('ROLE_ADMIN');
75
    }
76
77
    /**
78
     * Get id.
79
     *
80
     * @return int
81
     */
82
    public function getId()
83
    {
84
        return $this->id;
85
    }
86
87
    /**
88
     * Set username.
89
     *
90
     * @param string $name
91
     *
92
     * @return Admin
93
     */
94
    public function setUsername($name)
95
    {
96
        $this->userName = $name;
97
98
        return $this;
99
    }
100
101
    /**
102
     * Get name.
103
     *
104
     * @return string
105
     */
106
    public function getUsername()
107
    {
108
        return $this->userName;
109
    }
110
111
    /**
112
     * Set email.
113
     *
114
     * @param string $email
115
     *
116
     * @return Admin
117
     */
118
    public function setEmail($email)
119
    {
120
        $this->email = $email;
121
122
        return $this;
123
    }
124
125
    /**
126
     * Get email.
127
     *
128
     * @return string
129
     */
130
    public function getEmail()
131
    {
132
        return $this->email;
133
    }
134
135
    /**
136
     * Set password.
137
     *
138
     * @param string $password
139
     *
140
     * @return Admin
141
     */
142
    public function setPassword($password)
143
    {
144
        $this->password = $password;
145
146
        return $this;
147
    }
148
149
    /**
150
     * Get password.
151
     *
152
     * @return string
153
     */
154
    public function getPassword()
155
    {
156
        return $this->password;
157
    }
158
159
    /**
160
     * @return string
161
     */
162
    public function getPlainPassword()
163
    {
164
        return $this->plainPassword;
165
    }
166
167
    /**
168
     * @param string $plainPassword
169
     */
170
    public function setPlainPassword($plainPassword)
171
    {
172
        $this->plainPassword = $plainPassword;
173
    }
174
175
    /**
176
     * @param mixed $roles
177
     */
178
    public function setRoles($roles)
179
    {
180
        $this->roles = $roles;
181
    }
182
183
    /**
184
     * @return mixed
185
     */
186
    public function getRoles()
187
    {
188
        return $this->roles;
189
    }
190
191
    public function getSalt()
192
    {
193
        // TODO: Implement getSalt() method.
194
    }
195
196
    public function eraseCredentials()
197
    {
198
        $this->setPlainPassword(null);
199
    }
200
}
201