Пример #1
0
 /**
  * @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);
 }
Пример #2
0
 /**
  * @param Currency $currency
  * @return bool
  */
 public function isEqualTo(Currency $currency)
 {
     return $this->getCode() == $currency->getCode();
 }