Completed
Push — feature/ra-locations-model ( d07346...09efcd )
by A.
04:21
created

RaLocationAddedEvent::serialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 10
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
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 Surfnet\Stepup\Configuration\Value\ContactInformation;
22
use Surfnet\Stepup\Configuration\Value\Institution;
23
use Surfnet\Stepup\Configuration\Value\InstitutionConfigurationId;
24
use Surfnet\Stepup\Configuration\Value\Location;
25
use Surfnet\Stepup\Configuration\Value\RaLocationId;
26
use Surfnet\Stepup\Configuration\Value\RaLocationName;
27
28
class RaLocationAddedEvent
29
{
30
    /**
31
     * @var InstitutionConfigurationId
32
     */
33
    public $institutionConfigurationId;
34
    
35
    /**
36
     * @var RaLocationId
37
     */
38
    public $raLocationId;
39
    
40
    /**
41
     * @var RaLocationName
42
     */
43
    public $raLocationName;
44
    
45
    /**
46
     * @var Location
47
     */
48
    public $location;
49
    
50
    /**
51
     * @var ContactInformation
52
     */
53
    public $contactInformation;
54
55
    public function __construct(
56
        InstitutionConfigurationId $institutionConfigurationId,
57
        RaLocationId $raLocationId,
58
        RaLocationName $raLocationName,
59
        Location $location,
60
        ContactInformation $contactInformation
61
    ) {
62
        $this->institutionConfigurationId = $institutionConfigurationId;
63
        $this->raLocationId               = $raLocationId;
64
        $this->raLocationName             = $raLocationName;
65
        $this->location                   = $location;
66
        $this->contactInformation         = $contactInformation;
67
    }
68
69
    public static function deserialize(array $data)
70
    {
71
        return new self(
72
            $data['institution_configuration_id'],
73
            $data['ra_location_id'],
74
            $data['ra_location_name'],
75
            $data['location'],
76
            $data['contact_information']
77
        );
78
    }
79
80
    public function serialize()
81
    {
82
        return [
83
            'institution_configuration_id' => (string) $this->institutionConfigurationId,
84
            'ra_location_id'               => (string) $this->raLocationId,
85
            'ra_location_name'             => (string) $this->raLocationName,
86
            'location'                     => (string) $this->location,
87
            'contact_information'          => (string) $this->contactInformation,
88
        ];
89
    }
90
}
91