| @@ 9-61 (lines=53) @@ | ||
| 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 | /** |
|
| 17 | * @param string $itemId |
|
| 18 | * @param Coordinates $coordinates |
|
| 19 | */ |
|
| 20 | public function __construct($itemId, Coordinates $coordinates) |
|
| 21 | { |
|
| 22 | parent::__construct($itemId); |
|
| 23 | $this->coordinates = $coordinates; |
|
| 24 | } |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @return Coordinates |
|
| 28 | */ |
|
| 29 | public function getCoordinates() |
|
| 30 | { |
|
| 31 | return $this->coordinates; |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @return array |
|
| 36 | */ |
|
| 37 | public function serialize() |
|
| 38 | { |
|
| 39 | return parent::serialize() + [ |
|
| 40 | 'coordinates' => [ |
|
| 41 | 'lat' => $this->coordinates->getLatitude()->toDouble(), |
|
| 42 | 'long' => $this->coordinates->getLongitude()->toDouble(), |
|
| 43 | ], |
|
| 44 | ]; |
|
| 45 | } |
|
| 46 | ||
| 47 | /** |
|
| 48 | * @param array $data |
|
| 49 | * @return static |
|
| 50 | */ |
|
| 51 | public static function deserialize(array $data) |
|
| 52 | { |
|
| 53 | return new static( |
|
| 54 | $data['item_id'], |
|
| 55 | new Coordinates( |
|
| 56 | new Latitude($data['coordinates']['lat']), |
|
| 57 | new Longitude($data['coordinates']['long']) |
|
| 58 | ) |
|
| 59 | ); |
|
| 60 | } |
|
| 61 | } |
|
| 62 | ||
| @@ 9-57 (lines=49) @@ | ||
| 6 | use CultuurNet\Geocoding\Coordinate\Latitude; |
|
| 7 | use CultuurNet\Geocoding\Coordinate\Longitude; |
|
| 8 | ||
| 9 | class GeoCoordinatesUpdated extends OrganizerEvent |
|
| 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 | ||