예제 #1
0
파일: Money.php 프로젝트: brick/money
 /**
  * Returns the product of this Money and the given number.
  *
  * By default, the resulting Money has the same number of fraction digits as this Money. If the result
  * cannot be represented at this scale without rounding, an exception is thrown.
  *
  * This behaviour can be overridden by providing a MoneyContext instance.
  *
  * @param BigNumber|number|string $that    The multiplier.
  * @param MoneyContext|null       $context An optional scale & rounding context.
  *
  * @return Money
  *
  * @throws ArithmeticException If the argument is an invalid number.
  */
 public function multipliedBy($that, MoneyContext $context = null)
 {
     if ($context === null) {
         $context = new RetainContext(RoundingMode::UNNECESSARY);
     }
     $amount = $this->amount->multipliedBy($that);
     $amount = $context->applyTo($amount, $this->currency, $this->amount->scale());
     return new Money($amount, $this->currency);
 }