Code Duplication    Length = 39-39 lines in 2 locations

src/Offer/Events/AbstractGeoCoordinatesUpdated.php 1 location

@@ 9-47 (lines=39) @@
6
use CultuurNet\Geocoding\Coordinate\Latitude;
7
use CultuurNet\Geocoding\Coordinate\Longitude;
8
9
abstract class AbstractGeoCoordinatesUpdated extends AbstractEvent
10
{
11
    /**
12
     * @var Coordinates
13
     */
14
    private $coordinates;
15
16
    final public function __construct(string $itemId, Coordinates $coordinates)
17
    {
18
        parent::__construct($itemId);
19
        $this->coordinates = $coordinates;
20
    }
21
22
    public function getCoordinates(): Coordinates
23
    {
24
        return $this->coordinates;
25
    }
26
27
    public function serialize(): array
28
    {
29
        return parent::serialize() + [
30
            'coordinates' => [
31
                'lat' => $this->coordinates->getLatitude()->toDouble(),
32
                'long' => $this->coordinates->getLongitude()->toDouble(),
33
            ],
34
        ];
35
    }
36
37
    public static function deserialize(array $data): AbstractGeoCoordinatesUpdated
38
    {
39
        return new static(
40
            $data['item_id'],
41
            new Coordinates(
42
                new Latitude($data['coordinates']['lat']),
43
                new Longitude($data['coordinates']['long'])
44
            )
45
        );
46
    }
47
}
48

src/Organizer/Events/GeoCoordinatesUpdated.php 1 location

@@ 11-49 (lines=39) @@
8
use CultuurNet\Geocoding\Coordinate\Latitude;
9
use CultuurNet\Geocoding\Coordinate\Longitude;
10
11
final class GeoCoordinatesUpdated extends OrganizerEvent
12
{
13
    /**
14
     * @var Coordinates
15
     */
16
    private $coordinates;
17
18
    public function __construct(string $organizerId, Coordinates $coordinates)
19
    {
20
        parent::__construct($organizerId);
21
        $this->coordinates = $coordinates;
22
    }
23
24
    public function coordinates(): Coordinates
25
    {
26
        return $this->coordinates;
27
    }
28
29
    public function serialize(): array
30
    {
31
        return parent::serialize() + [
32
            'coordinates' => [
33
                'lat' => $this->coordinates->getLatitude()->toDouble(),
34
                'long' => $this->coordinates->getLongitude()->toDouble(),
35
            ],
36
        ];
37
    }
38
39
    public static function deserialize(array $data): GeoCoordinatesUpdated
40
    {
41
        return new static(
42
            $data['organizer_id'],
43
            new Coordinates(
44
                new Latitude($data['coordinates']['lat']),
45
                new Longitude($data['coordinates']['long'])
46
            )
47
        );
48
    }
49
}
50