serialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

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