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


PHP Money::stringToUnits方法代码示例

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


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

示例1: filter

 /**
  * {@inheritdoc}
  *
  * @throws InvalidArgumentException
  *
  * @return int|null
  */
 public function filter($value)
 {
     if (null === $value || is_string($value) && strlen($value) === 0) {
         return null;
     }
     return Money::stringToUnits($value);
 }
开发者ID:zfbrasil,项目名称:doctrine-money-module,代码行数:14,代码来源:AmountFilter.php

示例2: addEntriesToStatement

 /**
  * @param SimpleXMLElement $statementXml
  * @param Statement $statement
  */
 private function addEntriesToStatement(SimpleXMLElement $statementXml, Statement $statement)
 {
     $index = 0;
     $entriesXml = $statementXml->Ntry;
     foreach ($entriesXml as $entryXml) {
         $amount = Money::stringToUnits((string) $entryXml->Amt);
         $currency = (string) $entryXml->Amt['Ccy'];
         $bookingDate = (string) $entryXml->BookgDt->Dt;
         $valueDate = (string) $entryXml->ValDt->Dt;
         if ((string) $entryXml->CdtDbtInd === 'DBIT') {
             $amount = $amount * -1;
         }
         $entry = new Entry($statement, $index, new Money($amount, new Currency($currency)), new DateTimeImmutable($bookingDate), new DateTimeImmutable($valueDate));
         if (isset($entryXml->RvslInd) && (string) $entryXml->RvslInd === 'true') {
             $entry->setReversalIndicator(true);
         }
         if (isset($entryXml->NtryRef) && (string) $entryXml->NtryRef) {
             $entry->setReference((string) $entryXml->NtryRef);
         }
         if (isset($entryXml->NtryDtls->Btch->PmtInfId) && (string) $entryXml->NtryDtls->Btch->PmtInfId) {
             $entry->setBatchPaymentId((string) $entryXml->NtryDtls->Btch->PmtInfId);
         }
         $this->addTransactionDetailsToEntry($entryXml, $entry);
         $statement->addEntry($entry);
         $index++;
     }
 }
开发者ID:Grummfy,项目名称:camt,代码行数:31,代码来源:Decoder.php

示例3: convert

 /**
  * @param \Money\Money|string $amount
  * @param \Money\Currency|string $from
  * @param \Money\Currency|string $to
  * @return \Money\Money
  */
 public function convert($amount, $from, $to)
 {
     if ($from instanceof Currency == false) {
         $from = new Currency(strtoupper($from));
     }
     if ($to instanceof Currency == false) {
         $to = new Currency(strtoupper($to));
     }
     if ($amount instanceof Money == false) {
         $money = new Money(Money::stringToUnits($amount), $from);
     } else {
         $money = $amount;
     }
     $pair = $this->fetchCached($from, $to);
     if ($pair == null) {
         $pair = $this->provider->getCurrencyPair($from, $to);
         $this->saveCached($pair);
     }
     $converted = $pair->convert($money);
     return $converted;
 }
开发者ID:morbicer,项目名称:converter-bundle,代码行数:27,代码来源:Convert.php

示例4: testStringToUnits

 /**
  * @dataProvider provideStrings
  */
 public function testStringToUnits($string, $units)
 {
     $this->assertEquals($units, Money::stringToUnits($string));
 }
开发者ID:hemeragestao,项目名称:money,代码行数:7,代码来源:MoneyTest.php

示例5: testInvalidStringToUnit

 /**
  * @expectedException \Money\InvalidArgumentException
  */
 public function testInvalidStringToUnit()
 {
     Money::stringToUnits('This should be an invalid string');
 }
开发者ID:frederikbosch,项目名称:money,代码行数:7,代码来源:MoneyTest.php

示例6: testStringToUnits

 public function testStringToUnits()
 {
     foreach ($this->moneystrings() as $array) {
         $this->assertEquals($array[1], Money::stringToUnits($array[0]));
     }
 }
开发者ID:SerdarSanri,项目名称:laravel-money,代码行数:6,代码来源:MoneyTest.php

示例7: testInvalidStringToUnits

 /**
  * @expectedException InvalidArgumentException
  */
 public function testInvalidStringToUnits()
 {
     Money::stringToUnits('invalid units');
 }
开发者ID:srtfisher,项目名称:money,代码行数:7,代码来源:MoneyTest.php


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