Esempio n. 1
0
File: Math.php Progetto: kingsj/core
 /**
  * Format currency as parts 
  * 
  * @param float                 $value    Value
  * @param \XLite\Model\Currency $currency Currency
  *  
  * @return array
  */
 public function formatParts($value, \XLite\Model\Currency $currency)
 {
     $value = $currency->roundValue($value);
     $parts = array();
     if (0 > $value) {
         $parts['sign'] = '-';
     }
     if (!$currency->getPrefix() && !$currency->getSuffix()) {
         $parts['prefix'] = $currency->getCode();
     } elseif ($currency->getPrefix()) {
         $parts['prefix'] = $currency->getPrefix();
     }
     $parts['integer'] = number_format(floor(abs($value)), 0, '', $currency->getThousandDelimiter());
     if (0 < $currency->getE()) {
         $parts['decimalDelimiter'] = $currency->getDecimalDelimiter();
         $parts['decimal'] = substr(strval(abs($value != 0 ? $value : 1) * pow(10, $currency->getE())), -1 * $currency->getE());
     }
     if ($currency->getSuffix()) {
         $parts['suffix'] = $currency->getSuffix();
     }
     return $parts;
 }
 /**
  * {@inheritDoc}
  */
 public function getPrefix()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getPrefix', array());
     return parent::getPrefix();
 }