1 | <?php |
||
15 | class ConfirmationToken |
||
16 | { |
||
17 | const TYPE_CONFIRM_EMAIL = 'confirm_email'; |
||
18 | const TYPE_PASSWORD_RECOVERY = 'password_recovery'; |
||
19 | |||
20 | /** |
||
21 | * @ORM\Id() |
||
22 | * @ORM\GeneratedValue() |
||
23 | * @ORM\Column(type="integer") |
||
24 | */ |
||
25 | private $id; |
||
26 | |||
27 | /** |
||
28 | * @var User |
||
29 | * @ORM\ManyToOne(targetEntity="App\Users\Entity\User") |
||
30 | */ |
||
31 | private $user; |
||
32 | |||
33 | /** |
||
34 | * @ORM\Column(type="string", length=32, unique=true) |
||
35 | */ |
||
36 | private $token; |
||
37 | |||
38 | /** |
||
39 | * @ORM\Column(type="string", length=256) |
||
40 | */ |
||
41 | private $type; |
||
42 | |||
43 | /** |
||
44 | * @ORM\Column(type="datetime", nullable=true) |
||
45 | * |
||
46 | * @var \DateTimeImmutable|\DateTimeInterface |
||
47 | */ |
||
48 | private $expires_at; |
||
49 | |||
50 | /** |
||
51 | * ConfirmationToken constructor. |
||
52 | * |
||
53 | * @param \App\Users\Entity\User $user |
||
54 | * @param $type |
||
55 | * @param \DateTimeInterface|null $expires_at |
||
56 | * |
||
57 | * @throws \Exception |
||
58 | */ |
||
59 | 9 | public function __construct(User $user, $type, \DateTimeInterface $expires_at = null) |
|
77 | |||
78 | 9 | public function getValidTypes(): array |
|
82 | |||
83 | /** |
||
84 | * @return mixed |
||
85 | */ |
||
86 | public function getId() |
||
90 | |||
91 | /** |
||
92 | * @return User |
||
93 | */ |
||
94 | 2 | public function getUser(): User |
|
98 | |||
99 | /** |
||
100 | * @return mixed |
||
101 | */ |
||
102 | 4 | public function getToken() |
|
106 | |||
107 | /** |
||
108 | * @return mixed |
||
109 | */ |
||
110 | public function getType() |
||
114 | |||
115 | /** |
||
116 | * @throws \Exception |
||
117 | * |
||
118 | * @return bool |
||
119 | */ |
||
120 | 2 | public function isValid(): bool |
|
130 | } |
||
131 |