/** * Adds the passed monetary value to the current one * * @throws fValidationException When `$addend` is not a valid number/monetary value * * @param fMoney|string|integer $addend The money object to add - a string or integer will be converted to the default currency (if defined) * @return fMoney The sum of the monetary values in this currency */ public function add($addend) { $addend = $this->makeMoney($addend); $converted_addend = $addend->convert($this->currency)->amount; $precision = self::getCurrencyInfo($this->currency, 'precision'); $new_amount = $this->amount->add($converted_addend, $precision + 1)->round($precision); return new fMoney($new_amount, $this->currency); }
/** * @dataProvider invalidNumProvider * @expectedException fValidationException */ public function testDivFail($number) { $num = new fNumber('1'); $num->add($number); }