Total Complexity | 5 |
Total Lines | 30 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
23 | class ChangeEmailVerificationEmailFactory extends AbstractUserEmailFactory |
||
24 | { |
||
25 | 3 | public function create(AbstractUser $user, array $context = []): ?RawMessage |
|
26 | { |
||
27 | 3 | if (!$this->enabled) { |
|
28 | 1 | return null; |
|
29 | } |
||
30 | |||
31 | 2 | $this->initUser($user); |
|
32 | |||
33 | 2 | $token = $user->getNewEmailVerificationToken(); |
|
34 | 2 | if (!$token) { |
|
35 | 1 | throw new InvalidArgumentException('A `new email verification token` must be set to send the verification email'); |
|
36 | } |
||
37 | |||
38 | 1 | $context['redirect_url'] = $this->getTokenUrl($token, $user->getUsername()); |
|
|
|||
39 | |||
40 | 1 | return $this->createEmailMessage($context); |
|
41 | } |
||
42 | |||
43 | 1 | protected static function getRequiredContextKeys(): ?array |
|
44 | { |
||
45 | 1 | return array_merge(parent::getRequiredContextKeys(), [ |
|
46 | 1 | 'redirect_url', |
|
47 | ]); |
||
48 | } |
||
49 | |||
50 | 1 | protected function getTemplate(): string |
|
53 | } |
||
54 | } |
||
55 |