IdentityAccreditedAsRaEvent::getAuditLogMetadata()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
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
 */
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
/**
31
 * @deprecated This event is superseded by the IdentityAccreditedAsRaForInstitutionEvent because an RA institution was needed
32
 */
33
class IdentityAccreditedAsRaEvent extends IdentityEvent implements RightToObtainDataInterface
34
{
35
    /**
36
     * @var string[]
37
     */
38
    private array $allowlist = [
39
        'identity_id',
40
        'name_id',
41
        'institution',
42
        'registration_authority_role',
43
        'location',
44
        'contact_information',
45
    ];
46
47
    /**
48
     * @param IdentityId $identityId
49
     * @param NameId $nameId
50
     * @param Institution $institution
51
     * @param RegistrationAuthorityRole $registrationAuthorityRole
52
     * @param Location $location
53
     * @param ContactInformation $contactInformation
54
     */
55
    public function __construct(
56
        IdentityId $identityId,
57
        public NameId $nameId,
58
        Institution $institution,
59
        public RegistrationAuthorityRole $registrationAuthorityRole,
60
        public Location $location,
61
        public ContactInformation $contactInformation,
62
    ) {
63
        parent::__construct($identityId, $institution);
64
    }
65
66
    public function getAuditLogMetadata(): Metadata
67
    {
68
        $metadata = new Metadata();
69
        $metadata->identityId = $this->identityId;
70
        $metadata->identityInstitution = $this->identityInstitution;
71
72
        return $metadata;
73
    }
74
75
    public static function deserialize(array $data): self
76
    {
77
        return new self(
78
            new IdentityId($data['identity_id']),
79
            new NameId($data['name_id']),
80
            new Institution($data['institution']),
81
            RegistrationAuthorityRole::deserialize($data['registration_authority_role']),
82
            new Location($data['location']),
83
            new ContactInformation($data['contact_information']),
84
        );
85
    }
86
87
    public function serialize(): array
88
    {
89
        return [
90
            'identity_id' => (string)$this->identityId,
91
            'name_id' => (string)$this->nameId,
92
            'institution' => (string)$this->identityInstitution,
93
            'registration_authority_role' => $this->registrationAuthorityRole->serialize(),
94
            'location' => (string)$this->location,
95
            'contact_information' => (string)$this->contactInformation,
96
        ];
97
    }
98
99
    public function obtainUserData(): array
100
    {
101
        return $this->serialize();
102
    }
103
104
    /**
105
     * @return string[]
106
     */
107
    public function getAllowlist(): array
108
    {
109
        return $this->allowlist;
110
    }
111
}
112