コード例 #1
0
ファイル: NumberFormatter.php プロジェクト: msooon/hubzilla
 /**
  * {@inheritdoc}
  */
 public function parseCurrency($value, CurrencyInterface $currency)
 {
     $replacements = array($this->numberFormat->getDecimalSeparator() => '.', $this->numberFormat->getPlusSign() => '+', $this->numberFormat->getMinusSign() => '-', $this->numberFormat->getGroupingSeparator() => '', $currency->getCurrencyCode() => '', $currency->getSymbol() => '', ' ' => '', chr(0xc2) . chr(0xa0) => '');
     $numberingSystem = $this->numberFormat->getNumberingSystem();
     if (isset($this->digits[$numberingSystem])) {
         // Convert the localized digits back to latin.
         $replacements += array_flip($this->digits[$numberingSystem]);
     }
     $value = strtr($value, $replacements);
     if (substr($value, 0, 1) == '(' && substr($value, -1, 1) == ')') {
         // This is an accounting formatted negative number.
         $value = '-' . str_replace(array('(', ')'), '', $value);
     }
     return is_numeric($value) ? $value : false;
 }
コード例 #2
0
ファイル: Price.php プロジェクト: kemeice/pricing
 /**
  * Returns the string representation of the price (amount, currency code).
  *
  * @return string
  */
 public function __toString()
 {
     return $this->amount . ' ' . $this->currency->getCurrencyCode();
 }