Completed
Push — feature/warn-on-non-utc-usage ( f71ca6...75a7ba )
by Boy
12:02 queued 07:38
created

RaLocationAddedEvent   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 63
Duplicated Lines 20.63 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 3
c 3
b 0
f 1
lcom 1
cbo 5
dl 13
loc 63
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 13 13 1
A deserialize() 0 10 1
A serialize() 0 10 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\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 implements SerializableInterface
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 View Code Duplication
    public function __construct(
0 ignored issues
show
Duplication introduced by
This method 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...
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
            new InstitutionConfigurationId($data['institution_configuration_id']),
73
            new RaLocationId($data['ra_location_id']),
74
            new RaLocationName($data['ra_location_name']),
75
            new Location($data['location']),
76
            new ContactInformation($data['contact_information'])
77
        );
78
    }
79
80
    public function serialize()
81
    {
82
        return [
83
            'institution_configuration_id' => $this->institutionConfigurationId->getInstitutionConfigurationId(),
84
            'ra_location_id'               => $this->raLocationId->getRaLocationId(),
85
            'ra_location_name'             => $this->raLocationName->getRaLocationName(),
86
            'location'                     => $this->location->getLocation(),
87
            'contact_information'          => $this->contactInformation->getContactInformation(),
88
        ];
89
    }
90
}
91