Completed
Pull Request — master (#320)
by Luc
05:00
created

LocationUpdated   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 49
loc 49
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 8 8 1
A getLocationId() 4 4 1
A serialize() 6 6 1
A deserialize() 7 7 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
namespace CultuurNet\UDB3\Event\Events;
4
5
use CultuurNet\UDB3\Location\LocationId;
6
use CultuurNet\UDB3\Offer\Events\AbstractEvent;
7
8 View Code Duplication
class LocationUpdated extends AbstractEvent
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...
9
{
10
    /**
11
     * @var LocationId
12
     */
13
    private $locationId;
14
15
    /**
16
     * @param string $eventId
17
     * @param LocationId $locationId
18
     */
19
    public function __construct(
20
        $eventId,
21
        LocationId $locationId
22
    ) {
23
        parent::__construct($eventId);
24
25
        $this->locationId = $locationId;
26
    }
27
28
    /**
29
     * @return LocationId
30
     */
31
    public function getLocationId()
32
    {
33
        return $this->locationId;
34
    }
35
36
    /**
37
     * @inheritdoc
38
     */
39
    public function serialize()
40
    {
41
        return parent::serialize() + [
42
                'location_id' => $this->locationId->toNative(),
43
            ];
44
    }
45
46
    /**
47
     * @inheritdoc
48
     */
49
    public static function deserialize(array $data)
50
    {
51
        return new static(
52
            $data['item_id'],
53
            new LocationId($data['location_id'])
54
        );
55
    }
56
}
57