Completed
Pull Request — master (#12)
by
unknown
02:47
created

User::generatePasswordResetToken()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace SumoCoders\FrameworkMultiUserBundle\User;
4
5
use SumoCoders\FrameworkMultiUserBundle\Security\PasswordResetToken;
6
7
class User implements UserInterface, PasswordReset
8
{
9
    /** @var string */
10
    private $username;
11
12
    /** @var string */
13
    private $password;
14
15
    /** @var string */
16
    private $displayName;
17
18
    /** @var */
19
    private $passwordResetToken;
20
21
    /** @var */
22
    private $email;
23
24
    /**
25
     * @param string $username
26
     * @param string $password
27
     * @param string $displayName
28
     */
29 View Code Duplication
    public function __construct($username, $password, $displayName, $email)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
    {
31
        $this->username = $username;
32
        $this->password = $password;
33
        $this->displayName = $displayName;
34
        $this->email = $email;
35
    }
36
37
    /**
38
     * {@inheritDoc}
39
     */
40
    public function getRoles()
41
    {
42
        return [ 'ROLE_USER' ];
43
    }
44
45
    /**
46
     * {@inheritDoc}
47
     */
48
    public function getPassword()
49
    {
50
        return $this->password;
51
    }
52
53
    /**
54
     * {@inheritDoc}
55
     */
56
    public function getSalt()
57
    {
58
        return;
59
    }
60
61
    /**
62
     * {@inheritDoc}
63
     */
64
    public function getUsername()
65
    {
66
        return $this->username;
67
    }
68
69
    /**
70
     * {@inheritDoc}
71
     */
72
    public function eraseCredentials()
73
    {
74
        return;
75
    }
76
77
    /**
78
     * {@inheritDoc}
79
     */
80
    public function getDisplayName()
81
    {
82
        return $this->displayName;
83
    }
84
85
    /**
86
     * {@inheritDoc}
87
     */
88
    public function __toString()
89
    {
90
        return $this->getDisplayName();
91
    }
92
93
    /**
94
     * {@inheritdoc}
95
     */
96
    public function clearPasswordResetToken()
97
    {
98
        $this->passwordResetToken = null;
99
100
        return $this;
101
    }
102
103
    /**
104
     * @return self
105
     */
106
    public function generatePasswordResetToken()
107
    {
108
        $token = PasswordResetToken::generate();
109
        $this->passwordResetToken = $token->getToken();
110
111
        return $this;
112
    }
113
114
    /**
115
     * @return string
116
     */
117
    public function getPasswordResetToken()
118
    {
119
        return $this->passwordResetToken;
120
    }
121
122
    /**
123
     * @return string
124
     */
125
    public function getEmail()
126
    {
127
        return $this->email;
128
    }
129
130
    /**
131
     * @param $email
132
     *
133
     * @return self
134
     */
135
    public function setEmail($email)
136
    {
137
        $this->email = $email;
138
139
        return $this;
140
    }
141
142
    /**
143
     * @param $password
144
     *
145
     * @return self
146
     */
147
    public function setPassword($password)
148
    {
149
        $this->password = $password;
150
151
        return $this;
152
    }
153
}
154