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; |
28
|
|
|
|
29
|
|
View Code Duplication |
class IdentityAccreditedAsRaForInstitutionEvent extends IdentityEvent |
|
|
|
|
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* @var NameId |
33
|
|
|
*/ |
34
|
|
|
public $nameId; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var RegistrationAuthorityRole |
38
|
|
|
*/ |
39
|
|
|
public $registrationAuthorityRole; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var Location |
43
|
|
|
*/ |
44
|
|
|
public $location; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var ContactInformation |
48
|
|
|
*/ |
49
|
|
|
public $contactInformation; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var Institution |
53
|
|
|
*/ |
54
|
|
|
public $raInstitution; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param IdentityId $identityId |
58
|
|
|
* @param NameId $nameId |
59
|
|
|
* @param Institution $institution |
60
|
|
|
* @param RegistrationAuthorityRole $role |
61
|
|
|
* @param Location $location |
62
|
|
|
* @param ContactInformation $contactInformation |
63
|
|
|
* @param Institution $raInstitution |
64
|
|
|
*/ |
65
|
|
|
public function __construct( |
66
|
|
|
IdentityId $identityId, |
67
|
|
|
NameId $nameId, |
68
|
|
|
Institution $institution, |
69
|
|
|
RegistrationAuthorityRole $role, |
70
|
|
|
Location $location, |
71
|
|
|
ContactInformation $contactInformation, |
72
|
|
|
Institution $raInstitution |
73
|
|
|
) { |
74
|
|
|
parent::__construct($identityId, $institution); |
75
|
|
|
|
76
|
|
|
$this->nameId = $nameId; |
77
|
|
|
$this->registrationAuthorityRole = $role; |
78
|
|
|
$this->location = $location; |
79
|
|
|
$this->contactInformation = $contactInformation; |
80
|
|
|
$this->raInstitution = $raInstitution; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function getAuditLogMetadata() |
84
|
|
|
{ |
85
|
|
|
$metadata = new Metadata(); |
86
|
|
|
$metadata->identityId = $this->identityId; |
87
|
|
|
$metadata->identityInstitution = $this->identityInstitution; |
88
|
|
|
|
89
|
|
|
return $metadata; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public static function deserialize(array $data) |
93
|
|
|
{ |
94
|
|
|
return new self( |
95
|
|
|
new IdentityId($data['identity_id']), |
96
|
|
|
new NameId($data['name_id']), |
97
|
|
|
new Institution($data['institution']), |
98
|
|
|
RegistrationAuthorityRole::deserialize($data['registration_authority_role']), |
99
|
|
|
new Location($data['location']), |
100
|
|
|
new ContactInformation($data['contact_information']), |
101
|
|
|
new Institution($data['ra_institution']) |
102
|
|
|
); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function serialize() |
106
|
|
|
{ |
107
|
|
|
return [ |
108
|
|
|
'identity_id' => (string) $this->identityId, |
109
|
|
|
'name_id' => (string) $this->nameId, |
110
|
|
|
'institution' => (string) $this->identityInstitution, |
111
|
|
|
'registration_authority_role' => $this->registrationAuthorityRole->serialize(), |
112
|
|
|
'location' => (string) $this->location, |
113
|
|
|
'contact_information' => (string) $this->contactInformation, |
114
|
|
|
'ra_institution' => (string) $this->raInstitution, |
115
|
|
|
]; |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.