Passed
Push — develop ( 710e27...6f29be )
by Stone
03:28
created

User   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 130
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 25
dl 0
loc 130
rs 10
c 0
b 0
f 0
wmc 13

12 Methods

Rating   Name   Duplication   Size   Complexity  
A getPassword() 0 3 1
A eraseCredentials() 0 2 1
A setImage() 0 5 1
A getUsername() 0 3 1
A getSalt() 0 2 1
A setPassword() 0 5 1
A getRoles() 0 7 1
A getEmail() 0 3 1
A getImage() 0 3 1
A setUserName() 0 5 1
A getId() 0 3 1
A setEmail() 0 5 1
1
<?php
2
3
namespace App\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Symfony\Component\Security\Core\User\UserInterface;
7
8
/**
9
 * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
10
 */
11
class User implements UserInterface
12
{
13
    /**
14
     * @ORM\Id()
15
     * @ORM\GeneratedValue()
16
     * @ORM\Column(type="integer")
17
     */
18
    private $id;
19
20
    /**
21
     * @ORM\Column(type="string", length=180, unique=true)
22
     */
23
    private $email;
24
25
    /**
26
     * @ORM\Column(type="json")
27
     */
28
    private $roles = [];
29
30
    /**
31
     * @var string The hashed password
32
     * @ORM\Column(type="string")
33
     */
34
    private $password;
35
36
    /**
37
     * @ORM\Column(type="string", length=255)
38
     */
39
    private $userName;
40
41
    /**
42
     * @ORM\Column(type="string", length=255, nullable=true)
43
     */
44
    private $image;
45
46
    public function getId(): ?int
47
    {
48
        return $this->id;
49
    }
50
51
    public function getEmail(): ?string
52
    {
53
        return $this->email;
54
    }
55
56
    public function setEmail(string $email): self
57
    {
58
        $this->email = $email;
59
60
        return $this;
61
    }
62
63
    /**
64
     * A visual identifier that represents this user.
65
     *
66
     * @see UserInterface
67
     */
68
    public function getUsername(): string
69
    {
70
        return (string) $this->userName;
71
    }
72
73
    /**
74
     * @see UserInterface
75
     */
76
    public function getRoles(): array
77
    {
78
        $roles = $this->roles;
79
        // guarantee every user at least has ROLE_USER
80
        $roles[] = 'ROLE_USER';
81
82
        return array_unique($roles);
83
    }
84
85
    public function setRoles(array $roles): self
86
    {
87
        $this->roles = $roles;
88
89
        return $this;
90
    }
91
92
    /**
93
     * @see UserInterface
94
     */
95
    public function getPassword(): string
96
    {
97
        return (string) $this->password;
98
    }
99
100
    public function setPassword(string $password): self
101
    {
102
        $this->password = $password;
103
104
        return $this;
105
    }
106
107
    /**
108
     * @see UserInterface
109
     */
110
    public function getSalt()
111
    {
112
        // not needed when using the "bcrypt" algorithm in security.yaml
113
    }
114
115
    /**
116
     * @see UserInterface
117
     */
118
    public function eraseCredentials()
119
    {
120
        // If you store any temporary, sensitive data on the user, clear it here
121
        // $this->plainPassword = null;
122
    }
123
124
    public function setUserName(string $userName): self
125
    {
126
        $this->userName = $userName;
127
128
        return $this;
129
    }
130
131
    public function getImage(): ?string
132
    {
133
        return $this->image;
134
    }
135
136
    public function setImage(?string $image): self
137
    {
138
        $this->image = $image;
139
140
        return $this;
141
    }
142
}
143