AppointedAsRaaEvent::getAllowlist()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
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\IdentityId;
23
use Surfnet\Stepup\Identity\Value\Institution;
24
use Surfnet\Stepup\Identity\Value\NameId;
25
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\RightToObtainDataInterface;
26
27
/**
28
 * @deprecated This event is superseded by the AppointedAsRaaForInstitutionEvent because an RA institution was needed
29
 */
30
class AppointedAsRaaEvent extends IdentityEvent implements RightToObtainDataInterface
31
{
32
    /**
33
     * @var string[]
34
     */
35
    private array $allowlist = [
36
        'identity_id',
37
        'institution',
38
        'name_id',
39
    ];
40
41
    public function __construct(
42
        IdentityId $identityId,
43
        Institution $identityInstitution,
44
        public NameId $nameId,
45
    ) {
46
        parent::__construct($identityId, $identityInstitution);
47
    }
48
49
    public function getAuditLogMetadata(): Metadata
50
    {
51
        $metadata = new Metadata();
52
        $metadata->identityId = $this->identityId;
53
        $metadata->identityInstitution = $this->identityInstitution;
54
55
        return $metadata;
56
    }
57
58
    public static function deserialize(array $data): self
59
    {
60
        return new self(
61
            new IdentityId($data['identity_id']),
62
            new Institution($data['institution']),
63
            new NameId($data['name_id']),
64
        );
65
    }
66
67
    public function serialize(): array
68
    {
69
        return [
70
            'identity_id' => (string)$this->identityId,
71
            'institution' => (string)$this->identityInstitution,
72
            'name_id' => (string)$this->nameId,
73
        ];
74
    }
75
76
    public function obtainUserData(): array
77
    {
78
        return $this->serialize();
79
    }
80
81
    /**
82
     * @return string[]
83
     */
84
    public function getAllowlist(): array
85
    {
86
        return $this->allowlist;
87
    }
88
}
89