Passed
Push — bugfix/fix-deprovision-anonymi... ( aa4a6e...ce6ef9 )
by
unknown
04:58
created

SecondFactorRevocationProjector   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A applyIdentityForgottenEvent() 0 2 1
A __construct() 0 2 1
A applyCompliedWithVettedSecondFactorRevocationEvent() 0 12 1
A applyVettedSecondFactorRevokedEvent() 0 12 1
1
<?php
2
3
/**
4
 * Copyright 2014 SURFnet bv
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
 */
0 ignored issues
show
Coding Style introduced by
Missing @link tag in file comment
Loading history...
18
19
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Projector;
20
21
use Broadway\Domain\DomainMessage;
22
use Surfnet\Stepup\Identity\Event\IdentityForgottenEvent;
23
use Surfnet\Stepup\Projector\Projector;
24
use DateTime as CoreDateTime;
25
use Ramsey\Uuid\Uuid;
26
use Surfnet\Stepup\DateTime\DateTime;
27
use Surfnet\Stepup\Identity\Event\CompliedWithVettedSecondFactorRevocationEvent;
28
use Surfnet\Stepup\Identity\Event\VettedSecondFactorRevokedEvent;
29
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\SecondFactorRevocation;
30
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\SecondFactorRevocationRepository;
31
32
class SecondFactorRevocationProjector extends Projector
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class SecondFactorRevocationProjector
Loading history...
33
{
34
    public function __construct(private readonly SecondFactorRevocationRepository $repository)
35
    {
36
    }
37
38
    protected function applyVettedSecondFactorRevokedEvent(
39
        VettedSecondFactorRevokedEvent $event,
40
        DomainMessage $domainMessage,
41
    ): void {
42
        $revocation = new SecondFactorRevocation();
43
        $revocation->id = (string)Uuid::uuid4();
44
        $revocation->institution = $event->identityInstitution;
45
        $revocation->secondFactorType = $event->secondFactorType->getSecondFactorType();
46
        $revocation->revokedBy = 'self';
47
        $revocation->recordedOn = new DateTime(new CoreDateTime($domainMessage->getRecordedOn()->toString()));
48
49
        $this->repository->save($revocation);
50
    }
51
52
    protected function applyCompliedWithVettedSecondFactorRevocationEvent(
53
        CompliedWithVettedSecondFactorRevocationEvent $event,
54
        DomainMessage $domainMessage,
55
    ): void {
56
        $revocation = new SecondFactorRevocation();
57
        $revocation->id = (string)Uuid::uuid4();
58
        $revocation->institution = $event->identityInstitution;
59
        $revocation->secondFactorType = $event->secondFactorType->getSecondFactorType();
60
        $revocation->revokedBy = 'ra';
61
        $revocation->recordedOn = new DateTime(new CoreDateTime($domainMessage->getRecordedOn()->toString()));
62
63
        $this->repository->save($revocation);
64
    }
65
66
    protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
67
    {
68
        // do nothing, no sensitive data in this projection
69
    }
70
}
71