User::getUsername()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * The MIT License (MIT)
5
 *
6
 * Copyright (c) 2014-2016 Spomky-Labs
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license.  See the LICENSE file for details.
10
 */
11
12
namespace SpomkyLabs\TestRoleHierarchyBundle\Entity;
13
14
use Symfony\Component\Security\Core\User\UserInterface;
15
16
class User implements UserInterface
17
{
18
    private $username;
19
    private $password;
20
    private $salt;
21
    private $roles;
22
23
    public function __construct($username, $password, $salt, array $roles)
24
    {
25
        $this->username = $username;
26
        $this->password = $password;
27
        $this->salt = $salt;
28
        $this->roles = $roles;
29
    }
30
31
    public function getRoles()
32
    {
33
        return $this->roles;
34
    }
35
36
    public function getPassword()
37
    {
38
        return $this->password;
39
    }
40
41
    public function getSalt()
42
    {
43
        return $this->salt;
44
    }
45
46
    public function getUsername()
47
    {
48
        return $this->username;
49
    }
50
51
    public function eraseCredentials()
52
    {
53
    }
54
55
    public function equals(UserInterface $user)
56
    {
57
        if (!$user instanceof self) {
58
            return false;
59
        }
60
61
        if ($this->password !== $user->getPassword()) {
62
            return false;
63
        }
64
65
        if ($this->getSalt() !== $user->getSalt()) {
66
            return false;
67
        }
68
69
        if ($this->username !== $user->getUsername()) {
70
            return false;
71
        }
72
73
        return true;
74
    }
75
}
76