/** * @param string $expected * @param string $format * * @dataProvider testGetDateFormatDataProvider */ public function testFormat($expected, $format) { $dateFormatter = DateFormatterFactory::getFormatter($format); $date = new DateTimeImmutable('1982-01-24'); $actual = $dateFormatter->format($date, $format); $this->assertSame($expected, $actual); }
/** * @return string * * @throws UnsupportedDateFormatException */ public function getText() { try { $dateFormat = $this->getDateFormat(); $dateFormatter = DateFormatterFactory::getFormatter($dateFormat); return $dateFormatter->format($this->getDateTime(), $dateFormat); } catch (\Exception $e) { throw new UnsupportedDateFormatException($this->getDateFormat()); } }