当前位置: 首页>>代码示例>>PHP>>正文


PHP Money::multiply方法代码示例

本文整理汇总了PHP中Money\Money::multiply方法的典型用法代码示例。如果您正苦于以下问题:PHP Money::multiply方法的具体用法?PHP Money::multiply怎么用?PHP Money::multiply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Money\Money的用法示例。


在下文中一共展示了Money::multiply方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: convert

 public function convert(Money $money, $target)
 {
     if (!$target instanceof MoneyCurrency) {
         throw new InvalidArgumentException(sprintf('Second argument must be Currency, %s given.', gettype($target)));
     }
     $rate = $this->swap->quote(new CurrencyPair($money->getCurrency(), $target));
     return new Money($money->multiply((double) $rate->getValue())->getAmount(), $target);
 }
开发者ID:umpirsky,项目名称:locurro,代码行数:8,代码来源:Currency.php

示例2: setDiscount

 /**
  * @param Quote|Invoice $object
  * @param Money         $total
  *
  * @return mixed
  */
 private function setDiscount($object, Money $total)
 {
     if (null !== $object->getDiscount()) {
         $discount = $total->multiply($object->getDiscount());
         $total = $total->subtract($discount);
         return $total;
     }
     return $total;
 }
开发者ID:csbill,项目名称:csbill,代码行数:15,代码来源:BillingFormSubscriber.php

示例3: Rate

 function it_converts_money_using_swap(SwapInterface $swap, Money $money, Money $converted, Currency $from, Currency $to)
 {
     $money->getAmount()->willReturn(100);
     $money->getCurrency()->willReturn($from);
     $money->multiply(120.3971)->willReturn($converted);
     $converted->getAmount()->willReturn(12039);
     $converted->getCurrency()->willReturn($to);
     $from->__toString()->willReturn('EUR');
     $to->__toString()->willReturn('RSD');
     $rate = new Rate(120.3971);
     $swap->quote('EUR/RSD')->shouldBeCalled()->willReturn($rate);
     $this->convert($money, $to)->getAmount()->shouldBe(12039);
 }
开发者ID:umpirsky,项目名称:locurro,代码行数:13,代码来源:CurrencySpec.php

示例4: testMultiplication

 public function testMultiplication()
 {
     $m = new Money(1, new Currency('EUR'));
     $this->assertEquals(new Money(2, new Currency('EUR')), $m->multiply(1.5));
     $this->assertEquals(new Money(1, new Currency('EUR')), $m->multiply(1.5, Money::ROUND_HALF_DOWN));
     $this->assertNotSame($m, $m->multiply(2));
 }
开发者ID:hemeragestao,项目名称:money,代码行数:7,代码来源:MoneyTest.php

示例5: updateTotal

 /**
  * PrePersist listener to update the line total.
  *
  * @ORM\PrePersist
  */
 public function updateTotal()
 {
     $this->total = $this->price->multiply($this->qty);
 }
开发者ID:Codixis,项目名称:CSBill,代码行数:9,代码来源:Item.php

示例6: negative

 /**
  * @return Money
  */
 public function negative() : Money
 {
     return new self($this->money->multiply(-1));
 }
开发者ID:hughgrigg,项目名称:ching-shop,代码行数:7,代码来源:Money.php


注:本文中的Money\Money::multiply方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。