Exemplo n.º 1
0
Arquivo: Math.php Projeto: 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;
 }
Exemplo n.º 2
0
 /**
  * {@inheritDoc}
  */
 public function getE()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getE', array());
     return parent::getE();
 }