Completed
Push — master ( b20bb8...057e61 )
by Tarmo
29s queued 11s
created

SecurityUser::getLocale()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
declare(strict_types = 1);
3
/**
4
 * /src/Security/SecurityUser.php
5
 *
6
 * @author TLe, Tarmo Leppänen <[email protected]>
7
 */
8
9
namespace App\Security;
10
11
use App\Entity\User;
12
use App\Security\Interfaces\SecurityUserInterface;
13
14
/**
15
 * Class SecurityUser
16
 *
17
 * @package App\Security
18
 * @author TLe, Tarmo Leppänen <[email protected]>
19
 */
20
class SecurityUser implements SecurityUserInterface
21
{
22
    private string $username;
23
    private string $password;
24
    private string $language;
25
    private string $locale;
26
    private string $timezone;
27
28
    /**
29
     * @var array<int, string>
30
     */
31
    private array $roles;
32
33
    /**
34
     * SecurityUser constructor.
35
     *
36
     * @param array<int, string> $roles
37
     */
38 299
    public function __construct(User $user, array $roles = [])
39
    {
40 299
        $this->username = $user->getId();
41 299
        $this->password = $user->getPassword();
42 299
        $this->language = $user->getLanguage();
43 299
        $this->locale = $user->getLocale();
44 299
        $this->timezone = $user->getTimezone();
45 299
        $this->roles = $roles;
46 299
    }
47
48 37
    public function getUuid(): string
49
    {
50 37
        return $this->getUsername();
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     *
56
     * @return array<int, string> The user roles
57
     */
58 256
    public function getRoles(): array
59
    {
60 256
        return $this->roles;
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     *
66
     * @codeCoverageIgnore
67
     */
68
    public function getPassword(): string
69
    {
70
        return $this->password;
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     *
76
     * @codeCoverageIgnore
77
     */
78
    public function getSalt(): ?string
79
    {
80
        return null;
81
    }
82
83
    /**
84
     * {@inheritdoc}
85
     *
86
     * @codeCoverageIgnore
87
     */
88
    public function getUsername(): string
89
    {
90
        return $this->username;
91
    }
92
93 24
    public function getLanguage(): string
94
    {
95 24
        return $this->language;
96
    }
97
98 24
    public function getLocale(): string
99
    {
100 24
        return $this->locale;
101
    }
102
103 24
    public function getTimezone(): string
104
    {
105 24
        return $this->timezone;
106
    }
107
108
    /**
109
     * {@inheritdoc}
110
     *
111
     * @codeCoverageIgnore
112
     */
113
    public function eraseCredentials(): void
114
    {
115
    }
116
}
117