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


PHP Money::subtract方法代码示例

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


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

示例1: withdraw

 /**
  * Decrease this account current balance
  *
  * @param Money $amount
  * @throws InsufficientFunds
  *     A member cannot withdraw more than it's account current balance
  */
 public function withdraw(Money $amount)
 {
     if ($amount->greaterThan($this->balance)) {
         throw new InsufficientFunds("Cannot withdraw {$amount->getAmount()}");
     }
     $this->balance = $this->balance->subtract($amount);
 }
开发者ID:zoek1,项目名称:php-testing-tools,代码行数:14,代码来源:Account.php

示例2: testDifferentCurrenciesCannotBeSubtracted

 /**
  * @expectedException Money\InvalidArgumentException
  */
 public function testDifferentCurrenciesCannotBeSubtracted()
 {
     $m1 = new Money(100, new Currency('EUR'));
     $m2 = new Money(100, new Currency('USD'));
     $m1->subtract($m2);
 }
开发者ID:hemeragestao,项目名称:money,代码行数:9,代码来源:MoneyTest.php

示例3: subtractFromAmount

 public function subtractFromAmount(Money $money)
 {
     return new static($this->amount->subtract($money), $this->dueDate);
 }
开发者ID:cambridgeuniversity,项目名称:ice-paymentplan,代码行数:4,代码来源:PlannedPayment.php

示例4: testDifferentCurrenciesCannotBeSubtracted

 /**
  * @expectedException InvalidArgumentException
  */
 public function testDifferentCurrenciesCannotBeSubtracted()
 {
     $m1 = new Money(100, CurrencyProxy::determine('EUR'));
     $m2 = new Money(100, CurrencyProxy::determine('USD'));
     $m1->subtract($m2);
 }
开发者ID:srtfisher,项目名称:money,代码行数:9,代码来源:MoneyTest.php

示例5: subtract

 /**
  * @param Money $amount
  *
  * @throws \InvalidArgumentException
  *
  * @return Money
  */
 public function subtract(Money $amount) : Money
 {
     return new self($this->money->subtract($amount->wrapped()));
 }
开发者ID:hughgrigg,项目名称:ching-shop,代码行数:11,代码来源:Money.php


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