Completed
Push — master ( ace74a...38a91c )
by Daan van
04:54
created

RaLocationAddedEvent::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 13
nc 1
nop 6
1
<?php
2
3
/**
4
 * Copyright 2016 SURFnet B.V.
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\Configuration\Event;
20
21
use Broadway\Serializer\SerializableInterface;
22
use Surfnet\Stepup\Configuration\Value\ContactInformation;
23
use Surfnet\Stepup\Configuration\Value\Institution;
24
use Surfnet\Stepup\Configuration\Value\InstitutionConfigurationId;
25
use Surfnet\Stepup\Configuration\Value\Location;
26
use Surfnet\Stepup\Configuration\Value\RaLocationId;
27
use Surfnet\Stepup\Configuration\Value\RaLocationName;
28
29
class RaLocationAddedEvent implements SerializableInterface
30
{
31
    /**
32
     * @var InstitutionConfigurationId
33
     */
34
    public $institutionConfigurationId;
35
36
    /**
37
     * @var Institution
38
     */
39
    public $institution;
40
41
    /**
42
     * @var RaLocationId
43
     */
44
    public $raLocationId;
45
46
    /**
47
     * @var RaLocationName
48
     */
49
    public $raLocationName;
50
51
    /**
52
     * @var Location
53
     */
54
    public $location;
55
    /**
56
     * @var ContactInformation
57
     */
58
    public $contactInformation;
59
60
    public function __construct(
61
        InstitutionConfigurationId $institutionConfigurationId,
62
        Institution $institution,
63
        RaLocationId $raLocationId,
64
        RaLocationName $raLocationName,
65
        Location $location,
66
        ContactInformation $contactInformation
67
    ) {
68
        $this->institutionConfigurationId = $institutionConfigurationId;
69
        $this->institution                = $institution;
70
        $this->raLocationId               = $raLocationId;
71
        $this->raLocationName             = $raLocationName;
72
        $this->location                   = $location;
73
        $this->contactInformation         = $contactInformation;
74
    }
75
76
    public static function deserialize(array $data)
77
    {
78
        return new self(
79
            new InstitutionConfigurationId($data['institution_configuration_id']),
80
            new Institution($data['institution']),
81
            new RaLocationId($data['ra_location_id']),
82
            new RaLocationName($data['ra_location_name']),
83
            new Location($data['location']),
84
            new ContactInformation($data['contact_information'])
85
        );
86
    }
87
88
    public function serialize()
89
    {
90
        return [
91
            'institution_configuration_id' => $this->institutionConfigurationId->getInstitutionConfigurationId(),
92
            'institution'                  => $this->institution->getInstitution(),
93
            'ra_location_id'               => $this->raLocationId->getRaLocationId(),
94
            'ra_location_name'             => $this->raLocationName->getRaLocationName(),
95
            'location'                     => $this->location->getLocation(),
96
            'contact_information'          => $this->contactInformation->getContactInformation(),
97
        ];
98
    }
99
}
100