/** * 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 roundValue($value) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'roundValue', array($value)); return parent::roundValue($value); }