Completed
Pull Request — master (#436)
by
unknown
02:57
created

GeoCoordinatesUpdated::coordinates()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php declare(strict_types=1);
2
3
namespace CultuurNet\UDB3\Organizer\Events;
4
5
use CultuurNet\Geocoding\Coordinate\Coordinates;
6
use CultuurNet\Geocoding\Coordinate\Latitude;
7
use CultuurNet\Geocoding\Coordinate\Longitude;
8
9 View Code Duplication
class GeoCoordinatesUpdated extends OrganizerEvent
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...
10
{
11
    /**
12
     * @var Coordinates
13
     */
14
    private $coordinates;
15
16
    public function __construct(string $organizerId, Coordinates $coordinates)
17
    {
18
        parent::__construct($organizerId);
19
        $this->coordinates = $coordinates;
20
    }
21
22
    /**
23
     * @return Coordinates
24
     */
25
    public function coordinates(): Coordinates
26
    {
27
        return $this->coordinates;
28
    }
29
30
    /**
31
     * @return array
32
     */
33
    public function serialize()
34
    {
35
        return parent::serialize() + [
36
                'coordinates' => [
37
                    'lat' => $this->coordinates->getLatitude()->toDouble(),
38
                    'long' => $this->coordinates->getLongitude()->toDouble(),
39
                ],
40
            ];
41
    }
42
43
    /**
44
     * @param array $data
45
     * @return static
46
     */
47
    public static function deserialize(array $data)
48
    {
49
        return new static(
50
            $data['item_id'],
51
            new Coordinates(
52
                new Latitude($data['coordinates']['lat']),
53
                new Longitude($data['coordinates']['long'])
54
            )
55
        );
56
    }
57
}
58