/** * Gets the fractional part of the provided amount * * @param Amount $amount * * @return string */ protected function getFractionalPart(Amount $amount) { $number = new Number($amount->getNumber()->getSubunits()); //if the subunit format is numbers, we want to simply return a fraction if ($amount->getSubunitFormat()->getFormat() === SubunitFormat::NUMBERS) { return $number->getValue() . '/100'; } $unitName = $this->currencyDictionary->getSubunitName($amount->getCurrency(), !$this->isSingular($number)); return $this->numberTransformer->toWords($number) . ' ' . $unitName; }
/** * Convert given number to words * * @param Amount $amount * * @return string */ public function toWords(Amount $amount) { $this->guardAgainstUnexistingCurrency($amount->getCurrency()); $unit = $this->toWordsWithGrammarCasedDescription($amount->getNumber(), CurrencyDictionary::getUnits()['PLN']); if ($amount->getSubunitFormat()->getFormat() === SubunitFormat::WORDS) { $subunit = $this->toWordsWithGrammarCasedDescription(new Number($amount->getNumber()->getSubunits()), CurrencyDictionary::getSubunits()['PLN']); } else { $subunit = sprintf('%d/100', $amount->getNumber()->getSubunits()); } return $unit . ' ' . $subunit; }