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 invitation token regenerated domain event class. |
21
|
|
|
* |
22
|
|
|
* @author Beñat Espiña <[email protected]> |
23
|
|
|
*/ |
24
|
|
View Code Duplication |
final class UserInvitationTokenRegenerated implements UserEvent |
|
|
|
|
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* The user id. |
28
|
|
|
* |
29
|
|
|
* @var UserId |
30
|
|
|
*/ |
31
|
|
|
private $userId; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* The user email. |
35
|
|
|
* |
36
|
|
|
* @var UserEmail |
37
|
|
|
*/ |
38
|
|
|
private $email; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* The confirmation token. |
42
|
|
|
* |
43
|
|
|
* @var UserToken |
44
|
|
|
*/ |
45
|
|
|
private $invitationToken; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* The occurred on. |
49
|
|
|
* |
50
|
|
|
* @var \DateTimeImmutable |
51
|
|
|
*/ |
52
|
|
|
private $occurredOn; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Constructor. |
56
|
|
|
* |
57
|
|
|
* @param UserId $aUserId The user id |
58
|
|
|
* @param UserEmail $anEmail The email |
59
|
|
|
* @param UserToken $anInvitationToken The invitation token |
60
|
|
|
*/ |
61
|
|
|
public function __construct(UserId $aUserId, UserEmail $anEmail, UserToken $anInvitationToken) |
62
|
|
|
{ |
63
|
|
|
$this->userId = $aUserId; |
64
|
|
|
$this->email = $anEmail; |
65
|
|
|
$this->invitationToken = $anInvitationToken; |
66
|
|
|
$this->occurredOn = new \DateTimeImmutable(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* {@inheritdoc} |
71
|
|
|
*/ |
72
|
|
|
public function id() |
73
|
|
|
{ |
74
|
|
|
return $this->userId; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* {@inheritdoc} |
79
|
|
|
*/ |
80
|
|
|
public function email() |
81
|
|
|
{ |
82
|
|
|
return $this->email; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* {@inheritdoc} |
87
|
|
|
*/ |
88
|
|
|
public function occurredOn() |
89
|
|
|
{ |
90
|
|
|
return $this->occurredOn; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Gets the invitation token. |
95
|
|
|
* |
96
|
|
|
* @return UserToken |
97
|
|
|
*/ |
98
|
|
|
public function invitationToken() |
99
|
|
|
{ |
100
|
|
|
return $this->invitationToken; |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|
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.