/**
* Formats provided value using optional style properties
*
* @param mixed $value Formatter-specific variable to format (can be integer, \DateTime, etc)
* @param Locale $locale Locale to use
* @param array $styleProperties Integer-indexed array of formatter-specific style properties (can be empty)
* @return string String representation of $value provided, or (string)$value
* @api
*/
public function format($value, Locale $locale, array $styleProperties = [])
{
if (isset($styleProperties[0])) {
$formatType = $styleProperties[0];
DatesReader::validateFormatType($formatType);
} else {
$formatType = DatesReader::FORMAT_TYPE_DATETIME;
}
if (isset($styleProperties[1])) {
$formatLength = $styleProperties[1];
DatesReader::validateFormatLength($formatLength);
} else {
$formatLength = DatesReader::FORMAT_LENGTH_DEFAULT;
}
switch ($formatType) {
case DatesReader::FORMAT_TYPE_DATE:
return $this->formatDate($value, $locale, $formatLength);
case DatesReader::FORMAT_TYPE_TIME:
return $this->formatTime($value, $locale, $formatLength);
default:
return $this->formatDateTime($value, $locale, $formatLength);
}
}