Passed
Push — master ( 71711b...62d875 )
by Jan
03:15
created

User::getTimezone()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
/**
4
 *
5
 * part-db version 0.1
6
 * Copyright (C) 2005 Christoph Lechner
7
 * http://www.cl-projects.de/
8
 *
9
 * part-db version 0.2+
10
 * Copyright (C) 2009 K. Jacobs and others (see authors.php)
11
 * http://code.google.com/p/part-db/
12
 *
13
 * Part-DB Version 0.4+
14
 * Copyright (C) 2016 - 2019 Jan Böhmer
15
 * https://github.com/jbtronics
16
 *
17
 * This program is free software; you can redistribute it and/or
18
 * modify it under the terms of the GNU General Public License
19
 * as published by the Free Software Foundation; either version 2
20
 * of the License, or (at your option) any later version.
21
 *
22
 * This program is distributed in the hope that it will be useful,
23
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25
 * GNU General Public License for more details.
26
 *
27
 * You should have received a copy of the GNU General Public License
28
 * along with this program; if not, write to the Free Software
29
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
30
 *
31
 */
32
33
namespace App\Entity;
34
35
use Doctrine\ORM\Mapping as ORM;
36
use Symfony\Component\Security\Core\User\UserInterface;
37
38
/**
39
 * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
40
 * @ORM\Table("users")
41
 */
42
class User extends NamedDBElement implements UserInterface
43
{
44
    /**
45
     * @ORM\Id()
46
     * @ORM\GeneratedValue()
47
     * @ORM\Column(type="integer")
48
     */
49
    protected $id;
50
51
    /**
52
     * @ORM\Column(type="string", length=180, unique=true)
53
     */
54
    protected $name;
55
56
    /**
57
     * //@ORM\Column(type="json")
58
     */
59
    //protected $roles = [];
60
61
    /**
62
     * @var string The hashed password
63
     * @ORM\Column(type="string")
64
     */
65
    protected $password;
66
67
    /**
68
     * @var string The first name of the User
69
     * @ORM\Column(type="string", length=255)
70
     */
71
    protected $first_name;
72
73
    /**
74
     * @var string The last name of the User
75
     * @ORM\Column(type="string", length=255)
76
     */
77
    protected $last_name;
78
79
    /**
80
     * @var string The department the user is working
81
     * @ORM\Column(type="string", length=255)
82
     */
83
    protected $department;
84
85
86
    /**
87
     * @var string The email address of the user
88
     * @ORM\Column(type="string", length=255)
89
     */
90
    protected $email;
91
92
    /**
93
     * @var string The language/locale the user prefers
94
     * @ORM\Column(type="string", name="config_language")
95
     */
96
    protected $language;
97
98
    /**
99
     * @var string The timezone the user prefers
100
     * @ORM\Column(type="string", name="config_timezone")
101
     */
102
    protected $timezone;
103
104
    /**
105
     * @var string The theme
106
     * @ORM\Column(type="string", name="config_theme")
107
     */
108
    protected $theme;
109
110
111
    /**
112
     * A visual identifier that represents this user.
113
     *
114
     * @see UserInterface
115
     */
116
    public function getUsername(): string
117
    {
118
        return (string) $this->name;
119
    }
120
121
    /**
122
     * @see UserInterface
123
     */
124
    public function getRoles(): array
125
    {
126
        $roles = [];
127
        //$roles = $this->roles;
128
        // guarantee every user at least has ROLE_USER
129
        $roles[] = 'ROLE_USER';
130
131
        return array_unique($roles);
132
    }
133
134
    public function setRoles(array $roles): self
0 ignored issues
show
Unused Code introduced by
The parameter $roles is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

134
    public function setRoles(/** @scrutinizer ignore-unused */ array $roles): self

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
135
    {
136
        //$this->roles = $roles;
137
138
        return $this;
139
    }
140
141
    /**
142
     * @see UserInterface
143
     */
144
    public function getPassword(): string
145
    {
146
        return (string) $this->password;
147
    }
148
149
    public function setPassword(string $password): self
150
    {
151
        $this->password = $password;
152
153
        return $this;
154
    }
155
156
    /**
157
     * @see UserInterface
158
     */
159
    public function getSalt()
160
    {
161
        // not needed when using the "bcrypt" algorithm in security.yaml
162
    }
163
164
    /**
165
     * @see UserInterface
166
     */
167
    public function eraseCredentials()
168
    {
169
        // If you store any temporary, sensitive data on the user, clear it here
170
        // $this->plainPassword = null;
171
    }
172
173
    /**
174
     * Returns the ID as an string, defined by the element class.
175
     * This should have a form like P000014, for a part with ID 14.
176
     * @return string The ID as a string;
177
     */
178
    public function getIDString(): string
179
    {
180
        return "U" . $this->getID();
181
    }
182
183
184
    /************************************************
185
     * Getters
186
     ************************************************/
187
188
    /**
189
     * @return string
190
     */
191
    public function getFirstName(): string
192
    {
193
        return $this->first_name;
194
    }
195
196
    /**
197
     * @param string $first_name
198
     * @return User
199
     */
200
    public function setFirstName(string $first_name): User
201
    {
202
        $this->first_name = $first_name;
203
        return $this;
204
    }
205
206
    /**
207
     * @return string
208
     */
209
    public function getLastName(): string
210
    {
211
        return $this->last_name;
212
    }
213
214
    /**
215
     * @param string $last_name
216
     * @return User
217
     */
218
    public function setLastName(string $last_name): User
219
    {
220
        $this->last_name = $last_name;
221
        return $this;
222
    }
223
224
    /**
225
     * @return string
226
     */
227
    public function getDepartment(): string
228
    {
229
        return $this->department;
230
    }
231
232
    /**
233
     * @param string $department
234
     * @return User
235
     */
236
    public function setDepartment(string $department): User
237
    {
238
        $this->department = $department;
239
        return $this;
240
    }
241
242
    /**
243
     * @return string
244
     */
245
    public function getEmail(): string
246
    {
247
        return $this->email;
248
    }
249
250
    /**
251
     * @param string $email
252
     * @return User
253
     */
254
    public function setEmail(string $email): User
255
    {
256
        $this->email = $email;
257
        return $this;
258
    }
259
260
    /**
261
     * @return string
262
     */
263
    public function getLanguage(): string
264
    {
265
        return $this->language;
266
    }
267
268
    /**
269
     * @param string $language
270
     * @return User
271
     */
272
    public function setLanguage(string $language): User
273
    {
274
        $this->language = $language;
275
        return $this;
276
    }
277
278
    /**
279
     * @return string
280
     */
281
    public function getTimezone(): string
282
    {
283
        return $this->timezone;
284
    }
285
286
    /**
287
     * @param string $timezone
288
     * @return User
289
     */
290
    public function setTimezone(string $timezone): User
291
    {
292
        $this->timezone = $timezone;
293
        return $this;
294
    }
295
296
    /**
297
     * @return string
298
     */
299
    public function getTheme(): string
300
    {
301
        return $this->theme;
302
    }
303
304
    /**
305
     * @param string $theme
306
     * @return User
307
     */
308
    public function setTheme(string $theme): User
309
    {
310
        $this->theme = $theme;
311
        return $this;
312
    }
313
314
}
315