@@ -75,7 +75,7 @@ class DigitText
7575 */
7676 private function lang ($ lang = 'en ' )
7777 {
78- $ filename = sprintf ('%s/lang/%s.php ' , __DIR__ , trim ($ lang ));
78+ $ filename = sprintf ('%s/lang/%s.php ' , __DIR__ , trim ($ lang ));
7979 $ this ->lang = file_exists ($ filename ) ? trim ($ lang ) : $ this ->lang_fallback ;
8080 }
8181
@@ -86,7 +86,7 @@ private function lang($lang = 'en')
8686 */
8787 private function currency ($ is_currency = false )
8888 {
89- $ this ->is_currency = (bool )$ is_currency ;
89+ $ this ->is_currency = (bool ) $ is_currency ;
9090 }
9191
9292 /**
@@ -136,10 +136,10 @@ public function text($digit = 0.0, $lang = 'en', $is_currency = false)
136136 // Get the fractional part
137137 $ this ->fraction ();
138138
139- $ groups = str_split ($ this ->digitReverse ((int )$ this ->digit ), 3 );
140- $ result = [] ;
139+ $ groups = str_split ($ this ->digitReverse ((int ) $ this ->digit ), 3 );
140+ $ result = array () ;
141141 for ($ i = sizeof ($ groups ) - 1 ; $ i >= 0 ; $ i --) {
142- if ((int )$ groups [$ i ] > 0 ) {
142+ if ((int ) $ groups [$ i ] > 0 ) {
143143 $ result [] = $ this ->digits ($ groups [$ i ], $ i );
144144 }
145145 }
@@ -164,16 +164,16 @@ private function fixDigit($digit = null)
164164 return ;
165165 }
166166
167- $ digit = str_replace ([ ', ' , '- ' , ' ' , "' " , '` ' ] , '' , (string )$ digit );
167+ $ digit = str_replace (array ( ', ' , '- ' , ' ' , "' " , '` ' ) , '' , (string ) $ digit );
168168
169- if (strripos ((string )$ digit , '. ' ) === false ) {
170- $ this ->digit = (float )$ digit ;
169+ if (strripos ((string ) $ digit , '. ' ) === false ) {
170+ $ this ->digit = (float ) $ digit ;
171171
172172 return ;
173173 }
174174
175- $ digit = explode ('. ' , $ digit );
176- $ this ->digit = (float )sprintf ('%s.%s ' , intval ($ digit [0 ]), intval ($ digit [1 ]));
175+ $ digit = explode ('. ' , $ digit );
176+ $ this ->digit = (float ) sprintf ('%s.%s ' , intval ($ digit [0 ]), intval ($ digit [1 ]));
177177 }
178178
179179 /**
@@ -185,7 +185,7 @@ private function intl()
185185 {
186186 if ($ this ->is_currency ) {
187187 if (extension_loaded ('php_intl ' )) {
188- return (new \MessageFormatter ($ this ->lang , '{n, spellout} ' ))->format ([ 'n ' => $ this ->digit ] );
188+ return (new \MessageFormatter ($ this ->lang , '{n, spellout} ' ))->format (array ( 'n ' => $ this ->digit ) );
189189 }
190190 }
191191
@@ -197,8 +197,8 @@ private function intl()
197197 */
198198 private function loadTexts ()
199199 {
200- $ filename = sprintf ('%s/lang/%s.php ' , __DIR__ , $ this ->lang );
201- $ lang = file_exists ($ filename ) ? $ this ->lang : $ this ->lang_fallback ;
200+ $ filename = sprintf ('%s/lang/%s.php ' , __DIR__ , $ this ->lang );
201+ $ lang = file_exists ($ filename ) ? $ this ->lang : $ this ->lang_fallback ;
202202 $ this ->texts = require sprintf ('%s/lang/%s.php ' , __DIR__ , $ lang );
203203 }
204204
@@ -215,8 +215,8 @@ private function fraction()
215215 return ;
216216 }
217217
218- $ pos = strripos ((string )$ this ->digit , '. ' );
219- $ this ->surplus = $ pos === false ? 0 : mb_substr ((string )$ this ->digit , $ pos + 1 );
218+ $ pos = strripos ((string ) $ this ->digit , '. ' );
219+ $ this ->surplus = $ pos === false ? 0 : mb_substr ((string ) $ this ->digit , $ pos + 1 );
220220 }
221221
222222 /**
@@ -228,7 +228,7 @@ private function fraction()
228228 */
229229 private function digitReverse ($ digit = '0 ' )
230230 {
231- return strrev ((string )$ digit );
231+ return strrev ((string ) $ digit );
232232 }
233233
234234 /**
@@ -245,24 +245,24 @@ private function digits($digit = 0.0, $id = 0)
245245 return $ this ->texts ['zero ' ];
246246 }
247247
248- $ digitUnsorted = (int )$ this ->digitReverse ($ digit );
248+ $ digitUnsorted = (int ) $ this ->digitReverse ($ digit );
249249
250- $ array = str_split ((string )$ digit , 1 );
251- $ result = [] ;
250+ $ array = str_split ((string ) $ digit , 1 );
251+ $ result = array () ;
252252
253253 for ($ i = sizeof ($ array ) - 1 ; $ i >= 0 ; $ i --) {
254254 if ($ i === 1 && $ array [$ i ] == '1 ' ) {
255- $ d = $ array [$ i ] . $ array [$ i - 1 ];
256- $ result [] = trim ($ this ->texts [$ id == 1 ? 3 : 0 ][(int )$ d ]);
255+ $ d = $ array [$ i ]. $ array [$ i - 1 ];
256+ $ result [] = trim ($ this ->texts [$ id == 1 ? 3 : 0 ][(int ) $ d ]);
257257 $ i --;
258- } elseif ((int )$ array [$ i ] > 0 ) {
258+ } elseif ((int ) $ array [$ i ] > 0 ) {
259259 $ result [] = $ this ->texts [$ id == 1 ? $ i + 3 : $ i ][$ array [$ i ]];
260260 }
261261 }
262262
263263 $ result = implode (($ this ->lang == 'de ' ? 'und ' : ' ' ), $ result );
264264
265- return trim (trim ($ result ) . $ this ->decline ($ id , $ digitUnsorted ));
265+ return trim (trim ($ result ). $ this ->decline ($ id , $ digitUnsorted ));
266266 }
267267
268268 /**
@@ -275,27 +275,27 @@ private function digits($digit = 0.0, $id = 0)
275275 */
276276 private function decline ($ group = 0 , $ digit = 0.0 )
277277 {
278- $ text = (string )((int )$ digit );
279- $ text = (int )$ text [strlen ($ digit ) - 1 ];
280- $ result = '' ;
278+ $ text = (string ) ((int ) $ digit );
279+ $ text = (int ) $ text [strlen ($ digit ) - 1 ];
280+ $ result = '' ;
281281 $ deleter = $ this ->lang == 'de ' ? '' : ' ' ;
282282
283283 switch ($ group ) {
284284 case 1 :
285- $ result = $ deleter . $ this ->texts ['thousands ' ][0 ];
285+ $ result = $ deleter. $ this ->texts ['thousands ' ][0 ];
286286 if ($ text == 1 ) {
287- $ result = $ deleter . $ this ->texts ['thousands ' ][1 ];
287+ $ result = $ deleter. $ this ->texts ['thousands ' ][1 ];
288288 } elseif ($ text >= 2 && $ text <= 4 ) {
289- $ result = $ deleter . $ this ->texts ['thousands ' ][2 ];
289+ $ result = $ deleter. $ this ->texts ['thousands ' ][2 ];
290290 }
291291 break ;
292292
293293 case 2 :
294- $ result = $ deleter . $ this ->texts ['millions ' ][0 ];
294+ $ result = $ deleter. $ this ->texts ['millions ' ][0 ];
295295 if ($ text >= 2 && $ text <= 4 ) {
296- $ result = $ deleter . $ this ->texts ['millions ' ][1 ];
296+ $ result = $ deleter. $ this ->texts ['millions ' ][1 ];
297297 } elseif (($ text >= 5 && $ text <= 9 ) || $ text == 0 ) {
298- $ result = $ deleter . $ this ->texts ['millions ' ][2 ];
298+ $ result = $ deleter. $ this ->texts ['millions ' ][2 ];
299299 }
300300 break ;
301301
@@ -320,18 +320,18 @@ private function getCurrency($content = null)
320320 }
321321
322322 if ($ this ->texts ['currency ' ]['position ' ] == 'before ' ) {
323- $ result = $ this ->texts ['currency ' ]['int ' ] . ' ' . $ content ;
323+ $ result = $ this ->texts ['currency ' ]['int ' ]. ' ' . $ content ;
324324
325325 if ($ this ->surplus > 0 ) {
326- $ result .= '. ' . $ this ->surplus ;
326+ $ result .= '. ' . $ this ->surplus ;
327327 }
328328 } else {
329- $ result = trim ($ content ) . ' ' . $ this ->texts ['currency ' ]['int ' ];
329+ $ result = trim ($ content ). ' ' . $ this ->texts ['currency ' ]['int ' ];
330330
331331 if ($ this ->surplus > 0 ) {
332- $ result .= ' ' . $ this ->surplus . ' ' . $ this ->texts ['currency ' ]['fraction ' ];
332+ $ result .= ' ' . $ this ->surplus . ' ' . $ this ->texts ['currency ' ]['fraction ' ];
333333 } else {
334- $ result .= ' 00 ' . $ this ->texts ['currency ' ]['fraction ' ];
334+ $ result .= ' 00 ' . $ this ->texts ['currency ' ]['fraction ' ];
335335 }
336336 }
337337
0 commit comments