Completed
Pull Request — feature/fine-grained-authoriza... (#246)
by
unknown
56:03 queued 45:22
created

__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17

Duplication

Lines 17
Ratio 100 %

Importance

Changes 0
Metric Value
dl 17
loc 17
rs 9.7
c 0
b 0
f 0
cc 1
nc 1
nop 7
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 IdentityAccreditedAsRaaForInstitutionEvent extends IdentityEvent
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

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.

Loading history...
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
     * @var Institution
52
     */
53
    public $raInstitution;
54
55
    /**
56
     * @param IdentityId $identityId
57
     * @param NameId $nameId
58
     * @param Institution $institution
59
     * @param RegistrationAuthorityRole $role
60
     * @param Location $location
61
     * @param ContactInformation $contactInformation
62
     * @param Institution $raInstitution
63
     */
64
    public function __construct(
65
        IdentityId $identityId,
66
        NameId $nameId,
67
        Institution $institution,
68
        RegistrationAuthorityRole $role,
69
        Location $location,
70
        ContactInformation $contactInformation,
71
        Institution $raInstitution
72
    ) {
73
        parent::__construct($identityId, $institution);
74
75
        $this->nameId                    = $nameId;
76
        $this->registrationAuthorityRole = $role;
77
        $this->location                  = $location;
78
        $this->contactInformation        = $contactInformation;
79
        $this->raInstitution             = $raInstitution;
80
    }
81
82
    public function getAuditLogMetadata()
83
    {
84
        $metadata                      = new Metadata();
85
        $metadata->identityId          = $this->identityId;
86
        $metadata->identityInstitution = $this->identityInstitution;
87
88
        return $metadata;
89
    }
90
91
    public static function deserialize(array $data)
92
    {
93
        return new self(
94
            new IdentityId($data['identity_id']),
95
            new NameId($data['name_id']),
96
            new Institution($data['institution']),
97
            RegistrationAuthorityRole::deserialize($data['registration_authority_role']),
98
            new Location($data['location']),
99
            new ContactInformation($data['contact_information']),
100
            new Institution($data['ra_institution'])
101
        );
102
    }
103
104
    public function serialize()
105
    {
106
        return [
107
            'identity_id'                 => (string) $this->identityId,
108
            'name_id'                     => (string) $this->nameId,
109
            'institution'                 => (string) $this->identityInstitution,
110
            'registration_authority_role' => $this->registrationAuthorityRole->serialize(),
111
            'location'                    => (string) $this->location,
112
            'contact_information'         => (string) $this->contactInformation,
113
            'ra_institution'              => (string) $this->raInstitution,
114
        ];
115
    }
116
}
117