EmailVerificationEmailProcessor   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 7

4 Methods

Rating   Name   Duplication   Size   Complexity  
A handleYubikeyPossessionProvenEvent() 0 8 2
A __construct() 0 3 1
A handlePhonePossessionProvenEvent() 0 8 2
A handleGssfPossessionProvenEvent() 0 8 2
1
<?php
2
3
/**
4
 * Copyright 2016 SURFnet B.V.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Processor;
20
21
use Broadway\Processor\Processor;
22
use Surfnet\Stepup\Identity\Event\GssfPossessionProvenEvent;
23
use Surfnet\Stepup\Identity\Event\PhonePossessionProvenEvent;
24
use Surfnet\Stepup\Identity\Event\YubikeyPossessionProvenEvent;
25
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service\EmailVerificationMailService;
26
27
final class EmailVerificationEmailProcessor extends Processor
28
{
29
    public function __construct(
30
        private readonly EmailVerificationMailService $emailVerificationMailService,
31
    ) {
32
    }
33
34
    public function handlePhonePossessionProvenEvent(PhonePossessionProvenEvent $event): void
35
    {
36
        if ($event->emailVerificationRequired) {
37
            $this->emailVerificationMailService->sendEmailVerificationEmail(
38
                (string)$event->preferredLocale,
39
                (string)$event->commonName,
40
                (string)$event->email,
41
                $event->emailVerificationNonce,
42
            );
43
        }
44
    }
45
46
    public function handleYubikeyPossessionProvenEvent(YubikeyPossessionProvenEvent $event): void
47
    {
48
        if ($event->emailVerificationRequired) {
49
            $this->emailVerificationMailService->sendEmailVerificationEmail(
50
                (string)$event->preferredLocale,
51
                (string)$event->commonName,
52
                (string)$event->email,
53
                $event->emailVerificationNonce,
54
            );
55
        }
56
    }
57
58
    public function handleGssfPossessionProvenEvent(GssfPossessionProvenEvent $event): void
59
    {
60
        if ($event->emailVerificationRequired) {
61
            $this->emailVerificationMailService->sendEmailVerificationEmail(
62
                (string)$event->preferredLocale,
63
                (string)$event->commonName,
64
                (string)$event->email,
65
                $event->emailVerificationNonce,
66
            );
67
        }
68
    }
69
}
70