User   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 13
c 2
b 1
f 0
dl 0
loc 89
rs 10
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getUsername() 0 3 1
A getSalt() 0 2 1
A getRoles() 0 6 1
A setEmail() 0 5 1
A eraseCredentials() 0 2 1
A getEmail() 0 3 1
A setRoles() 0 5 1
A __construct() 0 3 1
A getPassword() 0 2 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
     * User constructor.
25
     * @param string|null $email
26
     */
27
    public function __construct(string $email = null)
28
    {
29
        $this->email = $email;
30
    }
31
32
    /**
33
     * @return string|null
34
     */
35
    public function getEmail(): ?string
36
    {
37
        return $this->email;
38
    }
39
40
    /**
41
     * @param string $email
42
     * @return $this
43
     */
44
    public function setEmail(string $email): self
45
    {
46
        $this->email = $email;
47
48
        return $this;
49
    }
50
51
    /**
52
     * A visual identifier that represents this user.
53
     *
54
     * @see UserInterface
55
     */
56
    public function getUsername(): string
57
    {
58
        return (string) $this->email;
59
    }
60
61
    /**
62
     * @see UserInterface
63
     */
64
    public function getRoles(): array
65
    {
66
        $roles = $this->roles;
67
        $roles[] = 'ROLE_USER';
68
69
        return array_unique($roles);
70
    }
71
72
    public function setRoles(array $roles): self
73
    {
74
        $this->roles = $roles;
75
76
        return $this;
77
    }
78
79
    /**
80
     * @see UserInterface
81
     */
82
    public function getPassword()
83
    {
84
        // not needed for apps that do not check user passwords
85
    }
86
87
    /**
88
     * @see UserInterface
89
     */
90
    public function getSalt()
91
    {
92
        // not needed for apps that do not check user passwords
93
    }
94
95
    /**
96
     * @see UserInterface
97
     */
98
    public function eraseCredentials()
99
    {
100
        // If you store any temporary, sensitive data on the user, clear it here
101
    }
102
}
103