function twig_round in Translation template extractor 6.3
Same name and namespace in other branches
- 7.3 vendor/Twig/Extension/Core.php \twig_round()
Rounds a number.
Parameters
int|float $value The value to round:
int|float $precision The rounding precision:
string $method The method to use for rounding:
Return value
int|float The rounded number
1 string reference to 'twig_round'
- Twig_Extension_Core::getFilters in vendor/
Twig/ Extension/ Core.php - Returns a list of filters to add to the existing list.
File
- vendor/
Twig/ Extension/ Core.php, line 554
Code
function twig_round($value, $precision = 0, $method = 'common') {
if ('common' == $method) {
return round($value, $precision);
}
if ('ceil' != $method && 'floor' != $method) {
throw new Twig_Error_Runtime('The round filter only supports the "common", "ceil", and "floor" methods.');
}
return $method($value * pow(10, $precision)) / pow(10, $precision);
}