Your IP : 216.73.216.86


Current Path : /var/www/homesaver/www/bitrix/modules/location/lib/entity/address/converter/
Upload File :
Current File : /var/www/homesaver/www/bitrix/modules/location/lib/entity/address/converter/dbfieldconverter.php

<?php

namespace Bitrix\Location\Entity\Address\Converter;

use Bitrix\Location\Entity;

/**
 * Class DbFieldConverter
 * @package Bitrix\Location\Entity\Address\Converter
 * @internal
 */
final class DbFieldConverter
{
	/**
	 * Convert Address to DB fields array
	 *
	 * @param Entity\Address $address
	 * @return array
	 */
	public static function convertToDbField(Entity\Address $address): array
	{
		$locationId = 0;

		if ($location = $address->getLocation())
		{
			$locationId = $location->getId();
		}

		$latitude = $address->getLatitude();
		$longitude = $address->getLongitude();

		return [
			'ID' => $address->getId(),
			'LOCATION_ID' => $locationId,
			'LANGUAGE_ID' => $address->getLanguageId(),
			'LATITUDE' => $latitude === '' ? null : (float)$latitude,
			'LONGITUDE' => $longitude === '' ? null : (float)$longitude,
		];
	}
}