diff --git a/src/Speller.php b/src/Speller.php index 71c4175..309a851 100644 --- a/src/Speller.php +++ b/src/Speller.php @@ -24,16 +24,21 @@ abstract class Speller const CURRENCY_US_DOLLAR = 'USD'; private static $languages = array( - 'en' => languages\English::class, - 'es' => languages\Spanish::class, - 'et' => languages\Estonian::class, - 'lt' => languages\Lithuanian::class, - 'lv' => languages\Latvian::class, - 'ru' => languages\Russian::class, + self::LANGUAGE_ENGLISH => languages\English::class, + self::LANGUAGE_ESTONIAN => languages\Estonian::class, + self::LANGUAGE_LATVIAN => languages\Latvian::class, + self::LANGUAGE_LITHUANIAN => languages\Lithuanian::class, + self::LANGUAGE_RUSSIAN => languages\Russian::class, + self::LANGUAGE_SPANISH => languages\Spanish::class, ); private static $currencies = array( - 'EUR', 'LTL', 'LVL', 'RUR', 'USD', 'GBP', + self::CURRENCY_EURO, + self::CURRENCY_BRITISH_POUND, + self::CURRENCY_LATVIAN_LAT, + self::CURRENCY_LITHUANIAN_LIT, + self::CURRENCY_RUSSIAN_ROUBLE, + self::CURRENCY_US_DOLLAR, ); protected $minus; diff --git a/src/languages/English.php b/src/languages/English.php index f28932e..70c6177 100644 --- a/src/languages/English.php +++ b/src/languages/English.php @@ -99,30 +99,30 @@ protected function spellExponent($type, $number, $currency) protected function getCurrencyName($type, $number, $currency) { static $names = array( - 'EUR' => array( + self::CURRENCY_EURO => array( 'whole' => array('euro', 'euro'), 'decimal' => array('cent', 'cents'), ), - 'LTL' => array( - 'whole' => array('litas', 'litai'), - 'decimal' => array('centas', 'centai'), + self::CURRENCY_BRITISH_POUND => array( + 'whole' => array('pound', 'pounds'), + 'decimal' => array('penny', 'pennies'), ), - 'LVL' => array( + self::CURRENCY_LATVIAN_LAT => array( 'whole' => array('lat', 'lats'), 'decimal' => array('santim', 'santims'), ), - 'RUR' => array( + self::CURRENCY_LITHUANIAN_LIT => array( + 'whole' => array('litas', 'litai'), + 'decimal' => array('centas', 'centai'), + ), + self::CURRENCY_RUSSIAN_ROUBLE => array( 'whole' => array('ruble', 'rubles'), 'decimal' => array('kopek', 'kopeks'), ), - 'USD' => array( + self::CURRENCY_US_DOLLAR => array( 'whole' => array('dollar', 'dollars'), 'decimal' => array('cent', 'cents'), ), - 'GBP' => array( - 'whole' => array('pound', 'pounds'), - 'decimal' => array('penny', 'pennies'), - ), ); if (!isset($names[$currency])) diff --git a/src/languages/Estonian.php b/src/languages/Estonian.php index 7e4b6d1..87e2e85 100644 --- a/src/languages/Estonian.php +++ b/src/languages/Estonian.php @@ -116,30 +116,30 @@ protected function spellExponent($type, $number, $currency) protected function getCurrencyName($type, $number, $currency) { static $names = array( - 'EUR' => array( + self::CURRENCY_EURO => array( 'whole' => array('euro', 'eurot'), 'decimal' => array('sent', 'senti'), ), - 'LTL' => array( - 'whole' => array('litt', 'litti'), - 'decimal' => array('sent', 'senti'), + self::CURRENCY_BRITISH_POUND => array( + 'whole' => array('nael', 'naela'), + 'decimal' => array('penn', 'penni'), ), - 'LVL' => array( + self::CURRENCY_LATVIAN_LAT => array( 'whole' => array('latt', 'latti'), 'decimal' => array('santiim', 'santiimi'), ), - 'RUR' => array( + self::CURRENCY_LITHUANIAN_LIT => array( + 'whole' => array('litt', 'litti'), + 'decimal' => array('sent', 'senti'), + ), + self::CURRENCY_RUSSIAN_ROUBLE => array( 'whole' => array('rubla', 'rubla'), 'decimal' => array('kopikas', 'kopikat'), ), - 'USD' => array( + self::CURRENCY_US_DOLLAR => array( 'whole' => array('dollar', 'dollarit'), 'decimal' => array('sent', 'senti'), ), - 'GBP' => array( - 'whole' => array('nael', 'naela'), - 'decimal' => array('penn', 'penni'), - ), ); if (!isset($names[$currency])) diff --git a/src/languages/Latvian.php b/src/languages/Latvian.php index 0a7b89d..e29fd44 100644 --- a/src/languages/Latvian.php +++ b/src/languages/Latvian.php @@ -106,7 +106,7 @@ private function spellSingle($digit, $isDecimalPart, $currency) 9 => 'deviņas', ); - if ($isDecimalPart && ($currency === 'RUR')) + if ($isDecimalPart && ($currency === self::CURRENCY_RUSSIAN_ROUBLE)) { // russian kopek nouns are feminine gender in Latvian return $singlesFeminine[intval($digit)]; @@ -146,30 +146,30 @@ protected function spellExponent($type, $number, $currency) protected function getCurrencyName($type, $number, $currency) { static $names = array( - 'EUR' => array( + self::CURRENCY_EURO => array( 'whole' => array('eiro', 'eiro', 'eiro'), 'decimal' => array('cents', 'centi', 'centu'), ), - 'LTL' => array( - 'whole' => array('lits', 'liti', 'litu'), - 'decimal' => array('cents', 'centi', 'centu'), + self::CURRENCY_BRITISH_POUND => array( + 'whole' => array('mārciņa', 'mārciņas', 'mārciņu'), + 'decimal' => array('penijs', 'peniji', 'peniju'), ), - 'LVL' => array( + self::CURRENCY_LATVIAN_LAT => array( 'whole' => array('lats', 'lati', 'latu'), 'decimal' => array('santīms', 'santīmi', 'santīmu'), ), - 'RUR' => array( + self::CURRENCY_LITHUANIAN_LIT => array( + 'whole' => array('lits', 'liti', 'litu'), + 'decimal' => array('cents', 'centi', 'centu'), + ), + self::CURRENCY_RUSSIAN_ROUBLE => array( 'whole' => array('rublis', 'rubļi', 'rubļu'), 'decimal' => array('kapeika', 'kapeikas', 'kapeiku'), ), - 'USD' => array( + self::CURRENCY_US_DOLLAR => array( 'whole' => array('dolārs', 'dolāri', 'dolāru'), 'decimal' => array('cents', 'centi', 'centu'), ), - 'GBP' => array( - 'whole' => array('mārciņa', 'mārciņas', 'mārciņu'), - 'decimal' => array('penijs', 'peniji', 'peniju'), - ), ); if (!isset($names[$currency])) diff --git a/src/languages/Lithuanian.php b/src/languages/Lithuanian.php index fdf5b86..9022d9b 100644 --- a/src/languages/Lithuanian.php +++ b/src/languages/Lithuanian.php @@ -124,30 +124,30 @@ protected function spellExponent($type, $number, $currency) protected function getCurrencyName($type, $number, $currency) { static $names = array( - 'EUR' => array( + self::CURRENCY_EURO => array( 'whole' => array('euras', 'eurai', 'eurų'), 'decimal' => array('centas', 'centai', 'centų'), ), - 'LTL' => array( - 'whole' => array('litas', 'litai', 'litų'), - 'decimal' => array('centas', 'centai', 'centų'), + self::CURRENCY_BRITISH_POUND => array( + 'whole' => array('svaras', 'svarai', 'svarų'), + 'decimal' => array('pensas', 'pensai', 'pensų'), ), - 'LVL' => array( + self::CURRENCY_LATVIAN_LAT => array( 'whole' => array('latas', 'latai', 'latų'), 'decimal' => array('santimas', 'santimai', 'santimų'), ), - 'RUR' => array( + self::CURRENCY_LITHUANIAN_LIT => array( + 'whole' => array('litas', 'litai', 'litų'), + 'decimal' => array('centas', 'centai', 'centų'), + ), + self::CURRENCY_RUSSIAN_ROUBLE => array( 'whole' => array('rublis', 'rubliai', 'rublių'), 'decimal' => array('kapeika', 'kapeikos', 'kapeikų'), ), - 'USD' => array( + self::CURRENCY_US_DOLLAR => array( 'whole' => array('dolaras', 'dolarai', 'dolarų'), 'decimal' => array('centas', 'centai', 'centų'), ), - 'GBP' => array( - 'whole' => array('svaras', 'svarai', 'svarų'), - 'decimal' => array('pensas', 'pensai', 'pensų'), - ), ); if (!isset($names[$currency])) diff --git a/src/languages/Russian.php b/src/languages/Russian.php index fc359bf..0241e1d 100644 --- a/src/languages/Russian.php +++ b/src/languages/Russian.php @@ -107,7 +107,7 @@ private function spellSingle($digit, $groupOfThrees, $isDecimalPart, $currency) ); if (($groupOfThrees === 2) // thousands - || ($isDecimalPart && ($currency === 'RUR'))) // russian kopeks + || ($isDecimalPart && ($currency === self::CURRENCY_RUSSIAN_ROUBLE))) // russian kopeks { return $singlesFeminine[intval($digit)]; } @@ -158,30 +158,30 @@ protected function spellExponent($type, $number, $currency) protected function getCurrencyName($type, $number, $currency) { static $names = array( - 'EUR' => array( + self::CURRENCY_EURO => array( 'whole' => array('евро', 'евро', 'евро'), 'decimal' => array('цент', 'цента', 'центов'), ), - 'LTL' => array( - 'whole' => array('лит', 'лита', 'литов'), - 'decimal' => array('цент', 'цента', 'центов'), + self::CURRENCY_BRITISH_POUND => array( + 'whole' => array('фунт', 'фунта', 'фунтов'), + 'decimal' => array('пенни', 'пенса', 'пенсов'), ), - 'LVL' => array( + self::CURRENCY_LATVIAN_LAT => array( 'whole' => array('лат', 'лата', 'латов'), 'decimal' => array('сантим', 'сантима', 'сантимов'), ), - 'RUR' => array( + self::CURRENCY_LITHUANIAN_LIT => array( + 'whole' => array('лит', 'лита', 'литов'), + 'decimal' => array('цент', 'цента', 'центов'), + ), + self::CURRENCY_RUSSIAN_ROUBLE => array( 'whole' => array('рубль', 'рубля', 'рублей'), 'decimal' => array('копейка', 'копейки', 'копеек'), ), - 'USD' => array( + self::CURRENCY_US_DOLLAR => array( 'whole' => array('доллар', 'доллара', 'долларов'), 'decimal' => array('цент', 'цента', 'центов'), ), - 'GBP' => array( - 'whole' => array('фунт', 'фунта', 'фунтов'), - 'decimal' => array('пенни', 'пенса', 'пенсов'), - ), ); if (!isset($names[$currency])) diff --git a/src/languages/Spanish.php b/src/languages/Spanish.php index aeaa3ce..ff6f668 100644 --- a/src/languages/Spanish.php +++ b/src/languages/Spanish.php @@ -131,30 +131,30 @@ protected function getCurrencyName($type, $number, $currency) { // TODO some of these spellings are extremely hard to find and are probably incorrect static $names = array( - 'EUR' => array( + self::CURRENCY_EURO => array( 'whole' => array('euro', 'euros'), 'decimal' => array('centime', 'centimes'), ), - 'LTL' => array( - 'whole' => array('litas', 'litas'), - 'decimal' => array('cent', 'cents'), + self::CURRENCY_BRITISH_POUND => array( + 'whole' => array('libra esterlina', 'libras esterlinas'), + 'decimal' => array('penique', 'peniques'), ), - 'LVL' => array( + self::CURRENCY_LATVIAN_LAT => array( 'whole' => array('lat', 'lats'), 'decimal' => array('sentim', 'sentims'), ), - 'RUR' => array( + self::CURRENCY_LITHUANIAN_LIT => array( + 'whole' => array('litas', 'litas'), + 'decimal' => array('cent', 'cents'), + ), + self::CURRENCY_RUSSIAN_ROUBLE => array( 'whole' => array('rublo ruso', 'rublos rusos'), 'decimal' => array('kopek', 'kopeks'), ), - 'USD' => array( + self::CURRENCY_US_DOLLAR => array( 'whole' => array('dólar estadounidense', 'dólares estadounidenses'), 'decimal' => array('centavo', 'centavos'), ), - 'GBP' => array( - 'whole' => array('libra esterlina', 'libras esterlinas'), - 'decimal' => array('penique', 'peniques'), - ), ); if (!isset($names[$currency]))