/** * @see ValueFormatter::format * * @since 0.1 * * @param GlobeCoordinateValue $value The value to format * * @return string * @throws InvalidArgumentException */ public function format($value) { if (!$value instanceof GlobeCoordinateValue) { throw new InvalidArgumentException('Data value type mismatch. Expected a GlobeCoordinateValue.'); } $formatter = new GeoCoordinateFormatter($this->options); return $formatter->formatLatLongValue($value->getLatLong(), $value->getPrecision()); }
/** * @see ValueFormatter::format * * @since 0.1 * * @param GlobeCoordinateValue $value The value to format * * @return string * @throws InvalidArgumentException */ public function format($value) { if (!$value instanceof GlobeCoordinateValue) { throw new InvalidArgumentException('The GlobeCoordinateFormatter can only format instances of GlobeCoordinateValue.'); } $formatter = new GeoCoordinateFormatter($this->options); return $formatter->formatLatLongValue($value->getLatLong(), $value->getPrecision()); }
/** * @dataProvider invalidPrecisionProvider */ public function testFormatLatLongValueWithInvalidPrecision_fallsBackToDefaultPrecision($precision) { $formatter = new GeoCoordinateFormatter(new FormatterOptions()); $formatted = $formatter->formatLatLongValue(new LatLongValue(1.2, 3.4), $precision); $this->assertEquals('1.2, 3.4', $formatted); }