Completed
Push — feature/evo-2472-whoami ( c50209...9b4500 )
by Jan
30:40
created

SecurityConsultant   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 0
loc 87
rs 10
c 1
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getRoles() 0 4 1
A getPassword() 0 4 1
A getSalt() 0 4 1
A getUsername() 0 4 1
A eraseCredentials() 0 3 1
A getConsultant() 0 4 1
1
<?php
2
/**
3
 * security consultant entity
4
 */
5
6
namespace Graviton\SecurityBundle\Entities;
7
8
use GravitonDyn\ConsultantBundle\Document\Consultant;
9
use Symfony\Component\Security\Core\Role\Role;
10
use Symfony\Component\Security\Core\User\UserInterface;
11
12
/**
13
 * Class SecurityConsultant
14
 *
15
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
16
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
17
 * @link     http://swisscom.ch
18
 */
19
class SecurityConsultant implements UserInterface
20
{
21
    /**
22
     * @var Contract
23
     */
24
    private $consultant;
25
26
    /**
27
     * @var Role[]
28
     */
29
    private $roles;
30
31
32
    /**
33
     * Constructor of the class.
34
     *
35
     * @param Contract $consultant contract
36
     * @param Role[]   $roles    roles for the contract
37
     */
38
    public function __construct(Consultant $consultant, array $roles = array())
39
    {
40
        $this->consultant = $consultant;
0 ignored issues
show
Documentation Bug introduced by
It seems like $consultant of type object<GravitonDyn\Consu...le\Document\Consultant> is incompatible with the declared type object<Graviton\SecurityBundle\Entities\Contract> of property $consultant.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
41
        $this->roles = $roles;
42
    }
43
44
    /**
45
     * Returns the roles granted to the user.
46
     *
47
     * @return Role[] The user roles
48
     */
49
    public function getRoles()
50
    {
51
        return $this->roles;
52
    }
53
54
    /**
55
     * Returns the password used to authenticate the user.
56
     *
57
     * @return string The password
58
     */
59
    public function getPassword()
60
    {
61
        return '';
62
    }
63
64
    /**
65
     * Returns the salt that was originally used to encode the password.
66
     *
67
     * @return null The salt
68
     */
69
    public function getSalt()
70
    {
71
        return null;
72
    }
73
74
    /**
75
     * Returns the username used to authenticate the user.
76
     *
77
     * @return string The username
78
     */
79
    public function getUsername()
80
    {
81
        return $this->consultant->getUsername();
82
    }
83
84
    /**
85
     * Removes sensitive data from the user.
86
     *
87
     * This is important if, at any given point, sensitive information like
88
     * the plain-text password is stored on this object.
89
     *
90
     * @return void
91
     */
92
    public function eraseCredentials()
93
    {
94
    }
95
96
    /**
97
     * Provides the consultant object.
98
     *
99
     * @return Contract
100
     */
101
    public function getConsultant()
102
    {
103
        return $this->consultant;
104
    }
105
}
106