1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the BenGorUser package. |
5
|
|
|
* |
6
|
|
|
* (c) Beñat Espiña <[email protected]> |
7
|
|
|
* (c) Gorka Laucirica <[email protected]> |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
10
|
|
|
* file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace BenGorUser\User\Domain\Model\Event; |
14
|
|
|
|
15
|
|
|
use BenGorUser\User\Domain\Model\UserEmail; |
16
|
|
|
use BenGorUser\User\Domain\Model\UserId; |
17
|
|
|
use BenGorUser\User\Domain\Model\UserToken; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* User remember password request domain event class. |
21
|
|
|
* |
22
|
|
|
* @author Beñat Espiña <[email protected]> |
23
|
|
|
* @author Gorka Laucirica <[email protected]> |
24
|
|
|
*/ |
25
|
|
View Code Duplication |
final class UserRememberPasswordRequested implements UserEvent |
|
|
|
|
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* The user id. |
29
|
|
|
* |
30
|
|
|
* @var UserId |
31
|
|
|
*/ |
32
|
|
|
private $userId; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* The email. |
36
|
|
|
* |
37
|
|
|
* @var UserEmail |
38
|
|
|
*/ |
39
|
|
|
private $email; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* The occurred on. |
43
|
|
|
* |
44
|
|
|
* @var \DateTimeImmutable |
45
|
|
|
*/ |
46
|
|
|
private $occurredOn; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* The remember password token. |
50
|
|
|
* |
51
|
|
|
* @var UserToken |
52
|
|
|
*/ |
53
|
|
|
private $rememberPasswordToken; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Constructor. |
57
|
|
|
* |
58
|
|
|
* @param UserId $aUserId The user id |
59
|
|
|
* @param UserEmail $anEmail The email |
60
|
|
|
* @param UserToken $aRememberPasswordToken The remember password token |
61
|
|
|
*/ |
62
|
|
|
public function __construct(UserId $aUserId, UserEmail $anEmail, UserToken $aRememberPasswordToken) |
63
|
|
|
{ |
64
|
|
|
$this->userId = $aUserId; |
65
|
|
|
$this->email = $anEmail; |
66
|
|
|
$this->rememberPasswordToken = $aRememberPasswordToken; |
67
|
|
|
$this->occurredOn = new \DateTimeImmutable(); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* {@inheritdoc} |
72
|
|
|
*/ |
73
|
|
|
public function id() |
74
|
|
|
{ |
75
|
|
|
return $this->userId; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* {@inheritdoc} |
80
|
|
|
*/ |
81
|
|
|
public function email() |
82
|
|
|
{ |
83
|
|
|
return $this->email; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* {@inheritdoc} |
88
|
|
|
*/ |
89
|
|
|
public function occurredOn() |
90
|
|
|
{ |
91
|
|
|
return $this->occurredOn; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Gets the remember password token. |
96
|
|
|
* |
97
|
|
|
* @return UserToken |
98
|
|
|
*/ |
99
|
|
|
public function rememberPasswordToken() |
100
|
|
|
{ |
101
|
|
|
return $this->rememberPasswordToken; |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|
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.