function twig_round in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/twig/twig/lib/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/ twig/ lib/ Twig/ Extension/ Core.php
File
- vendor/
twig/ twig/ lib/ Twig/ Extension/ Core.php, line 558
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);
}