public function testSetPrecision() { $eur = new Currency("EUR", 2); $this->assertSame(2, $eur->getPrecision()); $eur->setPrecision(3); $this->assertSame(3, $eur->getPrecision()); }
/** * Sets the amount considering precision of the currency. * * @param numeric $amount */ protected function setAmount($amount) { if (!is_numeric($amount)) { throw new InvalidArgumentException("Amount must be a numeric value"); } $precision = $this->currency->getPrecision(); $amount = round($amount, $precision); if (0 === $precision) { $amount = (int) $amount; } $this->amount = $amount; }