/** * @return string */ public function format() { $format = $this->currency->getFormat(); $amountInString = $this->amount; $parts = explode(".", $amountInString); $hasDecimal = count($parts) > 1; $reversedIntAmount = strrev($parts[0]); $amountInString = ''; for ($i = 0; $i < strlen($reversedIntAmount); $i++) { if ($i != 0 && $i % 3 == 0) { $amountInString .= $this->currency->getThousandsDivider(); } $amountInString .= $reversedIntAmount[$i]; } $amountInString = strrev($amountInString); $decimal = $hasDecimal ? $parts[1] : "00"; $amountInString .= $this->currency->getDecimalPoint() . $decimal; return str_replace(Currency::FORMAT_PLACEHOLDER, $amountInString, $format); }
/** * @param Currency $currency * @return bool */ public function isEqualTo(Currency $currency) { return $this->getCode() == $currency->getCode(); }