本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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));
}
示例5: updateTotal
/**
* PrePersist listener to update the line total.
*
* @ORM\PrePersist
*/
public function updateTotal()
{
$this->total = $this->price->multiply($this->qty);
}
示例6: negative
/**
* @return Money
*/
public function negative() : Money
{
return new self($this->money->multiply(-1));
}