@@ -32,36 +32,45 @@ |
||
| 32 | 32 | |
| 33 | 33 | public function detectClass($len) |
| 34 | 34 | { |
| 35 | - if($len == 1) |
|
| 36 | - return "A"; |
|
| 35 | + if($len == 1) { |
|
| 36 | + return "A"; |
|
| 37 | + } |
|
| 37 | 38 | |
| 38 | 39 | |
| 39 | - if($len == 2) |
|
| 40 | - return "B"; |
|
| 40 | + if($len == 2) { |
|
| 41 | + return "B"; |
|
| 42 | + } |
|
| 41 | 43 | |
| 42 | 44 | |
| 43 | - if($len == 3) |
|
| 44 | - return "C"; |
|
| 45 | + if($len == 3) { |
|
| 46 | + return "C"; |
|
| 47 | + } |
|
| 45 | 48 | |
| 46 | 49 | |
| 47 | - if($len == 4) |
|
| 48 | - return "D"; |
|
| 50 | + if($len == 4) { |
|
| 51 | + return "D"; |
|
| 52 | + } |
|
| 49 | 53 | |
| 50 | 54 | |
| 51 | - if($len == 5) |
|
| 52 | - return "E"; |
|
| 55 | + if($len == 5) { |
|
| 56 | + return "E"; |
|
| 57 | + } |
|
| 53 | 58 | |
| 54 | - if($len == 6) |
|
| 55 | - return "F"; |
|
| 59 | + if($len == 6) { |
|
| 60 | + return "F"; |
|
| 61 | + } |
|
| 56 | 62 | |
| 57 | - if($len == 7) |
|
| 58 | - return "G"; |
|
| 63 | + if($len == 7) { |
|
| 64 | + return "G"; |
|
| 65 | + } |
|
| 59 | 66 | |
| 60 | - if($len == 8) |
|
| 61 | - return "H"; |
|
| 67 | + if($len == 8) { |
|
| 68 | + return "H"; |
|
| 69 | + } |
|
| 62 | 70 | |
| 63 | - if($len == 9) |
|
| 64 | - return "I"; |
|
| 71 | + if($len == 9) { |
|
| 72 | + return "I"; |
|
| 73 | + } |
|
| 65 | 74 | |
| 66 | 75 | } |
| 67 | 76 | } |
| 68 | 77 | \ No newline at end of file |
@@ -10,9 +10,10 @@ |
||
| 10 | 10 | public function initValidation() |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | - if (is_numeric($this->parsed_number)) |
|
| 14 | - return $this; |
|
| 15 | - else |
|
| 16 | - die('is not right number '); |
|
| 13 | + if (is_numeric($this->parsed_number)) { |
|
| 14 | + return $this; |
|
| 15 | + } else { |
|
| 16 | + die('is not right number '); |
|
| 17 | + } |
|
| 17 | 18 | } |
| 18 | 19 | } |
| 19 | 20 | \ No newline at end of file |
@@ -26,12 +26,13 @@ discard block |
||
| 26 | 26 | ]; |
| 27 | 27 | if ($arr == $detecd_array) |
| 28 | 28 | { |
| 29 | - if ($arr[0] == 0 and $arr[1]>=1 and $arr[1]<=10) |
|
| 30 | - $this->is_main1_currency = true; |
|
| 31 | - elseif ($arr[0]>=1 and $arr[1]>=1 and $arr[1]<=9) |
|
| 32 | - $this->is_main1_currency = false; |
|
| 33 | - elseif ($arr[0]>=2) |
|
| 34 | - $this->is_main1_currency = false; |
|
| 29 | + if ($arr[0] == 0 and $arr[1]>=1 and $arr[1]<=10) { |
|
| 30 | + $this->is_main1_currency = true; |
|
| 31 | + } elseif ($arr[0]>=1 and $arr[1]>=1 and $arr[1]<=9) { |
|
| 32 | + $this->is_main1_currency = false; |
|
| 33 | + } elseif ($arr[0]>=2) { |
|
| 34 | + $this->is_main1_currency = false; |
|
| 35 | + } |
|
| 35 | 36 | } |
| 36 | 37 | |
| 37 | 38 | |
@@ -41,55 +42,67 @@ discard block |
||
| 41 | 42 | |
| 42 | 43 | |
| 43 | 44 | |
| 44 | - if($arr[0]==0 and $arr[1]==0) |
|
| 45 | - return ''; |
|
| 45 | + if($arr[0]==0 and $arr[1]==0) { |
|
| 46 | + return ''; |
|
| 47 | + } |
|
| 46 | 48 | |
| 47 | 49 | |
| 48 | 50 | |
| 49 | - if($arr[0]==0) |
|
| 50 | - return $this->ones[$arr[1]]; |
|
| 51 | + if($arr[0]==0) { |
|
| 52 | + return $this->ones[$arr[1]]; |
|
| 53 | + } |
|
| 51 | 54 | |
| 52 | 55 | |
| 53 | 56 | |
| 54 | - if($arr[0]==1 and $arr[1]==1) |
|
| 55 | - return $this->ones[11]; |
|
| 57 | + if($arr[0]==1 and $arr[1]==1) { |
|
| 58 | + return $this->ones[11]; |
|
| 59 | + } |
|
| 56 | 60 | |
| 57 | 61 | |
| 58 | - if($arr[0]==1 and $arr[1]==0) |
|
| 59 | - return $this->ones[10]; |
|
| 62 | + if($arr[0]==1 and $arr[1]==0) { |
|
| 63 | + return $this->ones[10]; |
|
| 64 | + } |
|
| 60 | 65 | |
| 61 | 66 | |
| 62 | 67 | |
| 63 | - if($arr[1]==0) |
|
| 64 | - return $this->tens[$arr[0]]; |
|
| 68 | + if($arr[1]==0) { |
|
| 69 | + return $this->tens[$arr[0]]; |
|
| 70 | + } |
|
| 65 | 71 | |
| 66 | 72 | |
| 67 | 73 | |
| 68 | - if($arr[0]>1) |
|
| 69 | - return $this->ones[$arr[1]] . $this->config['connection_tool'] . $this->tens[$arr[0]]; |
|
| 74 | + if($arr[0]>1) { |
|
| 75 | + return $this->ones[$arr[1]] . $this->config['connection_tool'] . $this->tens[$arr[0]]; |
|
| 76 | + } |
|
| 70 | 77 | |
| 71 | - if(in_array($arr[1],[1,2])) |
|
| 72 | - return $this->others[$arr[1]] . ' ' . $this->tens[$arr[0]]; |
|
| 78 | + if(in_array($arr[1],[1,2])) { |
|
| 79 | + return $this->others[$arr[1]] . ' ' . $this->tens[$arr[0]]; |
|
| 80 | + } |
|
| 73 | 81 | |
| 74 | 82 | return $this->ones[$arr[1]] . ' ' . $this->tens[$arr[0]]; |
| 75 | 83 | } |
| 76 | 84 | |
| 77 | 85 | public function classC($arr,$len = 3) |
| 78 | 86 | { |
| 79 | - if($arr[0]==0 and $arr[1] == 0 and $arr[2] == 0) |
|
| 80 | - return ''; |
|
| 87 | + if($arr[0]==0 and $arr[1] == 0 and $arr[2] == 0) { |
|
| 88 | + return ''; |
|
| 89 | + } |
|
| 81 | 90 | |
| 82 | - if($arr[0]==0 and $arr[1] == 0) |
|
| 83 | - return $this->ones[$arr[2]]; |
|
| 91 | + if($arr[0]==0 and $arr[1] == 0) { |
|
| 92 | + return $this->ones[$arr[2]]; |
|
| 93 | + } |
|
| 84 | 94 | |
| 85 | - if($arr[0]==0) |
|
| 86 | - return $this->classB([$arr[1],$arr[2]]); |
|
| 95 | + if($arr[0]==0) { |
|
| 96 | + return $this->classB([$arr[1],$arr[2]]); |
|
| 97 | + } |
|
| 87 | 98 | |
| 88 | - if($arr[2] == 0 and $arr[1] == 0) |
|
| 89 | - return $this->hundreds[$arr[0]]; |
|
| 99 | + if($arr[2] == 0 and $arr[1] == 0) { |
|
| 100 | + return $this->hundreds[$arr[0]]; |
|
| 101 | + } |
|
| 90 | 102 | |
| 91 | - if($arr[1]!=0) |
|
| 92 | - return $this->hundreds[$arr[0]] . $this->config['connection_tool'] . $this->classB([$arr[1],$arr[2]]); |
|
| 103 | + if($arr[1]!=0) { |
|
| 104 | + return $this->hundreds[$arr[0]] . $this->config['connection_tool'] . $this->classB([$arr[1],$arr[2]]); |
|
| 105 | + } |
|
| 93 | 106 | |
| 94 | 107 | return $this->hundreds[$arr[0]] . $this->config['connection_tool'] . $this->classA([$arr[2]]); |
| 95 | 108 | } |
@@ -98,14 +111,16 @@ discard block |
||
| 98 | 111 | { |
| 99 | 112 | $classC = [$arr[1],$arr[2],$arr[3]]; |
| 100 | 113 | |
| 101 | - if($arr[0]<=2) |
|
| 102 | - $thousands = $this->thousands[$arr[0]] ; |
|
| 103 | - else |
|
| 104 | - $thousands = $this->ones[$arr[0]] . ' ' . $this->thousands['39']; |
|
| 114 | + if($arr[0]<=2) { |
|
| 115 | + $thousands = $this->thousands[$arr[0]] ; |
|
| 116 | + } else { |
|
| 117 | + $thousands = $this->ones[$arr[0]] . ' ' . $this->thousands['39']; |
|
| 118 | + } |
|
| 105 | 119 | |
| 106 | 120 | |
| 107 | - if($arr[1] == 0 and $arr[2] == 0 and $arr[3] == 0) |
|
| 108 | - return $thousands; |
|
| 121 | + if($arr[1] == 0 and $arr[2] == 0 and $arr[3] == 0) { |
|
| 122 | + return $thousands; |
|
| 123 | + } |
|
| 109 | 124 | |
| 110 | 125 | return $thousands . $this->config['connection_tool'] . $this->classC($classC); |
| 111 | 126 | } |
@@ -183,12 +198,12 @@ discard block |
||
| 183 | 198 | if($arr[1] == 0 && $arr[2]==0) |
| 184 | 199 | { |
| 185 | 200 | $thousands = $this->hundreds[$arr[0]] .' '. $this->thousands[1]; |
| 186 | - }else{ |
|
| 201 | + } else{ |
|
| 187 | 202 | if($arr[1] == 0 ) |
| 188 | 203 | { |
| 189 | 204 | $thousands = $this->hundreds[$arr[0]] .$this->config['connection_tool']. |
| 190 | 205 | $this->ones[$arr[2]] . ' '. $this->thousands[1]; |
| 191 | - }elseif($arr[2] == 0) |
|
| 206 | + } elseif($arr[2] == 0) |
|
| 192 | 207 | { |
| 193 | 208 | if($arr[3] == 0 and $arr[4] == 0 and $arr[5] == 0) |
| 194 | 209 | { |
@@ -218,13 +233,14 @@ discard block |
||
| 218 | 233 | } |
| 219 | 234 | } |
| 220 | 235 | |
| 221 | - }else |
|
| 236 | + } else |
|
| 222 | 237 | { |
| 223 | 238 | return $this->classE([$arr[1],$arr[2],$arr[3],$arr[4],$arr[5]]); |
| 224 | 239 | } |
| 225 | 240 | |
| 226 | - if($this->classC($classC)!='') |
|
| 227 | - return $thousands . $this->config['connection_tool'] . $this->classC($classC); |
|
| 241 | + if($this->classC($classC)!='') { |
|
| 242 | + return $thousands . $this->config['connection_tool'] . $this->classC($classC); |
|
| 243 | + } |
|
| 228 | 244 | return $thousands; |
| 229 | 245 | |
| 230 | 246 | } |
@@ -271,10 +287,11 @@ discard block |
||
| 271 | 287 | $conn = $this->config['connection_tool']; |
| 272 | 288 | } |
| 273 | 289 | |
| 274 | - if (in_array($arr[1], [2, 1])) |
|
| 275 | - $million = $this->others[$arr[1]].$conn.$this->tens[$arr[0]]; |
|
| 276 | - else |
|
| 277 | - $million = $this->ones[$arr[1]].$conn.$this->tens[$arr[0]]; |
|
| 290 | + if (in_array($arr[1], [2, 1])) { |
|
| 291 | + $million = $this->others[$arr[1]].$conn.$this->tens[$arr[0]]; |
|
| 292 | + } else { |
|
| 293 | + $million = $this->ones[$arr[1]].$conn.$this->tens[$arr[0]]; |
|
| 294 | + } |
|
| 278 | 295 | |
| 279 | 296 | if ($arr[1] == 0) |
| 280 | 297 | { |
@@ -282,29 +299,30 @@ discard block |
||
| 282 | 299 | { |
| 283 | 300 | $million = $this->ones[10]; |
| 284 | 301 | $million .= ' '.$this->millions[39]; |
| 285 | - }else |
|
| 302 | + } else |
|
| 286 | 303 | { |
| 287 | 304 | $million = $this->tens[$arr[0]]; |
| 288 | 305 | $million .= ' '.$this->millions[1]; |
| 289 | 306 | } |
| 290 | 307 | |
| 291 | - }else { |
|
| 308 | + } else { |
|
| 292 | 309 | if ($arr[2] == 0 and $arr[3] == 0 and $arr[4] == 0) |
| 293 | 310 | { |
| 294 | 311 | $million .= ' '.$this->millions[1]; |
| 295 | - }else |
|
| 312 | + } else |
|
| 296 | 313 | { |
| 297 | 314 | $million .= ' '.$this->millions[1199]; |
| 298 | 315 | } |
| 299 | 316 | |
| 300 | 317 | } |
| 301 | 318 | |
| 302 | - }else |
|
| 319 | + } else |
|
| 303 | 320 | { |
| 304 | - if (in_array($arr[1], [2, 1])) |
|
| 305 | - $million = $this->others[$arr[1]].' '; |
|
| 306 | - else |
|
| 307 | - $million = $this->ones[$arr[1]].' '; |
|
| 321 | + if (in_array($arr[1], [2, 1])) { |
|
| 322 | + $million = $this->others[$arr[1]].' '; |
|
| 323 | + } else { |
|
| 324 | + $million = $this->ones[$arr[1]].' '; |
|
| 325 | + } |
|
| 308 | 326 | |
| 309 | 327 | |
| 310 | 328 | if ($arr[1] == 0) |
@@ -336,10 +354,11 @@ discard block |
||
| 336 | 354 | $classF = [$arr[3], $arr[4], $arr[5], $arr[6], $arr[7], $arr[8]]; |
| 337 | 355 | |
| 338 | 356 | |
| 339 | - if (in_array($arr[1], [2])) |
|
| 340 | - $million = $this->others[$arr[1]].$this->config['connection_tool'].$this->tens[$arr[0]]; |
|
| 341 | - else |
|
| 342 | - $million = $this->ones[$arr[1]].$this->config['connection_tool'].$this->tens[$arr[0]]; |
|
| 357 | + if (in_array($arr[1], [2])) { |
|
| 358 | + $million = $this->others[$arr[1]].$this->config['connection_tool'].$this->tens[$arr[0]]; |
|
| 359 | + } else { |
|
| 360 | + $million = $this->ones[$arr[1]].$this->config['connection_tool'].$this->tens[$arr[0]]; |
|
| 361 | + } |
|
| 343 | 362 | |
| 344 | 363 | |
| 345 | 364 | if ($arr[1] == 0) |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | if (count($arr)>=3) |
| 38 | 38 | { |
| 39 | 39 | $this->after_comma_array = [$arr[0], $arr[1]]; |
| 40 | - }else |
|
| 40 | + } else |
|
| 41 | 41 | { |
| 42 | 42 | $this->after_comma_array = $arr; |
| 43 | 43 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | if ($this->is_main1_currency){ |
| 111 | 111 | $result .= $this->result_before_comma.' '.$this->config['currencies'][$currency]['main1']; |
| 112 | 112 | |
| 113 | - }else{ |
|
| 113 | + } else{ |
|
| 114 | 114 | $result .= $this->result_before_comma.' '.$this->config['currencies'][$currency]['main2']; |
| 115 | 115 | |
| 116 | 116 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | ])){ |
| 121 | 121 | $result .= $this->config['connection_tool'].$this->result_after_comma.' '. |
| 122 | 122 | $this->config['currencies'][$currency]['multi']; |
| 123 | - }else{ |
|
| 123 | + } else{ |
|
| 124 | 124 | $result .= $this->config['connection_tool'].$this->result_after_comma.' '. |
| 125 | 125 | $this->config['currencies'][$currency]['single']; |
| 126 | 126 | } |