moneyphp / money

PHP implementation of Fowler's Money pattern.

Home Page:http://moneyphp.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Round function not working

pmoore95 opened this issue · comments

Constructor only accepts integer(ish) values e.g.

$15.25 is represented with:

$price = new \Money\Money('1525', new Currency('USD'));

However the round function does not work:

$price->multiply(1 , Money::ROUND_UP);

returns '1525'

As it is considered an integer in all the round functions such as ceil() :

public function ceil($number)
    {
        $number = Number::fromNumber($number);

        if ($number->isInteger()) {
            return (string) $number;
        }

        if ($number->isNegative()) {
            return bcadd((string) $number, '0', 0);
        }

        return bcadd((string) $number, '1', 0);
    }
And just returns the same string.

This function works if the parameter is "15.25" but this isn't allowed in the constructor.

Never mind, this isn't an issue apologies.