Skip to content
This repository has been archived by the owner on Jul 6, 2019. It is now read-only.

add Float type, with stuff that twig_round does #83

Open
laland opened this issue Dec 22, 2015 · 0 comments
Open

add Float type, with stuff that twig_round does #83

laland opened this issue Dec 22, 2015 · 0 comments

Comments

@laland
Copy link

laland commented Dec 22, 2015

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);
} 

Why not to add this:
Float::ceil($float, $precision)
Float::floor($float, $precision)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant