PHP Класс CRUDlex\TwigExtensions

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
formatDate ( string $value, boolean $isUTC ) : string Formats the given value to a date of the format 'Y-m-d'.
formatDateTime ( string $value, boolean $isUTC ) : string Formats the given value to a date of the format 'Y-m-d H:i'.
formatFloat ( float $float ) : double | string Formats a float to not display in scientific notation.
getLanguageName ( string $language ) : string Gets a language name in the given language.
registerTwigExtensions ( Pimple\Container $app ) Registers all extensions.

Защищенные методы

Метод Описание
formatTime ( string $value, string $timezone, string $pattern ) : string Formats the given time value to a timestring defined by the $pattern parameter.

Описание методов

formatDate() публичный Метод

Formats the given value to a date of the format 'Y-m-d'.
public formatDate ( string $value, boolean $isUTC ) : string
$value string the value, might be of the format 'Y-m-d H:i' or 'Y-m-d'
$isUTC boolean whether the given value is in UTC
Результат string the formatted result or an empty string on null value

formatDateTime() публичный Метод

Formats the given value to a date of the format 'Y-m-d H:i'.
public formatDateTime ( string $value, boolean $isUTC ) : string
$value string the value, might be of the format 'Y-m-d H:i'
$isUTC boolean whether the given value is in UTC
Результат string the formatted result or an empty string on null value

formatFloat() публичный Метод

Formats a float to not display in scientific notation.
public formatFloat ( float $float ) : double | string
$float float the float to format
Результат double | string the formated float

formatTime() защищенный Метод

If the value is false (like null), an empty string is returned. Else, the value is tried to be parsed as datetime via the given pattern. If that fails, it is tried to be parsed with the pattern 'Y-m-d H:i:s'. If that fails, the value is returned unchanged. Else, it is returned formatted with the given pattern. The effect is to shorten 'Y-m-d H:i:s' to 'Y-m-d' for example.
protected formatTime ( string $value, string $timezone, string $pattern ) : string
$value string the value to be formatted
$timezone string the timezone of the value
$pattern string the pattern with which the value is parsed and formatted
Результат string the formatted value

getLanguageName() публичный Метод

Gets a language name in the given language.
public getLanguageName ( string $language ) : string
$language string the language code of the desired language name
Результат string the language name in the given language or null if not available

registerTwigExtensions() публичный Метод

Registers all extensions.
public registerTwigExtensions ( Pimple\Container $app )
$app Pimple\Container the current application