RedmineUser::eraseCredentials()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * File part of the Redmine User Provider bundle
4
 *
5
 * @category  SymfonyBundle
6
 * @package   GMaissa.RedmineUserProviderBundle
7
 * @author    Guillaume Maïssa <[email protected]>
8
 * @copyright 2017 Guillaume Maïssa
9
 * @license   https://opensource.org/licenses/MIT The MIT License (MIT)
10
 */
11
12
namespace GMaissa\RedmineUserProviderBundle\Model;
13
14
use Symfony\Component\Security\Core\User\UserInterface;
15
16
/**
17
 * User Model Class
18
 */
19
class RedmineUser implements UserInterface
20
{
21
    const ROLE_DEFAULT     = 'ROLE_USER';
22
23
    /**
24
     * @var integer
25
     */
26
    protected $id;
27
28
    /**
29
     * @var string
30
     */
31
    protected $firstname;
32
33
    /**
34
     * @var string
35
     */
36
    protected $lastname;
37
38
    /**
39
     * @var string
40
     */
41
    protected $email;
42
43
    /**
44
     * @var string
45
     */
46
    protected $username;
47
48
    /**
49
     * @var string
50
     */
51
    protected $password;
52
53
    /**
54
     * @var array
55
     */
56
    protected $roles;
57
58
    /**
59
     * @var bool
60
     */
61
    protected $enabled;
62
63
    /**
64
     * @var string
65
     */
66
    protected $salt;
67
68
    /**
69
     * User constructor
70
     *
71
     * @param array $properties
72
     */
73 6
    public function __construct($properties = array())
74
    {
75 6
        $this->roles = [];
76 6
        foreach ($properties as $key => $value) {
77 6
            $this->$key = $value;
78
        }
79 6
    }
80
81
    /**
82
     * {@inheritdoc}
83
     */
84 4
    public function getRoles()
85
    {
86 4
        $roles = $this->roles;
87
88 4
        if (count($roles) == 0) {
89 3
            $roles[] = self::ROLE_DEFAULT;
90
        }
91
92 4
        return $roles;
93
    }
94
95
    /**
96
     * {@inheritdoc}
97
     */
98 4
    public function getSalt()
99
    {
100 4
        return $this->salt;
101
    }
102
103
    /**
104
     * {@inheritdoc}
105
     */
106 4
    public function getPassword()
107
    {
108 4
        return $this->password;
109
    }
110
111
    /**
112
     * {@inheritdoc}
113
     */
114 4
    public function getUsername()
115
    {
116 4
        return $this->username;
117
    }
118
119
    /**
120
     * {@inheritdoc}
121
     */
122 2
    public function eraseCredentials()
123
    {
124 2
        $this->password = null;
125 2
    }
126
}
127