/** * @see ValueFormatter::format * * Generates HTML representing the details of a TimeValue, * as an itemized list. * * @param TimeValue $value * * @throws InvalidArgumentException * @return string HTML */ public function format($value) { if (!$value instanceof TimeValue) { throw new InvalidArgumentException('Data value type mismatch. Expected a TimeValue.'); } $timeHtml = $this->getTimestampHtml($value->getTime()); $timeZone = $value->getTimezone(); $timeZoneHtml = is_int($timeZone) ? $this->getTimeZoneHtml($timeZone) : htmlspecialchars($timeZone); $calendarHtml = $this->getCalendarModelHtml($value->getCalendarModel()); $precision = $value->getPrecision(); $before = $value->getBefore(); $after = $value->getAfter(); if (is_int($precision) && is_int($before) && is_int($after)) { $precisionHtml = $this->getAmountAndPrecisionHtml($precision); $beforeHtml = $this->getAmountAndPrecisionHtml($precision, $before); $afterHtml = $this->getAmountAndPrecisionHtml($precision, $after); } else { $precisionHtml = htmlspecialchars($precision); $beforeHtml = htmlspecialchars($value->getBefore()); $afterHtml = htmlspecialchars($value->getAfter()); } $html = ''; $html .= Html::rawElement('h4', array('class' => 'wb-details wb-time-details wb-time-rendered'), $this->timeFormatter->format($value)); $html .= Html::openElement('table', array('class' => 'wb-details wb-time-details')); $html .= $this->getFieldHtml('isotime', $timeHtml); $html .= $this->getFieldHtml('timezone', $timeZoneHtml); $html .= $this->getFieldHtml('calendar', $calendarHtml); $html .= $this->getFieldHtml('precision', $precisionHtml); $html .= $this->getFieldHtml('before', $beforeHtml); $html .= $this->getFieldHtml('after', $afterHtml); $html .= Html::closeElement('table'); return $html; }
/** * @dataProvider instanceProvider */ public function testGetAfter(TimeValue $time, array $arguments) { $this->assertEquals($arguments[3], $time->getAfter()); }