*/ abstract class AbstractArrayDumper { /** * @param Location $location * * @return array */ protected function getArray(Location $location): array { $properties = array_filter($location->toArray(), function ($value) { return !empty($value); }); unset( $properties['latitude'], $properties['longitude'], $properties['bounds'] ); if ([] === $properties) { $properties = null; } $lat = 0; $lon = 0; if (null !== $coordinates = $location->getCoordinates()) { $lat = $coordinates->getLatitude(); $lon = $coordinates->getLongitude(); } $array = [ 'type' => 'Feature', 'geometry' => [ 'type' => 'Point', 'coordinates' => [$lon, $lat], ], 'properties' => $properties, ]; if (null !== $bounds = $location->getBounds()) { $array['bounds'] = $bounds->toArray(); } return $array; } }