示例#1
0
 public function testSetPrecision()
 {
     $eur = new Currency("EUR", 2);
     $this->assertSame(2, $eur->getPrecision());
     $eur->setPrecision(3);
     $this->assertSame(3, $eur->getPrecision());
 }
示例#2
0
文件: Money.php 项目: sugiphp/money
 /**
  * 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;
 }