/** * @param string $currency * @param int $decimal * @param int $fraction * * @throws NumberToWordsException * @return string */ public function toCurrencyWords($currency, $decimal, $fraction = null) { $currency = strtoupper($currency); if (!array_key_exists($currency, PolishDictionary::$currencyNames)) { throw new NumberToWordsException(sprintf('Currency "%s" is not available for "%s" language', $currency, get_class($this))); } $currencyNames = PolishDictionary::$currencyNames[$currency]; $words = []; $words[] = $this->toWords($decimal); $words[] = $this->inflector->inflectNounByNumber($decimal, $currencyNames[0][0], $currencyNames[0][1], $currencyNames[0][2]); if (null !== $fraction) { $words[] = $this->toWords($fraction); $words[] = $this->inflector->inflectNounByNumber($fraction, $currencyNames[1][0], $currencyNames[1][1], $currencyNames[1][2]); } return implode(' ', $words); }
/** * @dataProvider providerItInflectsNounsByNumbers */ public function testItInflectsNounsByNumbers($number, $expectedNoun) { $polishInflector = new PolishInflector(); $inflected = $polishInflector->inflectNounByNumber($number, self::$nouns[0], self::$nouns[1], self::$nouns[2]); self::assertEquals($expectedNoun, $inflected); }
/** * @param int $number * @param int $power * * @return string */ public function inflectExponent($number, $power) { return $this->inflector->inflectNounByNumber($number, PolishDictionary::$exponent[$power][0], PolishDictionary::$exponent[$power][1], PolishDictionary::$exponent[$power][2]); }