Completed
Pull Request — master (#15)
by Oguzhan
02:25
created

User::__construct()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 10
nc 2
nop 7
1
<?php
2
namespace KleijnWeb\JwtBundle\Tests\Classes;
3
4
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
5
6
/**
7
 * User is the user implementation used by the in-memory user provider.
8
 *
9
 * This should not be used for anything else.
10
 *
11
 * @author Fabien Potencier <[email protected]>
12
 */
13
final class User implements AdvancedUserInterface
14
{
15
    private $username;
16
    private $password;
17
    private $enabled;
18
    private $accountNonExpired;
19
    private $credentialsNonExpired;
20
    private $accountNonLocked;
21
    private $roles;
22
23
    public function __construct($username, $password, array $roles = array(), $enabled = true, $userNonExpired = true, $credentialsNonExpired = true, $userNonLocked = true)
24
    {
25
        if ('' === $username || null === $username) {
26
            throw new \InvalidArgumentException('The username cannot be empty.');
27
        }
28
29
        $this->username = $username;
30
        $this->password = $password;
31
        $this->enabled = $enabled;
32
        $this->accountNonExpired = $userNonExpired;
33
        $this->credentialsNonExpired = $credentialsNonExpired;
34
        $this->accountNonLocked = $userNonLocked;
35
        $this->roles = $roles;
36
    }
37
38
    public function __toString()
39
    {
40
        return $this->getUsername();
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function getRoles()
47
    {
48
        return $this->roles;
49
    }
50
51
    /**
52
     * @param $role
53
     */
54
    public function addRole($role)
55
    {
56
        $this->roles[] = $role;
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62
    public function getPassword()
63
    {
64
        return $this->password;
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    public function getSalt()
71
    {
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77
    public function getUsername()
78
    {
79
        return $this->username;
80
    }
81
82
    /**
83
     * {@inheritdoc}
84
     */
85
    public function isAccountNonExpired()
86
    {
87
        return $this->accountNonExpired;
88
    }
89
90
    /**
91
     * {@inheritdoc}
92
     */
93
    public function isAccountNonLocked()
94
    {
95
        return $this->accountNonLocked;
96
    }
97
98
    /**
99
     * {@inheritdoc}
100
     */
101
    public function isCredentialsNonExpired()
102
    {
103
        return $this->credentialsNonExpired;
104
    }
105
106
    /**
107
     * {@inheritdoc}
108
     */
109
    public function isEnabled()
110
    {
111
        return $this->enabled;
112
    }
113
114
    /**
115
     * {@inheritdoc}
116
     */
117
    public function eraseCredentials()
118
    {
119
    }
120
}
121