RedmineUser   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 108
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 8
c 1
b 1
f 0
lcom 2
cbo 0
dl 0
loc 108
ccs 19
cts 19
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A getRoles() 0 10 2
A getSalt() 0 4 1
A getPassword() 0 4 1
A getUsername() 0 4 1
A eraseCredentials() 0 4 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