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


PHP Money::USD方法代码示例

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


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

示例1: testOverrideCurrency

 public function testOverrideCurrency()
 {
     \Locale::setDefault("fr_FR");
     $form = $this->factory->create($this->simpleMoneyTypeClass, null, ["currency" => "USD"]);
     $form->submit(array("tbbc_amount" => '1 252,5'));
     $this->assertEquals(Money::USD(125250), $form->getData());
 }
开发者ID:BboyKeen,项目名称:TbbcMoneyBundle,代码行数:7,代码来源:SimpleMoneyTypeTest.php

示例2: widthdrawl

 public function widthdrawl($amount)
 {
     $originalfunds = Money::USD((int) $this->fundsavailable);
     $addedFunds = Money::USD((int) $amount);
     $fundsavailable = $originalfunds->subtract($addedFunds);
     $this->fundsavailable = $fundsavailable->getAmount();
     $this->save();
 }
开发者ID:ammonitenetworks,项目名称:f3-finances,代码行数:8,代码来源:Dashboard.php

示例3: ConvertsEurToUsdWithModes

 /** @test */
 public function ConvertsEurToUsdWithModes()
 {
     $eur = Money::Euro(10);
     $pair = new CurrencyPair(CurrencyProxy::determine('EUR'), CurrencyProxy::determine('USD'), 1.25);
     $usd = $pair->convert($eur);
     $this->assertEquals(Money::USD(13), $usd);
     $pair = new CurrencyPair(CurrencyProxy::determine('EUR'), CurrencyProxy::determine('USD'), 1.25);
     $usd = $pair->convert($eur, new RoundingMode(RoundingMode::ROUND_HALF_DOWN));
     $this->assertEquals(Money::USD(12), $usd);
 }
开发者ID:srtfisher,项目名称:money,代码行数:11,代码来源:CurrencyPairTest.php

示例4: ConvertsEurToUsdAndBack

 /** @test */
 public function ConvertsEurToUsdAndBack()
 {
     $eur = Money::EUR(100);
     $pair = new CurrencyPair(new Currency('EUR'), new Currency('USD'), 1.25);
     $usd = $pair->convert($eur);
     $this->assertEquals(Money::USD(125), $usd);
     $pair = new CurrencyPair(new Currency('USD'), new Currency('EUR'), 0.8);
     $eur = $pair->convert($usd);
     $this->assertEquals(Money::EUR(100), $eur);
 }
开发者ID:SerdarSanri,项目名称:laravel-money,代码行数:11,代码来源:CurrencyPairTest.php

示例5: testMoneyTwigExtension

 public function testMoneyTwigExtension()
 {
     \Locale::setDefault('en');
     /** @var PairManagerInterface $pairManager */
     $pairManager = $this->client->getContainer()->get("tbbc_money.pair_manager");
     $pairManager->saveRatio("USD", 1.25);
     /** @var MoneyExtension $moneyExtension */
     $moneyExtension = $this->client->getContainer()->get("tbbc_money.twig.money");
     $eur = Money::EUR(100);
     $usd = $moneyExtension->convert($eur, "USD");
     $this->assertEquals(Money::USD(125), $usd);
 }
开发者ID:stalxed,项目名称:TbbcMoneyBundle,代码行数:12,代码来源:ConfigTest.php

示例6: testRatio

 public function testRatio()
 {
     $eur = Money::EUR(100);
     $sameEur = $this->manager->convert($eur, "EUR");
     $this->assertEquals(Money::EUR(100), $sameEur);
     try {
         $this->manager->convert($eur, "USD");
         $this->assertTrue(false);
     } catch (MoneyException $e) {
         $this->assertTrue(true);
     }
     $this->manager->saveRatio("USD", 1.25);
     $usd = $this->manager->convert($eur, "USD");
     $this->assertEquals(Money::USD(125), $usd);
     $this->manager->saveRatio("CAD", 1.5);
     $cad = $this->manager->convert($usd, "CAD");
     $this->assertEquals(Money::CAD(150), $cad);
 }
开发者ID:stalxed,项目名称:TbbcMoneyBundle,代码行数:18,代码来源:PairManagerTest.php

示例7: setUp

 public function setUp()
 {
     $this->money_usd = Money::USD(1234);
     $this->money_euro = Money::Euro(1234);
     $this->money_czech = Money::Koruna(1234);
 }
开发者ID:srtfisher,项目名称:money,代码行数:6,代码来源:FormatTest.php

示例8: testDifferentCurrenciesCannotBeCompared

 /**
  * @expectedException Money\InvalidArgumentException
  */
 public function testDifferentCurrenciesCannotBeCompared()
 {
     Money::EUR(1)->compare(Money::USD(1));
 }
开发者ID:hemeragestao,项目名称:money,代码行数:7,代码来源:MoneyTest.php

示例9: testConstructorWithMoney

 public function testConstructorWithMoney()
 {
     $price = new Price([Money::EUR(5), Money::USD(10), Money::GBP(10), 'TRY' => 120], [CurrencyPair::createFromIso('USD/CHF 1.5'), CurrencyPair::createFromIso('USD/AWG 1.0')]);
     $this->assertInstanceOf('Leaphly\\Price\\Price', $price);
     $this->assertEquals(15, $price->getAmount('CHF'));
 }
开发者ID:leaphly,项目名称:price,代码行数:6,代码来源:ConversionPriceTest.php

示例10: testCents

 public function testCents()
 {
     $this->assertEquals(Money::USD(1234)->getCents(), Money::USD(1234)->getUnits());
 }
开发者ID:srtfisher,项目名称:money,代码行数:4,代码来源:MoneyTest.php

示例11: chargeFee

 public function chargeFee($amount, $percentage = 0.029, $flat = 30)
 {
     $amount = Money::USD($amount);
     $flatfee = Money::USD($flat);
     $fee = $amount->multiply($percentage);
     $newAmount = $amount->subtract($fee);
     $newAmount = $newAmount->subtract($flatfee);
     return $newAmount->getAmount();
 }
开发者ID:ammonitenetworks,项目名称:f3-finances,代码行数:9,代码来源:Transactions.php

示例12: itSetsMoney

 /**
  * @test
  */
 public function itSetsMoney()
 {
     $expense = new Expense();
     $expense->setMoney($money = Money::USD(1000));
     $this->assertEquals($money, $expense->getMoney());
 }
开发者ID:radmen,项目名称:cashtraq,代码行数:9,代码来源:ExpenseTest.php


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