Completed
Pull Request — master (#12)
by Cesar
04:47
created

User   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Importance

Changes 0
Metric Value
wmc 8
lcom 2
cbo 0
dl 0
loc 83
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getEmail() 0 4 1
A setEmail() 0 6 1
A getUsername() 0 4 1
A getRoles() 0 7 1
A setRoles() 0 6 1
A getPassword() 0 4 1
A getSalt() 0 4 1
A eraseCredentials() 0 4 1
1
<?php
2
3
namespace App\Security;
4
5
use Symfony\Component\Security\Core\User\UserInterface;
6
7
/**
8
 * Class User
9
 * @package App\Security
10
 */
11
class User implements UserInterface
12
{
13
    /**
14
     * @var string
15
     */
16
    private $email;
17
18
    /**
19
     * @var string[]
20
     */
21
    private $roles = [];
22
23
    /**
24
     * @return string|null
25
     */
26
    public function getEmail(): ?string
27
    {
28
        return $this->email;
29
    }
30
31
    /**
32
     * @param string $email
33
     * @return $this
34
     */
35
    public function setEmail(string $email): self
36
    {
37
        $this->email = $email;
38
39
        return $this;
40
    }
41
42
    /**
43
     * A visual identifier that represents this user.
44
     *
45
     * @see UserInterface
46
     */
47
    public function getUsername(): string
48
    {
49
        return (string) $this->email;
50
    }
51
52
    /**
53
     * @see UserInterface
54
     */
55
    public function getRoles(): array
56
    {
57
        $roles = $this->roles;
58
        $roles[] = 'ROLE_USER';
59
60
        return array_unique($roles);
61
    }
62
63
    public function setRoles(array $roles): self
64
    {
65
        $this->roles = $roles;
66
67
        return $this;
68
    }
69
70
    /**
71
     * @see UserInterface
72
     */
73
    public function getPassword()
74
    {
75
        // not needed for apps that do not check user passwords
76
    }
77
78
    /**
79
     * @see UserInterface
80
     */
81
    public function getSalt()
82
    {
83
        // not needed for apps that do not check user passwords
84
    }
85
86
    /**
87
     * @see UserInterface
88
     */
89
    public function eraseCredentials()
90
    {
91
        // If you store any temporary, sensitive data on the user, clear it here
92
    }
93
}
94