/** * @param string|null $value if not null it's string formated as "(float, float)" * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform * * @return \Biera\GeographicLocation|null */ public function convertToPHPValue($value, AbstractPlatform $platform) { if (is_null($value)) { return $value; } list($latitude, $longitude) = array_map(function ($v) { return floatval($v); }, explode(',', substr($value, 1, -1))); return GeographicLocation::fromDecimals($latitude, $longitude); }
function it_converts_geographic_location_object_to_string(AbstractPlatform $platform) { $this->convertToDatabaseValue(GeographicLocation::fromDecimals(0.1, 0.1), $platform)->shouldBe('(0.1, 0.1)'); }