PHP Class CRUDlex\TwigExtensions

Afficher le fichier Open project: philiplb/crudlex Class Usage Examples

Méthodes publiques

Méthode Description
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.

Méthodes protégées

Méthode Description
formatTime ( string $value, string $timezone, string $pattern ) : string Formats the given time value to a timestring defined by the $pattern parameter.

Method Details

formatDate() public méthode

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
Résultat string the formatted result or an empty string on null value

formatDateTime() public méthode

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
Résultat string the formatted result or an empty string on null value

formatFloat() public méthode

Formats a float to not display in scientific notation.
public formatFloat ( float $float ) : double | string
$float float the float to format
Résultat double | string the formated float

formatTime() protected méthode

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
Résultat string the formatted value

getLanguageName() public méthode

Gets a language name in the given language.
public getLanguageName ( string $language ) : string
$language string the language code of the desired language name
Résultat string the language name in the given language or null if not available

registerTwigExtensions() public méthode

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