Skip to content
This repository was archived by the owner on Jul 1, 2019. It is now read-only.

Commit dd37514

Browse files
author
Andrey Helldar
authored
Merge pull request #7 from dkulyk/master
Fix numbers x10 - x19, x0x
2 parents 91de3bb + eb28bab commit dd37514

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/DigitText.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ public static function text($digit = 0.0, $lang = 'en', $currency = false)
9191

9292
$groups = str_split(self::dsort((int) $digit), 3);
9393
$result = '';
94-
9594
for ($i = count($groups) - 1; $i >= 0; $i--) {
9695
if ((int) $groups[$i] > 0) {
9796
$result .= ' '.trim(self::digits($groups[$i], $i));
@@ -194,15 +193,17 @@ private static function digits($digit = 0.0, $id = 0)
194193

195194
$digitUnsorted = (int) self::dsort($digit);
196195

197-
if ($digitUnsorted > 0 && $digitUnsorted < 20) {
198-
return trim(self::$texts[$id == 1 ? 3 : 0][(int) $digitUnsorted].self::decline($id, $digitUnsorted));
199-
}
200-
201196
$array = str_split((string) $digit, 1);
202197
$result = '';
203198

204199
for ($i = count($array) - 1; $i >= 0; $i--) {
205-
$result .= ' '.self::$texts[$id == 1 ? $i + 3 : $i][$array[$i]];
200+
if ($i === 1 && $array[$i] == '1') {
201+
$d = $array[$i].$array[$i - 1];
202+
$result .= ' '.trim(self::$texts[$id == 1 ? 3 : 0][(int) $d]);
203+
$i--;
204+
} elseif ((int) $array[$i] > 0) {
205+
$result .= ' '.self::$texts[$id == 1 ? $i + 3 : $i][$array[$i]];
206+
}
206207
}
207208

208209
return trim($result).self::decline($id, $digitUnsorted);

0 commit comments

Comments
 (0)