IdentityAccreditedAsRaaForInstitutionEvent   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 33
dl 0
loc 85
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getAuditLogMetadata() 0 8 1
A deserialize() 0 10 1
A serialize() 0 10 1
A __construct() 0 10 1
A getAllowlist() 0 3 1
A obtainUserData() 0 3 1
1
<?php
2
3
/**
4
 * Copyright 2018 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
 */
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\Stepup\Identity\Value\RegistrationAuthorityRole;
0 ignored issues
show
Bug introduced by
The type Surfnet\Stepup\Identity\...gistrationAuthorityRole was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
28
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\RightToObtainDataInterface;
29
30
class IdentityAccreditedAsRaaForInstitutionEvent extends IdentityEvent implements RightToObtainDataInterface
31
{
32
    /** @var string[] */
33
    /**
34
     * @var string[]
35
     */
36
    private array $allowlist = [
37
        'identity_id',
38
        'name_id',
39
        'institution',
40
        'registration_authority_role',
41
        'location',
42
        'contact_information',
43
        'ra_institution',
44
    ];
45
46
    public function __construct(
47
        IdentityId $identityId,
48
        public NameId $nameId,
49
        Institution $institution,
50
        public RegistrationAuthorityRole $registrationAuthorityRole,
51
        public Location $location,
52
        public ContactInformation $contactInformation,
53
        public Institution $raInstitution,
54
    ) {
55
        parent::__construct($identityId, $institution);
56
    }
57
58
    public function getAuditLogMetadata(): Metadata
59
    {
60
        $metadata = new Metadata();
61
        $metadata->identityId = $this->identityId;
62
        $metadata->identityInstitution = $this->identityInstitution;
63
        $metadata->raInstitution = $this->raInstitution;
64
65
        return $metadata;
66
    }
67
68
    /**
69
     * @param array<string, mixed> $data
70
     */
71
    public static function deserialize(array $data): self
72
    {
73
        return new self(
74
            new IdentityId($data['identity_id']),
75
            new NameId($data['name_id']),
76
            new Institution($data['institution']),
77
            RegistrationAuthorityRole::deserialize($data['registration_authority_role']),
78
            new Location($data['location']),
79
            new ContactInformation($data['contact_information']),
80
            new Institution($data['ra_institution']),
81
        );
82
    }
83
84
    /**
85
     * The data ending up in the event_stream, be careful not to include sensitive data here!
86
     * @return array<string, mixed>
87
     */
88
    public function serialize(): array
89
    {
90
        return [
91
            'identity_id' => (string)$this->identityId,
92
            'name_id' => (string)$this->nameId,
93
            'institution' => (string)$this->identityInstitution,
94
            'registration_authority_role' => $this->registrationAuthorityRole->serialize(),
95
            'location' => (string)$this->location,
96
            'contact_information' => (string)$this->contactInformation,
97
            'ra_institution' => (string)$this->raInstitution,
98
        ];
99
    }
100
101
    /**
102
     * @return array<string, mixed>
103
     */
104
    public function obtainUserData(): array
105
    {
106
        return $this->serialize();
107
    }
108
109
    /**
110
     * @return string[]
111
     */
112
    public function getAllowlist(): array
113
    {
114
        return $this->allowlist;
115
    }
116
}
117