RegistrationAuthorityInformationAmendedEvent   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 26
dl 0
loc 72
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A serialize() 0 8 1
A deserialize() 0 8 1
A getAllowlist() 0 3 1
A __construct() 0 8 1
A obtainUserData() 0 3 1
A getAuditLogMetadata() 0 7 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\Stepup\Identity\Event;
20
21
use Surfnet\Stepup\Identity\AuditLog\Metadata;
22
use Surfnet\Stepup\Identity\Value\ContactInformation;
23
use Surfnet\Stepup\Identity\Value\IdentityId;
24
use Surfnet\Stepup\Identity\Value\Institution;
25
use Surfnet\Stepup\Identity\Value\Location;
26
use Surfnet\Stepup\Identity\Value\NameId;
27
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\RightToObtainDataInterface;
28
29
/**
30
 * @deprecated This event is superseded by the RegistrationAuthorityInformationAmendedEvent because an RA institution was needed
31
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
32
class RegistrationAuthorityInformationAmendedEvent extends IdentityEvent implements RightToObtainDataInterface
33
{
34
    /**
35
     * @var string[]
36
     */
37
    private array $allowlist = [
38
        'identity_id',
39
        'name_id',
40
        'institution',
41
        'location',
42
        'contact_information',
43
    ];
44
45
    /**
46
     * @param IdentityId $identityId
0 ignored issues
show
Coding Style introduced by
Expected 9 spaces after parameter type; 1 found
Loading history...
47
     * @param Institution $institution
0 ignored issues
show
Coding Style introduced by
Expected 8 spaces after parameter type; 1 found
Loading history...
48
     * @param NameId $nameId
0 ignored issues
show
Coding Style introduced by
Expected 13 spaces after parameter type; 1 found
Loading history...
49
     * @param Location $location
0 ignored issues
show
Coding Style introduced by
Expected 11 spaces after parameter type; 1 found
Loading history...
50
     * @param ContactInformation $contactInformation
51
     */
52
    public function __construct(
53
        IdentityId $identityId,
54
        Institution $institution,
55
        public NameId $nameId,
56
        public Location $location,
57
        public ContactInformation $contactInformation,
58
    ) {
59
        parent::__construct($identityId, $institution);
60
    }
61
62
    public function getAuditLogMetadata(): Metadata
63
    {
64
        $metadata = new Metadata();
65
        $metadata->identityId = $this->identityId;
66
        $metadata->identityInstitution = $this->identityInstitution;
67
68
        return $metadata;
69
    }
70
71
    public static function deserialize(array $data): self
72
    {
73
        return new self(
74
            new IdentityId($data['identity_id']),
75
            new Institution($data['institution']),
76
            new NameId($data['name_id']),
77
            new Location($data['location']),
78
            new ContactInformation($data['contact_information']),
79
        );
80
    }
81
82
    public function serialize(): array
83
    {
84
        return [
85
            'identity_id' => (string)$this->identityId,
86
            'institution' => (string)$this->identityInstitution,
87
            'name_id' => (string)$this->nameId,
88
            'location' => (string)$this->location,
89
            'contact_information' => (string)$this->contactInformation,
90
        ];
91
    }
92
93
    public function obtainUserData(): array
94
    {
95
        return $this->serialize();
96
    }
97
98
    /**
99
     * @return string[]
100
     */
101
    public function getAllowlist(): array
102
    {
103
        return $this->allowlist;
104
    }
105
}
106