Neos\Flow\I18n\Cldr\Reader\DatesReader::validateFormatLength PHP Method

validateFormatLength() public static method

Validates provided format length and throws exception if value is not allowed.
public static validateFormatLength ( string $formatLength ) : void
$formatLength string
return void
    public static function validateFormatLength($formatLength)
    {
        if (!in_array($formatLength, [self::FORMAT_LENGTH_DEFAULT, self::FORMAT_LENGTH_FULL, self::FORMAT_LENGTH_LONG, self::FORMAT_LENGTH_MEDIUM, self::FORMAT_LENGTH_SHORT])) {
            throw new Exception\InvalidFormatLengthException('Provided formatLength, "' . $formatLength . '", is not one of allowed values.', 1281442591);
        }
    }

Usage Example

 /**
  * Formats dateTime with format string for date and time defined in CLDR for
  * particular locale.
  *
  * First date and time are formatted separately, and then dateTime format
  * from CLDR is used to place date and time in correct order.
  *
  * @param \DateTimeInterface $dateTime PHP object representing particular point in time
  * @param Locale $locale
  * @param string $formatLength One of DatesReader FORMAT_LENGTH constants
  * @return string Formatted date and time
  * @api
  */
 public function formatDateTime(\DateTimeInterface $dateTime, Locale $locale, $formatLength = DatesReader::FORMAT_LENGTH_DEFAULT)
 {
     DatesReader::validateFormatLength($formatLength);
     return $this->doFormattingWithParsedFormat($dateTime, $this->datesReader->parseFormatFromCldr($locale, DatesReader::FORMAT_TYPE_DATETIME, $formatLength), $this->datesReader->getLocalizedLiteralsForLocale($locale));
 }
All Usage Examples Of Neos\Flow\I18n\Cldr\Reader\DatesReader::validateFormatLength