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

Commit a0981c7

Browse files
author
Andrey Helldar
authored
Merge pull request #10 from andrey-helldar/analysis-XVABk3
Apply fixes from StyleCI
2 parents 438d343 + 29d9deb commit a0981c7

File tree

9 files changed

+303
-303
lines changed

9 files changed

+303
-303
lines changed

phpunit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
|
1212
*/
1313

14-
require __DIR__ . '/vendor/autoload.php';
14+
require __DIR__.'/vendor/autoload.php';
1515

1616
/*
1717
|--------------------------------------------------------------------------

src/DigitServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@ protected function registerDigitText()
7070
*/
7171
public function provides()
7272
{
73-
return ['digittext', Facade::class];
73+
return array('digittext', Facade::class);
7474
}
7575
}

src/DigitText.php

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
*/
3333
function digit_text()
3434
{
35-
return (new \Helldar\DigitText\DigitText());
35+
return new \Helldar\DigitText\DigitText();
3636
}

src/lang/de.php

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@
2323
* THE SOFTWARE.
2424
*/
2525

26-
return [
27-
0 => [
28-
0 => '',
29-
1 => 'ein',
30-
2 => 'zwei',
31-
3 => 'drei',
32-
4 => 'vier',
33-
5 => 'fünf',
34-
6 => 'sechs',
35-
7 => 'sieben',
36-
8 => 'acht',
37-
9 => 'neun',
26+
return array(
27+
0 => array(
28+
0 => '',
29+
1 => 'ein',
30+
2 => 'zwei',
31+
3 => 'drei',
32+
4 => 'vier',
33+
5 => 'fünf',
34+
6 => 'sechs',
35+
7 => 'sieben',
36+
8 => 'acht',
37+
9 => 'neun',
3838
10 => 'zehn',
3939
11 => 'elf',
4040
12 => 'zwölf',
@@ -45,9 +45,9 @@
4545
17 => 'siebzehn',
4646
18 => 'achtzehn',
4747
19 => 'neunzehn',
48-
],
48+
),
4949

50-
1 => [
50+
1 => array(
5151
2 => 'zwanzig',
5252
3 => 'dreißig',
5353
4 => 'vierzig',
@@ -56,9 +56,9 @@
5656
7 => 'siebzig',
5757
8 => 'achtzig',
5858
9 => 'neunzig',
59-
],
59+
),
6060

61-
2 => [
61+
2 => array(
6262
0 => '',
6363
1 => 'hundert',
6464
2 => 'zweihundert',
@@ -69,19 +69,19 @@
6969
7 => 'siebenhundert',
7070
8 => 'achthundert',
7171
9 => 'neunhundert',
72-
],
72+
),
7373

74-
3 => [
75-
0 => '',
76-
1 => 'einer',
77-
2 => 'zwei',
78-
3 => 'drei',
79-
4 => 'vier',
80-
5 => 'fünf',
81-
6 => 'sechs',
82-
7 => 'sieben',
83-
8 => 'acht',
84-
9 => 'neun',
74+
3 => array(
75+
0 => '',
76+
1 => 'einer',
77+
2 => 'zwei',
78+
3 => 'drei',
79+
4 => 'vier',
80+
5 => 'fünf',
81+
6 => 'sechs',
82+
7 => 'sieben',
83+
8 => 'acht',
84+
9 => 'neun',
8585
10 => 'zehn',
8686
11 => 'elf',
8787
12 => 'zwölf',
@@ -92,9 +92,9 @@
9292
17 => 'siebzehn',
9393
18 => 'achtzehn',
9494
19 => 'neunzehn',
95-
],
95+
),
9696

97-
4 => [
97+
4 => array(
9898
0 => '',
9999
2 => 'zwanzig',
100100
3 => 'dreißig',
@@ -104,9 +104,9 @@
104104
7 => 'siebzig',
105105
8 => 'achtzig',
106106
9 => 'neunzig',
107-
],
107+
),
108108

109-
5 => [
109+
5 => array(
110110
0 => '',
111111
1 => 'hundert',
112112
2 => 'zweihundert',
@@ -117,25 +117,25 @@
117117
7 => 'siebenhundert',
118118
8 => 'achthundert',
119119
9 => 'neunhundert',
120-
],
120+
),
121121

122-
'currency' => [
123-
'int' => 'Mark',
122+
'currency' => array(
123+
'int' => 'Mark',
124124
'fraction' => 'cent',
125125
'position' => 'after',
126-
],
126+
),
127127

128128
'zero' => 'null',
129129

130-
'thousands' => [
130+
'thousands' => array(
131131
0 => 'tausende',
132132
1 => 'tausend',
133133
2 => 'tausende',
134-
],
134+
),
135135

136-
'millions' => [
136+
'millions' => array(
137137
0 => 'million',
138138
1 => 'million',
139139
2 => 'million',
140-
],
141-
];
140+
),
141+
);

0 commit comments

Comments
 (0)