@@ -9,13 +9,13 @@ discard block |
||
9 | 9 | |
10 | 10 | public function setAmount($number = 0) |
11 | 11 | { |
12 | - $this->parsed_number = $number . ''; |
|
12 | + $this->parsed_number = $number.''; |
|
13 | 13 | return $this; |
14 | 14 | } |
15 | 15 | |
16 | 16 | private function split_parsed_number_to_two_number_depend_on_comma() |
17 | 17 | { |
18 | - $arr = explode('.',$this->parsed_number); |
|
18 | + $arr = explode('.', $this->parsed_number); |
|
19 | 19 | $this->parsed_number_array = $arr; |
20 | 20 | $this->all_numbers_len = count($this->parsed_number_array); |
21 | 21 | return $this; |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | |
31 | 31 | private function split_numbers_after_comma_to_array() |
32 | 32 | { |
33 | - if($this->all_numbers_len>=2) |
|
33 | + if ($this->all_numbers_len>=2) |
|
34 | 34 | { |
35 | 35 | $arr = str_split($this->parsed_number_array[1]); |
36 | 36 | |
37 | - if(count($arr)>=3) |
|
37 | + if (count($arr)>=3) |
|
38 | 38 | { |
39 | - $this->after_comma_array = [$arr[0],$arr[1]]; |
|
39 | + $this->after_comma_array = [$arr[0], $arr[1]]; |
|
40 | 40 | }else |
41 | 41 | { |
42 | 42 | $this->after_comma_array = $arr; |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $this->after_comma_len = count($this->after_comma_array); |
46 | 46 | foreach ($this->after_comma_array as $digit) |
47 | 47 | { |
48 | - $this->after_comma_sum.=$digit; |
|
48 | + $this->after_comma_sum .= $digit; |
|
49 | 49 | } |
50 | 50 | //dd($this->after_comma_sum == 00); |
51 | 51 | return $this; |
@@ -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 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | |
63 | 63 | if($arr[1]==0) |
64 | - return $this->tens[$arr[0]]; |
|
64 | + return $this->tens[$arr[0]]; |
|
65 | 65 | |
66 | 66 | |
67 | 67 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | return $this->ones[$arr[1]] . $this->config['connection_tool'] . $this->tens[$arr[0]]; |
70 | 70 | |
71 | 71 | if(in_array($arr[1],[1,2])) |
72 | - return $this->others[$arr[1]] . ' ' . $this->tens[$arr[0]]; |
|
72 | + return $this->others[$arr[1]] . ' ' . $this->tens[$arr[0]]; |
|
73 | 73 | |
74 | 74 | return $this->ones[$arr[1]] . ' ' . $this->tens[$arr[0]]; |
75 | 75 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | |
106 | 106 | |
107 | 107 | if($arr[1] == 0 and $arr[2] == 0 and $arr[3] == 0) |
108 | - return $thousands; |
|
108 | + return $thousands; |
|
109 | 109 | |
110 | 110 | return $thousands . $this->config['connection_tool'] . $this->classC($classC); |
111 | 111 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | { |
181 | 181 | if($arr[1] == 0 && $arr[2]==0) |
182 | 182 | { |
183 | - $thousands = $this->hundreds[$arr[0]] .' '. $this->thousands[1]; |
|
183 | + $thousands = $this->hundreds[$arr[0]] .' '. $this->thousands[1]; |
|
184 | 184 | }else{ |
185 | 185 | if($arr[1] == 0 ) |
186 | 186 | { |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | |
219 | 219 | }else |
220 | 220 | { |
221 | - return $this->classE([$arr[1],$arr[2],$arr[3],$arr[4],$arr[5]]); |
|
221 | + return $this->classE([$arr[1],$arr[2],$arr[3],$arr[4],$arr[5]]); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | if($this->classC($classC)!='') |
@@ -8,14 +8,14 @@ discard block |
||
8 | 8 | { |
9 | 9 | use Digit; |
10 | 10 | |
11 | - public function classA($arr,$len = 1) |
|
11 | + public function classA($arr, $len = 1) |
|
12 | 12 | { |
13 | 13 | return $this->ones[$arr[0]]; |
14 | 14 | } |
15 | 15 | |
16 | - public function classB($arr,$len = 2) |
|
16 | + public function classB($arr, $len = 2) |
|
17 | 17 | { |
18 | - if($this->before_comma_len >= 2) |
|
18 | + if ($this->before_comma_len>=2) |
|
19 | 19 | { |
20 | 20 | $ten_number_index = $this->before_comma_len - 2; |
21 | 21 | $single_number_index = $this->before_comma_len - 1; |
@@ -24,13 +24,13 @@ discard block |
||
24 | 24 | , |
25 | 25 | $this->before_comma_array[$single_number_index] |
26 | 26 | ]; |
27 | - if($arr==$detecd_array) |
|
27 | + if ($arr == $detecd_array) |
|
28 | 28 | { |
29 | - if($arr[0]==0 and $arr[1]>=1 and $arr[1]<=10) |
|
29 | + if ($arr[0] == 0 and $arr[1]>=1 and $arr[1]<=10) |
|
30 | 30 | $this->is_main1_currency = true; |
31 | - elseif($arr[0]>=1 and $arr[1]>=1 and $arr[1]<=9) |
|
31 | + elseif ($arr[0]>=1 and $arr[1]>=1 and $arr[1]<=9) |
|
32 | 32 | $this->is_main1_currency = false; |
33 | - elseif($arr[0]>=2) |
|
33 | + elseif ($arr[0]>=2) |
|
34 | 34 | $this->is_main1_currency = false; |
35 | 35 | } |
36 | 36 | |
@@ -41,267 +41,267 @@ discard block |
||
41 | 41 | |
42 | 42 | |
43 | 43 | |
44 | - if($arr[0]==0 and $arr[1]==0) |
|
44 | + if ($arr[0] == 0 and $arr[1] == 0) |
|
45 | 45 | return ''; |
46 | 46 | |
47 | 47 | |
48 | 48 | |
49 | - if($arr[0]==0) |
|
49 | + if ($arr[0] == 0) |
|
50 | 50 | return $this->ones[$arr[1]]; |
51 | 51 | |
52 | 52 | |
53 | 53 | |
54 | - if($arr[0]==1 and $arr[1]==1) |
|
54 | + if ($arr[0] == 1 and $arr[1] == 1) |
|
55 | 55 | return $this->ones[11]; |
56 | 56 | |
57 | 57 | |
58 | - if($arr[0]==1 and $arr[1]==0) |
|
58 | + if ($arr[0] == 1 and $arr[1] == 0) |
|
59 | 59 | return $this->ones[10]; |
60 | 60 | |
61 | 61 | |
62 | 62 | |
63 | - if($arr[1]==0) |
|
63 | + if ($arr[1] == 0) |
|
64 | 64 | return $this->tens[$arr[0]]; |
65 | 65 | |
66 | 66 | |
67 | 67 | |
68 | - if($arr[0]>1) |
|
69 | - return $this->ones[$arr[1]] . $this->config['connection_tool'] . $this->tens[$arr[0]]; |
|
68 | + if ($arr[0]>1) |
|
69 | + return $this->ones[$arr[1]].$this->config['connection_tool'].$this->tens[$arr[0]]; |
|
70 | 70 | |
71 | - if(in_array($arr[1],[1,2])) |
|
72 | - return $this->others[$arr[1]] . ' ' . $this->tens[$arr[0]]; |
|
71 | + if (in_array($arr[1], [1, 2])) |
|
72 | + return $this->others[$arr[1]].' '.$this->tens[$arr[0]]; |
|
73 | 73 | |
74 | - return $this->ones[$arr[1]] . ' ' . $this->tens[$arr[0]]; |
|
74 | + return $this->ones[$arr[1]].' '.$this->tens[$arr[0]]; |
|
75 | 75 | } |
76 | 76 | |
77 | - public function classC($arr,$len = 3) |
|
77 | + public function classC($arr, $len = 3) |
|
78 | 78 | { |
79 | - if($arr[0]==0 and $arr[1] == 0 and $arr[2] == 0) |
|
79 | + if ($arr[0] == 0 and $arr[1] == 0 and $arr[2] == 0) |
|
80 | 80 | return ''; |
81 | 81 | |
82 | - if($arr[0]==0 and $arr[1] == 0) |
|
82 | + if ($arr[0] == 0 and $arr[1] == 0) |
|
83 | 83 | return $this->ones[$arr[2]]; |
84 | 84 | |
85 | - if($arr[0]==0) |
|
86 | - return $this->classB([$arr[1],$arr[2]]); |
|
85 | + if ($arr[0] == 0) |
|
86 | + return $this->classB([$arr[1], $arr[2]]); |
|
87 | 87 | |
88 | - if($arr[2] == 0 and $arr[1] == 0) |
|
88 | + if ($arr[2] == 0 and $arr[1] == 0) |
|
89 | 89 | return $this->hundreds[$arr[0]]; |
90 | 90 | |
91 | - if($arr[1]!=0) |
|
92 | - return $this->hundreds[$arr[0]] . $this->config['connection_tool'] . $this->classB([$arr[1],$arr[2]]); |
|
91 | + if ($arr[1] != 0) |
|
92 | + return $this->hundreds[$arr[0]].$this->config['connection_tool'].$this->classB([$arr[1], $arr[2]]); |
|
93 | 93 | |
94 | 94 | //return $this->hundreds[$arr[0]] . $this->config['connection_tool'] . $this->classA([$arr[2]]); |
95 | 95 | } |
96 | 96 | |
97 | - public function classD($arr,$len = 4) |
|
97 | + public function classD($arr, $len = 4) |
|
98 | 98 | { |
99 | - $classC = [$arr[1],$arr[2],$arr[3]]; |
|
99 | + $classC = [$arr[1], $arr[2], $arr[3]]; |
|
100 | 100 | |
101 | - if($arr[0]<=2) |
|
102 | - $thousands = $this->thousands[$arr[0]] ; |
|
101 | + if ($arr[0]<=2) |
|
102 | + $thousands = $this->thousands[$arr[0]]; |
|
103 | 103 | else |
104 | - $thousands = $this->ones[$arr[0]] . ' ' . $this->thousands['39']; |
|
104 | + $thousands = $this->ones[$arr[0]].' '.$this->thousands['39']; |
|
105 | 105 | |
106 | 106 | |
107 | - if($arr[1] == 0 and $arr[2] == 0 and $arr[3] == 0) |
|
107 | + if ($arr[1] == 0 and $arr[2] == 0 and $arr[3] == 0) |
|
108 | 108 | return $thousands; |
109 | 109 | |
110 | - return $thousands . $this->config['connection_tool'] . $this->classC($classC); |
|
110 | + return $thousands.$this->config['connection_tool'].$this->classC($classC); |
|
111 | 111 | } |
112 | 112 | |
113 | - public function classE($arr,$len = 5) |
|
113 | + public function classE($arr, $len = 5) |
|
114 | 114 | { |
115 | - $classC = [$arr[2],$arr[3],$arr[4]]; |
|
115 | + $classC = [$arr[2], $arr[3], $arr[4]]; |
|
116 | 116 | |
117 | - if($arr[0] != 0) |
|
117 | + if ($arr[0] != 0) |
|
118 | 118 | { |
119 | 119 | $conn = ' '; |
120 | 120 | |
121 | - if($arr[1]>=2 and $arr[0]>1) |
|
121 | + if ($arr[1]>=2 and $arr[0]>1) |
|
122 | 122 | { |
123 | 123 | $conn = $this->config['connection_tool']; |
124 | 124 | } |
125 | 125 | |
126 | - if(in_array($arr[1],[2,1])) |
|
127 | - $thousands = $this->others[$arr[1]] . $conn . $this->tens[$arr[0]] ; |
|
126 | + if (in_array($arr[1], [2, 1])) |
|
127 | + $thousands = $this->others[$arr[1]].$conn.$this->tens[$arr[0]]; |
|
128 | 128 | else |
129 | - $thousands = $this->ones[$arr[1]] . $conn . $this->tens[$arr[0]] ; |
|
129 | + $thousands = $this->ones[$arr[1]].$conn.$this->tens[$arr[0]]; |
|
130 | 130 | |
131 | - if($arr[1] == 0) |
|
131 | + if ($arr[1] == 0) |
|
132 | 132 | { |
133 | - if($arr[0]==1) |
|
133 | + if ($arr[0] == 1) |
|
134 | 134 | { |
135 | - $thousands = $this->ones[10] ; |
|
136 | - $thousands.=' ' . $this->thousands[39]; |
|
135 | + $thousands = $this->ones[10]; |
|
136 | + $thousands .= ' '.$this->thousands[39]; |
|
137 | 137 | }else |
138 | 138 | { |
139 | - $thousands = $this->tens[$arr[0]] ; |
|
140 | - $thousands.=' ' . $this->thousands[1]; |
|
139 | + $thousands = $this->tens[$arr[0]]; |
|
140 | + $thousands .= ' '.$this->thousands[1]; |
|
141 | 141 | } |
142 | 142 | |
143 | - }else{ |
|
144 | - if($arr[2] == 0 and $arr[3] == 0 and $arr[4] == 0) |
|
143 | + }else { |
|
144 | + if ($arr[2] == 0 and $arr[3] == 0 and $arr[4] == 0) |
|
145 | 145 | { |
146 | - $thousands.=' ' . $this->thousands[1]; |
|
146 | + $thousands .= ' '.$this->thousands[1]; |
|
147 | 147 | }else |
148 | 148 | { |
149 | - $thousands.=' ' . $this->thousands[1199]; |
|
149 | + $thousands .= ' '.$this->thousands[1199]; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | } |
153 | 153 | |
154 | 154 | }else |
155 | 155 | { |
156 | - if(in_array($arr[1],[2,1])) |
|
157 | - $thousands = $this->others[$arr[1]] . ' ' ; |
|
156 | + if (in_array($arr[1], [2, 1])) |
|
157 | + $thousands = $this->others[$arr[1]].' '; |
|
158 | 158 | else |
159 | - $thousands = $this->ones[$arr[1]] . ' ' ; |
|
159 | + $thousands = $this->ones[$arr[1]].' '; |
|
160 | 160 | |
161 | 161 | |
162 | - if($arr[1] == 0) |
|
162 | + if ($arr[1] == 0) |
|
163 | 163 | { |
164 | 164 | //dd($arr[1]); |
165 | 165 | //dd($arr[2]); |
166 | - $thousands = $this->tens[$arr[2]] ; |
|
166 | + $thousands = $this->tens[$arr[2]]; |
|
167 | 167 | } |
168 | 168 | |
169 | - $thousands.=' ' . $this->thousands[39]; |
|
169 | + $thousands .= ' '.$this->thousands[39]; |
|
170 | 170 | } |
171 | - if($this->classC($classC) != '' ) |
|
171 | + if ($this->classC($classC) != '') |
|
172 | 172 | { |
173 | - return $thousands . $this->config['connection_tool'] . $this->classC($classC); |
|
173 | + return $thousands.$this->config['connection_tool'].$this->classC($classC); |
|
174 | 174 | } |
175 | 175 | return $thousands; |
176 | 176 | } |
177 | 177 | |
178 | - public function classF($arr,$len = 6) //100 000 |
|
178 | + public function classF($arr, $len = 6) //100 000 |
|
179 | 179 | { |
180 | - $classC = [$arr[3],$arr[4],$arr[5]]; |
|
181 | - if($arr[0]!=0) |
|
180 | + $classC = [$arr[3], $arr[4], $arr[5]]; |
|
181 | + if ($arr[0] != 0) |
|
182 | 182 | { |
183 | - if($arr[1] == 0 && $arr[2]==0) |
|
183 | + if ($arr[1] == 0 && $arr[2] == 0) |
|
184 | 184 | { |
185 | - $thousands = $this->hundreds[$arr[0]] .' '. $this->thousands[1]; |
|
186 | - }else{ |
|
187 | - if($arr[1] == 0 ) |
|
185 | + $thousands = $this->hundreds[$arr[0]].' '.$this->thousands[1]; |
|
186 | + }else { |
|
187 | + if ($arr[1] == 0) |
|
188 | 188 | { |
189 | - $thousands = $this->hundreds[$arr[0]] .$this->config['connection_tool']. |
|
190 | - $this->ones[$arr[2]] . ' '. $this->thousands[1]; |
|
191 | - }elseif($arr[2] == 0) |
|
189 | + $thousands = $this->hundreds[$arr[0]].$this->config['connection_tool']. |
|
190 | + $this->ones[$arr[2]].' '.$this->thousands[1]; |
|
191 | + }elseif ($arr[2] == 0) |
|
192 | 192 | { |
193 | - if($arr[3] == 0 and $arr[4] == 0 and $arr[5] == 0) |
|
193 | + if ($arr[3] == 0 and $arr[4] == 0 and $arr[5] == 0) |
|
194 | 194 | { |
195 | 195 | |
196 | - $thousands = $this->hundreds[$arr[0]] .$this->config['connection_tool']. |
|
197 | - $this->tens[$arr[1]] . ' '. $this->thousands[1]; |
|
196 | + $thousands = $this->hundreds[$arr[0]].$this->config['connection_tool']. |
|
197 | + $this->tens[$arr[1]].' '.$this->thousands[1]; |
|
198 | 198 | |
199 | 199 | }else |
200 | 200 | { |
201 | - $thousands = $this->hundreds[$arr[0]] .$this->config['connection_tool']. |
|
202 | - $this->tens[$arr[1]] . ' '. $this->thousands[1199]; |
|
201 | + $thousands = $this->hundreds[$arr[0]].$this->config['connection_tool']. |
|
202 | + $this->tens[$arr[1]].' '.$this->thousands[1199]; |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | else |
206 | 206 | { |
207 | 207 | // $thousands_lang = $this->thousands[1199]; |
208 | - if($arr[1]==0 and $arr[2]>=1 and $arr[1]<=10) |
|
208 | + if ($arr[1] == 0 and $arr[2]>=1 and $arr[1]<=10) |
|
209 | 209 | $thousands_lang = $this->thousands[1]; |
210 | - elseif($arr[1]>=1 and $arr[2]>=1 and $arr[1]<=9) |
|
210 | + elseif ($arr[1]>=1 and $arr[2]>=1 and $arr[1]<=9) |
|
211 | 211 | $thousands_lang = $this->thousands[1199]; |
212 | - elseif($arr[1]>=2) |
|
212 | + elseif ($arr[1]>=2) |
|
213 | 213 | $thousands_lang = $this->thousands[1199]; |
214 | 214 | |
215 | 215 | |
216 | - $thousands = $this->classC([$arr[0],$arr[1],$arr[2]],3) . ' '. $thousands_lang; |
|
216 | + $thousands = $this->classC([$arr[0], $arr[1], $arr[2]], 3).' '.$thousands_lang; |
|
217 | 217 | |
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
221 | 221 | }else |
222 | 222 | { |
223 | - return $this->classE([$arr[1],$arr[2],$arr[3],$arr[4],$arr[5]]); |
|
223 | + return $this->classE([$arr[1], $arr[2], $arr[3], $arr[4], $arr[5]]); |
|
224 | 224 | } |
225 | 225 | |
226 | - if($this->classC($classC)!='') |
|
227 | - return $thousands . $this->config['connection_tool'] . $this->classC($classC); |
|
226 | + if ($this->classC($classC) != '') |
|
227 | + return $thousands.$this->config['connection_tool'].$this->classC($classC); |
|
228 | 228 | return $thousands; |
229 | 229 | } |
230 | 230 | |
231 | - public function classG($arr,$len = 7) //1 000 000 |
|
231 | + public function classG($arr, $len = 7) //1 000 000 |
|
232 | 232 | { |
233 | 233 | //dd($arr,$len); |
234 | - $classC = [$arr[4],$arr[5],$arr[6]]; |
|
234 | + $classC = [$arr[4], $arr[5], $arr[6]]; |
|
235 | 235 | //$classC = [$arr[1],$arr[2],$arr[3]]; |
236 | 236 | //$classE = [$arr[1],$arr[2],$arr[3],$arr[4],$arr[5],$arr[6]]; |
237 | 237 | |
238 | - if($arr[0]<=2) |
|
239 | - $million = $this->millions[$arr[0]] ; |
|
238 | + if ($arr[0]<=2) |
|
239 | + $million = $this->millions[$arr[0]]; |
|
240 | 240 | else |
241 | - $million = $this->ones[$arr[0]] . ' ' . $this->millions['39']; |
|
241 | + $million = $this->ones[$arr[0]].' '.$this->millions['39']; |
|
242 | 242 | |
243 | - if($this->classC($classC)!='') |
|
244 | - return $million . $this->config['connection_tool'] . $this->classC($classC); |
|
243 | + if ($this->classC($classC) != '') |
|
244 | + return $million.$this->config['connection_tool'].$this->classC($classC); |
|
245 | 245 | return $million; |
246 | 246 | } |
247 | 247 | |
248 | - public function classH($arr,$len = 8) |
|
248 | + public function classH($arr, $len = 8) |
|
249 | 249 | { |
250 | 250 | //dd($arr,$len); |
251 | - $classF = [$arr[2],$arr[3],$arr[4],$arr[5],$arr[6],$arr[7]]; |
|
251 | + $classF = [$arr[2], $arr[3], $arr[4], $arr[5], $arr[6], $arr[7]]; |
|
252 | 252 | //$classC = [$arr[1],$arr[2],$arr[3]]; |
253 | 253 | |
254 | - if($arr[0] != 0) |
|
254 | + if ($arr[0] != 0) |
|
255 | 255 | { |
256 | 256 | $conn = ' '; |
257 | 257 | |
258 | - if($arr[1]>=2 and $arr[0]>1) |
|
258 | + if ($arr[1]>=2 and $arr[0]>1) |
|
259 | 259 | { |
260 | 260 | $conn = $this->config['connection_tool']; |
261 | 261 | } |
262 | 262 | |
263 | - if(in_array($arr[1],[2,1])) |
|
264 | - $million = $this->others[$arr[1]] . $conn . $this->tens[$arr[0]] ; |
|
263 | + if (in_array($arr[1], [2, 1])) |
|
264 | + $million = $this->others[$arr[1]].$conn.$this->tens[$arr[0]]; |
|
265 | 265 | else |
266 | - $million = $this->ones[$arr[1]] . $conn . $this->tens[$arr[0]] ; |
|
266 | + $million = $this->ones[$arr[1]].$conn.$this->tens[$arr[0]]; |
|
267 | 267 | |
268 | - if($arr[1] == 0) |
|
268 | + if ($arr[1] == 0) |
|
269 | 269 | { |
270 | - if($arr[0]==1) |
|
270 | + if ($arr[0] == 1) |
|
271 | 271 | { |
272 | - $million = $this->ones[10] ; |
|
273 | - $million.=' ' . $this->millions[39]; |
|
272 | + $million = $this->ones[10]; |
|
273 | + $million .= ' '.$this->millions[39]; |
|
274 | 274 | }else |
275 | 275 | { |
276 | - $million = $this->tens[$arr[0]] ; |
|
277 | - $million.=' ' . $this->millions[1]; |
|
276 | + $million = $this->tens[$arr[0]]; |
|
277 | + $million .= ' '.$this->millions[1]; |
|
278 | 278 | } |
279 | 279 | |
280 | - }else{ |
|
281 | - if($arr[2] == 0 and $arr[3] == 0 and $arr[4] == 0) |
|
280 | + }else { |
|
281 | + if ($arr[2] == 0 and $arr[3] == 0 and $arr[4] == 0) |
|
282 | 282 | { |
283 | - $million.=' ' . $this->millions[1]; |
|
283 | + $million .= ' '.$this->millions[1]; |
|
284 | 284 | }else |
285 | 285 | { |
286 | - $million.=' ' . $this->millions[1199]; |
|
286 | + $million .= ' '.$this->millions[1199]; |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | } |
290 | 290 | |
291 | 291 | }else |
292 | 292 | { |
293 | - if(in_array($arr[1],[2,1])) |
|
294 | - $million = $this->others[$arr[1]] . ' ' ; |
|
293 | + if (in_array($arr[1], [2, 1])) |
|
294 | + $million = $this->others[$arr[1]].' '; |
|
295 | 295 | else |
296 | - $million = $this->ones[$arr[1]] . ' ' ; |
|
296 | + $million = $this->ones[$arr[1]].' '; |
|
297 | 297 | |
298 | 298 | |
299 | - if($arr[1] == 0) |
|
299 | + if ($arr[1] == 0) |
|
300 | 300 | { |
301 | - $million = $this->tens[$arr[2]] ; |
|
301 | + $million = $this->tens[$arr[2]]; |
|
302 | 302 | } |
303 | 303 | |
304 | - $million.=' ' . $this->millions[39]; |
|
304 | + $million .= ' '.$this->millions[39]; |
|
305 | 305 | } |
306 | 306 | // if(in_array($arr[1],[2])) |
307 | 307 | // $million = $this->others[$arr[1]] . $this->config['connection_tool'] . $this->tens[$arr[0]] ; |
@@ -317,30 +317,30 @@ discard block |
||
317 | 317 | |
318 | 318 | //$million.=' ' . $this->millions[1199]; |
319 | 319 | |
320 | - return $million . $this->config['connection_tool'] . $this->classC($classF); |
|
320 | + return $million.$this->config['connection_tool'].$this->classC($classF); |
|
321 | 321 | } |
322 | 322 | |
323 | - public function classI($arr,$len = 9) |
|
323 | + public function classI($arr, $len = 9) |
|
324 | 324 | { |
325 | - $classF = [$arr[3],$arr[4],$arr[5],$arr[6],$arr[7],$arr[8]]; |
|
325 | + $classF = [$arr[3], $arr[4], $arr[5], $arr[6], $arr[7], $arr[8]]; |
|
326 | 326 | |
327 | 327 | |
328 | - if(in_array($arr[1],[2])) |
|
329 | - $million = $this->others[$arr[1]] . $this->config['connection_tool'] . $this->tens[$arr[0]] ; |
|
328 | + if (in_array($arr[1], [2])) |
|
329 | + $million = $this->others[$arr[1]].$this->config['connection_tool'].$this->tens[$arr[0]]; |
|
330 | 330 | else |
331 | - $million = $this->ones[$arr[1]] . $this->config['connection_tool'] . $this->tens[$arr[0]] ; |
|
331 | + $million = $this->ones[$arr[1]].$this->config['connection_tool'].$this->tens[$arr[0]]; |
|
332 | 332 | |
333 | 333 | |
334 | - if($arr[1] == 0) |
|
334 | + if ($arr[1] == 0) |
|
335 | 335 | { |
336 | - $million = $this->tens[$arr[0]] ; |
|
336 | + $million = $this->tens[$arr[0]]; |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | |
340 | - $million.=' ' . $this->millions[1199]; |
|
340 | + $million .= ' '.$this->millions[1199]; |
|
341 | 341 | |
342 | 342 | |
343 | - return $million . $this->config['connection_tool'] . $this->classF($classF); |
|
343 | + return $million.$this->config['connection_tool'].$this->classF($classF); |
|
344 | 344 | |
345 | 345 | } |
346 | 346 |
@@ -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 | } |
@@ -123,10 +138,11 @@ discard block |
||
123 | 138 | $conn = $this->config['connection_tool']; |
124 | 139 | } |
125 | 140 | |
126 | - if(in_array($arr[1],[2,1])) |
|
127 | - $thousands = $this->others[$arr[1]] . $conn . $this->tens[$arr[0]] ; |
|
128 | - else |
|
129 | - $thousands = $this->ones[$arr[1]] . $conn . $this->tens[$arr[0]] ; |
|
141 | + if(in_array($arr[1],[2,1])) { |
|
142 | + $thousands = $this->others[$arr[1]] . $conn . $this->tens[$arr[0]] ; |
|
143 | + } else { |
|
144 | + $thousands = $this->ones[$arr[1]] . $conn . $this->tens[$arr[0]] ; |
|
145 | + } |
|
130 | 146 | |
131 | 147 | if($arr[1] == 0) |
132 | 148 | { |
@@ -134,29 +150,30 @@ discard block |
||
134 | 150 | { |
135 | 151 | $thousands = $this->ones[10] ; |
136 | 152 | $thousands.=' ' . $this->thousands[39]; |
137 | - }else |
|
153 | + } else |
|
138 | 154 | { |
139 | 155 | $thousands = $this->tens[$arr[0]] ; |
140 | 156 | $thousands.=' ' . $this->thousands[1]; |
141 | 157 | } |
142 | 158 | |
143 | - }else{ |
|
159 | + } else{ |
|
144 | 160 | if($arr[2] == 0 and $arr[3] == 0 and $arr[4] == 0) |
145 | 161 | { |
146 | 162 | $thousands.=' ' . $this->thousands[1]; |
147 | - }else |
|
163 | + } else |
|
148 | 164 | { |
149 | 165 | $thousands.=' ' . $this->thousands[1199]; |
150 | 166 | } |
151 | 167 | |
152 | 168 | } |
153 | 169 | |
154 | - }else |
|
170 | + } else |
|
155 | 171 | { |
156 | - if(in_array($arr[1],[2,1])) |
|
157 | - $thousands = $this->others[$arr[1]] . ' ' ; |
|
158 | - else |
|
159 | - $thousands = $this->ones[$arr[1]] . ' ' ; |
|
172 | + if(in_array($arr[1],[2,1])) { |
|
173 | + $thousands = $this->others[$arr[1]] . ' ' ; |
|
174 | + } else { |
|
175 | + $thousands = $this->ones[$arr[1]] . ' ' ; |
|
176 | + } |
|
160 | 177 | |
161 | 178 | |
162 | 179 | if($arr[1] == 0) |
@@ -183,12 +200,12 @@ discard block |
||
183 | 200 | if($arr[1] == 0 && $arr[2]==0) |
184 | 201 | { |
185 | 202 | $thousands = $this->hundreds[$arr[0]] .' '. $this->thousands[1]; |
186 | - }else{ |
|
203 | + } else{ |
|
187 | 204 | if($arr[1] == 0 ) |
188 | 205 | { |
189 | 206 | $thousands = $this->hundreds[$arr[0]] .$this->config['connection_tool']. |
190 | 207 | $this->ones[$arr[2]] . ' '. $this->thousands[1]; |
191 | - }elseif($arr[2] == 0) |
|
208 | + } elseif($arr[2] == 0) |
|
192 | 209 | { |
193 | 210 | if($arr[3] == 0 and $arr[4] == 0 and $arr[5] == 0) |
194 | 211 | { |
@@ -196,21 +213,21 @@ discard block |
||
196 | 213 | $thousands = $this->hundreds[$arr[0]] .$this->config['connection_tool']. |
197 | 214 | $this->tens[$arr[1]] . ' '. $this->thousands[1]; |
198 | 215 | |
199 | - }else |
|
216 | + } else |
|
200 | 217 | { |
201 | 218 | $thousands = $this->hundreds[$arr[0]] .$this->config['connection_tool']. |
202 | 219 | $this->tens[$arr[1]] . ' '. $this->thousands[1199]; |
203 | 220 | } |
204 | - } |
|
205 | - else |
|
221 | + } else |
|
206 | 222 | { |
207 | 223 | // $thousands_lang = $this->thousands[1199]; |
208 | - if($arr[1]==0 and $arr[2]>=1 and $arr[1]<=10) |
|
209 | - $thousands_lang = $this->thousands[1]; |
|
210 | - elseif($arr[1]>=1 and $arr[2]>=1 and $arr[1]<=9) |
|
211 | - $thousands_lang = $this->thousands[1199]; |
|
212 | - elseif($arr[1]>=2) |
|
213 | - $thousands_lang = $this->thousands[1199]; |
|
224 | + if($arr[1]==0 and $arr[2]>=1 and $arr[1]<=10) { |
|
225 | + $thousands_lang = $this->thousands[1]; |
|
226 | + } elseif($arr[1]>=1 and $arr[2]>=1 and $arr[1]<=9) { |
|
227 | + $thousands_lang = $this->thousands[1199]; |
|
228 | + } elseif($arr[1]>=2) { |
|
229 | + $thousands_lang = $this->thousands[1199]; |
|
230 | + } |
|
214 | 231 | |
215 | 232 | |
216 | 233 | $thousands = $this->classC([$arr[0],$arr[1],$arr[2]],3) . ' '. $thousands_lang; |
@@ -218,13 +235,14 @@ discard block |
||
218 | 235 | } |
219 | 236 | } |
220 | 237 | |
221 | - }else |
|
238 | + } else |
|
222 | 239 | { |
223 | 240 | return $this->classE([$arr[1],$arr[2],$arr[3],$arr[4],$arr[5]]); |
224 | 241 | } |
225 | 242 | |
226 | - if($this->classC($classC)!='') |
|
227 | - return $thousands . $this->config['connection_tool'] . $this->classC($classC); |
|
243 | + if($this->classC($classC)!='') { |
|
244 | + return $thousands . $this->config['connection_tool'] . $this->classC($classC); |
|
245 | + } |
|
228 | 246 | return $thousands; |
229 | 247 | } |
230 | 248 | |
@@ -235,13 +253,15 @@ discard block |
||
235 | 253 | //$classC = [$arr[1],$arr[2],$arr[3]]; |
236 | 254 | //$classE = [$arr[1],$arr[2],$arr[3],$arr[4],$arr[5],$arr[6]]; |
237 | 255 | |
238 | - if($arr[0]<=2) |
|
239 | - $million = $this->millions[$arr[0]] ; |
|
240 | - else |
|
241 | - $million = $this->ones[$arr[0]] . ' ' . $this->millions['39']; |
|
256 | + if($arr[0]<=2) { |
|
257 | + $million = $this->millions[$arr[0]] ; |
|
258 | + } else { |
|
259 | + $million = $this->ones[$arr[0]] . ' ' . $this->millions['39']; |
|
260 | + } |
|
242 | 261 | |
243 | - if($this->classC($classC)!='') |
|
244 | - return $million . $this->config['connection_tool'] . $this->classC($classC); |
|
262 | + if($this->classC($classC)!='') { |
|
263 | + return $million . $this->config['connection_tool'] . $this->classC($classC); |
|
264 | + } |
|
245 | 265 | return $million; |
246 | 266 | } |
247 | 267 | |
@@ -260,10 +280,11 @@ discard block |
||
260 | 280 | $conn = $this->config['connection_tool']; |
261 | 281 | } |
262 | 282 | |
263 | - if(in_array($arr[1],[2,1])) |
|
264 | - $million = $this->others[$arr[1]] . $conn . $this->tens[$arr[0]] ; |
|
265 | - else |
|
266 | - $million = $this->ones[$arr[1]] . $conn . $this->tens[$arr[0]] ; |
|
283 | + if(in_array($arr[1],[2,1])) { |
|
284 | + $million = $this->others[$arr[1]] . $conn . $this->tens[$arr[0]] ; |
|
285 | + } else { |
|
286 | + $million = $this->ones[$arr[1]] . $conn . $this->tens[$arr[0]] ; |
|
287 | + } |
|
267 | 288 | |
268 | 289 | if($arr[1] == 0) |
269 | 290 | { |
@@ -271,29 +292,30 @@ discard block |
||
271 | 292 | { |
272 | 293 | $million = $this->ones[10] ; |
273 | 294 | $million.=' ' . $this->millions[39]; |
274 | - }else |
|
295 | + } else |
|
275 | 296 | { |
276 | 297 | $million = $this->tens[$arr[0]] ; |
277 | 298 | $million.=' ' . $this->millions[1]; |
278 | 299 | } |
279 | 300 | |
280 | - }else{ |
|
301 | + } else{ |
|
281 | 302 | if($arr[2] == 0 and $arr[3] == 0 and $arr[4] == 0) |
282 | 303 | { |
283 | 304 | $million.=' ' . $this->millions[1]; |
284 | - }else |
|
305 | + } else |
|
285 | 306 | { |
286 | 307 | $million.=' ' . $this->millions[1199]; |
287 | 308 | } |
288 | 309 | |
289 | 310 | } |
290 | 311 | |
291 | - }else |
|
312 | + } else |
|
292 | 313 | { |
293 | - if(in_array($arr[1],[2,1])) |
|
294 | - $million = $this->others[$arr[1]] . ' ' ; |
|
295 | - else |
|
296 | - $million = $this->ones[$arr[1]] . ' ' ; |
|
314 | + if(in_array($arr[1],[2,1])) { |
|
315 | + $million = $this->others[$arr[1]] . ' ' ; |
|
316 | + } else { |
|
317 | + $million = $this->ones[$arr[1]] . ' ' ; |
|
318 | + } |
|
297 | 319 | |
298 | 320 | |
299 | 321 | if($arr[1] == 0) |
@@ -325,10 +347,11 @@ discard block |
||
325 | 347 | $classF = [$arr[3],$arr[4],$arr[5],$arr[6],$arr[7],$arr[8]]; |
326 | 348 | |
327 | 349 | |
328 | - if(in_array($arr[1],[2])) |
|
329 | - $million = $this->others[$arr[1]] . $this->config['connection_tool'] . $this->tens[$arr[0]] ; |
|
330 | - else |
|
331 | - $million = $this->ones[$arr[1]] . $this->config['connection_tool'] . $this->tens[$arr[0]] ; |
|
350 | + if(in_array($arr[1],[2])) { |
|
351 | + $million = $this->others[$arr[1]] . $this->config['connection_tool'] . $this->tens[$arr[0]] ; |
|
352 | + } else { |
|
353 | + $million = $this->ones[$arr[1]] . $this->config['connection_tool'] . $this->tens[$arr[0]] ; |
|
354 | + } |
|
332 | 355 | |
333 | 356 | |
334 | 357 | if($arr[1] == 0) |
@@ -10,7 +10,7 @@ |
||
10 | 10 | public function initValidation() |
11 | 11 | { |
12 | 12 | |
13 | - if(is_numeric($this->parsed_number)) |
|
13 | + if (is_numeric($this->parsed_number)) |
|
14 | 14 | return $this; |
15 | 15 | else |
16 | 16 | die('is not right number '); |
@@ -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 |
@@ -33,7 +33,7 @@ |
||
33 | 33 | public function detectClass($len) |
34 | 34 | { |
35 | 35 | if($len == 1) |
36 | - return "A"; |
|
36 | + return "A"; |
|
37 | 37 | |
38 | 38 | |
39 | 39 | if($len == 2) |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | public function runBeforeComma() |
11 | 11 | { |
12 | 12 | $number = null; |
13 | - for ($i=0; $i < count($this->before_comma_array); $i++){ |
|
13 | + for ($i = 0; $i<count($this->before_comma_array); $i++) { |
|
14 | 14 | $num = $this->before_comma_array[$i]; |
15 | 15 | $number = $number.$num; |
16 | 16 | }; |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | |
22 | 22 | public function runAfterComma() |
23 | 23 | { |
24 | - $class = $this->detectClass($this->after_comma_len); |
|
25 | - $methodName = 'Class' . $class; |
|
26 | - if(method_exists($this,$methodName)) |
|
24 | + $class = $this->detectClass($this->after_comma_len); |
|
25 | + $methodName = 'Class'.$class; |
|
26 | + if (method_exists($this, $methodName)) |
|
27 | 27 | { |
28 | - return $this->$methodName($this->after_comma_array,$this->after_comma_len); |
|
28 | + return $this->$methodName($this->after_comma_array, $this->after_comma_len); |
|
29 | 29 | } |
30 | 30 | return 'عفوا هذا الرقم خارج نطاقنا حاليا حاول لاحقاً'; |
31 | 31 | } |
@@ -33,35 +33,35 @@ discard block |
||
33 | 33 | |
34 | 34 | public function detectClass($len) |
35 | 35 | { |
36 | - if($len == 1) |
|
36 | + if ($len == 1) |
|
37 | 37 | return "A"; |
38 | 38 | |
39 | 39 | |
40 | - if($len == 2) |
|
40 | + if ($len == 2) |
|
41 | 41 | return "B"; |
42 | 42 | |
43 | 43 | |
44 | - if($len == 3) |
|
44 | + if ($len == 3) |
|
45 | 45 | return "C"; |
46 | 46 | |
47 | 47 | |
48 | - if($len == 4) |
|
48 | + if ($len == 4) |
|
49 | 49 | return "D"; |
50 | 50 | |
51 | 51 | |
52 | - if($len == 5) |
|
52 | + if ($len == 5) |
|
53 | 53 | return "E"; |
54 | 54 | |
55 | - if($len == 6) |
|
55 | + if ($len == 6) |
|
56 | 56 | return "F"; |
57 | 57 | |
58 | - if($len == 7) |
|
58 | + if ($len == 7) |
|
59 | 59 | return "G"; |
60 | 60 | |
61 | - if($len == 8) |
|
61 | + if ($len == 8) |
|
62 | 62 | return "H"; |
63 | 63 | |
64 | - if($len == 9) |
|
64 | + if ($len == 9) |
|
65 | 65 | return "I"; |
66 | 66 | |
67 | 67 | } |
@@ -33,36 +33,45 @@ |
||
33 | 33 | |
34 | 34 | public function detectClass($len) |
35 | 35 | { |
36 | - if($len == 1) |
|
37 | - return "A"; |
|
36 | + if($len == 1) { |
|
37 | + return "A"; |
|
38 | + } |
|
38 | 39 | |
39 | 40 | |
40 | - if($len == 2) |
|
41 | - return "B"; |
|
41 | + if($len == 2) { |
|
42 | + return "B"; |
|
43 | + } |
|
42 | 44 | |
43 | 45 | |
44 | - if($len == 3) |
|
45 | - return "C"; |
|
46 | + if($len == 3) { |
|
47 | + return "C"; |
|
48 | + } |
|
46 | 49 | |
47 | 50 | |
48 | - if($len == 4) |
|
49 | - return "D"; |
|
51 | + if($len == 4) { |
|
52 | + return "D"; |
|
53 | + } |
|
50 | 54 | |
51 | 55 | |
52 | - if($len == 5) |
|
53 | - return "E"; |
|
56 | + if($len == 5) { |
|
57 | + return "E"; |
|
58 | + } |
|
54 | 59 | |
55 | - if($len == 6) |
|
56 | - return "F"; |
|
60 | + if($len == 6) { |
|
61 | + return "F"; |
|
62 | + } |
|
57 | 63 | |
58 | - if($len == 7) |
|
59 | - return "G"; |
|
64 | + if($len == 7) { |
|
65 | + return "G"; |
|
66 | + } |
|
60 | 67 | |
61 | - if($len == 8) |
|
62 | - return "H"; |
|
68 | + if($len == 8) { |
|
69 | + return "H"; |
|
70 | + } |
|
63 | 71 | |
64 | - if($len == 9) |
|
65 | - return "I"; |
|
72 | + if($len == 9) { |
|
73 | + return "I"; |
|
74 | + } |
|
66 | 75 | |
67 | 76 | } |
68 | 77 | } |
@@ -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 | } |
@@ -1,101 +1,101 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | - namespace Alkoumi\LaravelArabicTafqeet; |
|
4 | - |
|
5 | - use Alkoumi\LaravelArabicTafqeet\Helpers\Calculators; |
|
6 | - use Alkoumi\LaravelArabicTafqeet\Helpers\Handler; |
|
7 | - use Alkoumi\LaravelArabicTafqeet\Helpers\Validation; |
|
8 | - use Alkoumi\LaravelArabicTafqeet\Helpers\App; |
|
9 | - |
|
10 | - class Tafqeet |
|
11 | - { |
|
12 | - use Calculators,Handler,Validation,App; |
|
13 | - |
|
14 | - public $config = [ |
|
15 | - |
|
16 | - 'connection_tool' => ' و', |
|
17 | - |
|
18 | - 'default_currency' => 'sar', |
|
19 | - |
|
20 | - 'starter' => 'فقط', |
|
21 | - |
|
22 | - 'end' => 'لا غير', |
|
23 | - |
|
24 | - 'currencies' => [ |
|
25 | - 'sar' => [ |
|
26 | - 'main1' => 'ريال', |
|
27 | - 'main2' => 'ريالاً', |
|
28 | - 'single' => 'هللة', |
|
29 | - 'multi' => 'هللات' |
|
30 | - ], |
|
31 | - |
|
32 | - 'egp' => [ |
|
33 | - 'main1' => 'جنيه', |
|
34 | - 'main2' => 'جنيهًا', |
|
35 | - 'single' => 'قرش', |
|
36 | - 'multi' => 'قروش' |
|
37 | - ], |
|
38 | - |
|
39 | - 'dzd' => [ |
|
40 | - 'main1' => 'دينار', |
|
41 | - 'main2' => 'دينارًا', |
|
42 | - 'single' => 'سنتيم', |
|
43 | - 'multi' => 'سنتيمات' |
|
44 | - ], |
|
45 | - |
|
46 | - 'aed' => [ |
|
47 | - 'main1' => 'درهم', |
|
48 | - 'main2' => 'درهمًا', |
|
49 | - 'single' => 'فلس', |
|
50 | - 'multi' => 'فلسات' |
|
51 | - ], |
|
52 | - |
|
53 | - 'kwd' => [ |
|
54 | - 'main1' => 'دينار', |
|
55 | - 'main2' => 'دينارًا', |
|
56 | - 'single' => 'فلس', |
|
57 | - 'multi' => 'فلسات' |
|
58 | - ], |
|
59 | - |
|
60 | - 'bhd' => [ |
|
61 | - 'main1' => 'دينار', |
|
62 | - 'main2' => 'دينارًا', |
|
63 | - 'single' => 'فلس', |
|
64 | - 'multi' => 'فلسات' |
|
65 | - ], |
|
66 | - |
|
67 | - 'iqd' => [ |
|
68 | - 'main1' => 'دينار', |
|
69 | - 'main2' => 'دينارًا', |
|
70 | - 'single' => 'فلس', |
|
71 | - 'multi' => 'فلسات' |
|
72 | - ], |
|
73 | - 'lbp' => [ |
|
74 | - 'main1' => 'ليرة', |
|
75 | - 'main2' => 'ليرة', |
|
76 | - 'single' => 'قرش', |
|
77 | - 'multi' => 'قروش' |
|
78 | - ], |
|
79 | - 'yer' => [ |
|
80 | - 'main1' => 'ريال', |
|
81 | - 'main2' => 'ريالًا', |
|
82 | - 'single' => 'فلس', |
|
83 | - 'multi' => 'فلسات' |
|
84 | - ], |
|
85 | - |
|
86 | - 'jod' => [ |
|
87 | - 'main1' => 'دينار', |
|
88 | - 'main2' => 'دينارًا', |
|
89 | - 'single' => 'قرش', |
|
90 | - 'multi' => 'قروش' |
|
91 | - ], |
|
92 | - |
|
93 | - 'usd' => [ |
|
94 | - 'main1' => 'دولار', |
|
95 | - 'main2' => 'دولاراً', |
|
96 | - 'single' => 'سنت', |
|
97 | - 'multi' => 'سنت' |
|
98 | - ], |
|
3 | + namespace Alkoumi\LaravelArabicTafqeet; |
|
4 | + |
|
5 | + use Alkoumi\LaravelArabicTafqeet\Helpers\Calculators; |
|
6 | + use Alkoumi\LaravelArabicTafqeet\Helpers\Handler; |
|
7 | + use Alkoumi\LaravelArabicTafqeet\Helpers\Validation; |
|
8 | + use Alkoumi\LaravelArabicTafqeet\Helpers\App; |
|
9 | + |
|
10 | + class Tafqeet |
|
11 | + { |
|
12 | + use Calculators,Handler,Validation,App; |
|
13 | + |
|
14 | + public $config = [ |
|
15 | + |
|
16 | + 'connection_tool' => ' و', |
|
17 | + |
|
18 | + 'default_currency' => 'sar', |
|
19 | + |
|
20 | + 'starter' => 'فقط', |
|
21 | + |
|
22 | + 'end' => 'لا غير', |
|
23 | + |
|
24 | + 'currencies' => [ |
|
25 | + 'sar' => [ |
|
26 | + 'main1' => 'ريال', |
|
27 | + 'main2' => 'ريالاً', |
|
28 | + 'single' => 'هللة', |
|
29 | + 'multi' => 'هللات' |
|
30 | + ], |
|
31 | + |
|
32 | + 'egp' => [ |
|
33 | + 'main1' => 'جنيه', |
|
34 | + 'main2' => 'جنيهًا', |
|
35 | + 'single' => 'قرش', |
|
36 | + 'multi' => 'قروش' |
|
37 | + ], |
|
38 | + |
|
39 | + 'dzd' => [ |
|
40 | + 'main1' => 'دينار', |
|
41 | + 'main2' => 'دينارًا', |
|
42 | + 'single' => 'سنتيم', |
|
43 | + 'multi' => 'سنتيمات' |
|
44 | + ], |
|
45 | + |
|
46 | + 'aed' => [ |
|
47 | + 'main1' => 'درهم', |
|
48 | + 'main2' => 'درهمًا', |
|
49 | + 'single' => 'فلس', |
|
50 | + 'multi' => 'فلسات' |
|
51 | + ], |
|
52 | + |
|
53 | + 'kwd' => [ |
|
54 | + 'main1' => 'دينار', |
|
55 | + 'main2' => 'دينارًا', |
|
56 | + 'single' => 'فلس', |
|
57 | + 'multi' => 'فلسات' |
|
58 | + ], |
|
59 | + |
|
60 | + 'bhd' => [ |
|
61 | + 'main1' => 'دينار', |
|
62 | + 'main2' => 'دينارًا', |
|
63 | + 'single' => 'فلس', |
|
64 | + 'multi' => 'فلسات' |
|
65 | + ], |
|
66 | + |
|
67 | + 'iqd' => [ |
|
68 | + 'main1' => 'دينار', |
|
69 | + 'main2' => 'دينارًا', |
|
70 | + 'single' => 'فلس', |
|
71 | + 'multi' => 'فلسات' |
|
72 | + ], |
|
73 | + 'lbp' => [ |
|
74 | + 'main1' => 'ليرة', |
|
75 | + 'main2' => 'ليرة', |
|
76 | + 'single' => 'قرش', |
|
77 | + 'multi' => 'قروش' |
|
78 | + ], |
|
79 | + 'yer' => [ |
|
80 | + 'main1' => 'ريال', |
|
81 | + 'main2' => 'ريالًا', |
|
82 | + 'single' => 'فلس', |
|
83 | + 'multi' => 'فلسات' |
|
84 | + ], |
|
85 | + |
|
86 | + 'jod' => [ |
|
87 | + 'main1' => 'دينار', |
|
88 | + 'main2' => 'دينارًا', |
|
89 | + 'single' => 'قرش', |
|
90 | + 'multi' => 'قروش' |
|
91 | + ], |
|
92 | + |
|
93 | + 'usd' => [ |
|
94 | + 'main1' => 'دولار', |
|
95 | + 'main2' => 'دولاراً', |
|
96 | + 'single' => 'سنت', |
|
97 | + 'multi' => 'سنت' |
|
98 | + ], |
|
99 | 99 | 'sdg' => [ |
100 | 100 | 'main1' => 'قرش', |
101 | 101 | 'main2' => 'قرشاً', |
@@ -129,108 +129,108 @@ discard block |
||
129 | 129 | |
130 | 130 | ], |
131 | 131 | |
132 | - ]; |
|
133 | - /* |
|
132 | + ]; |
|
133 | + /* |
|
134 | 134 | * parsed number |
135 | 135 | * */ |
136 | - public $after_comma_sum; |
|
136 | + public $after_comma_sum; |
|
137 | 137 | |
138 | - /* |
|
138 | + /* |
|
139 | 139 | * array of numbers after split process |
140 | 140 | * */ |
141 | - private $parsed_number; |
|
141 | + private $parsed_number; |
|
142 | 142 | |
143 | - /* |
|
143 | + /* |
|
144 | 144 | * all number array |
145 | 145 | * all array count |
146 | 146 | * */ |
147 | - private $parsed_number_array = []; |
|
148 | - private $all_numbers_len; |
|
147 | + private $parsed_number_array = []; |
|
148 | + private $all_numbers_len; |
|
149 | 149 | |
150 | - /* |
|
150 | + /* |
|
151 | 151 | * before comma number array |
152 | 152 | * before comma array count |
153 | 153 | * */ |
154 | - private $all_numbers_array; |
|
155 | - private $before_comma_len; |
|
154 | + private $all_numbers_array; |
|
155 | + private $before_comma_len; |
|
156 | 156 | |
157 | - /* |
|
157 | + /* |
|
158 | 158 | * after comma number array |
159 | 159 | * after comma array count |
160 | 160 | * */ |
161 | - private $before_comma_array; |
|
162 | - private $after_comma_len; |
|
163 | - private $after_comma_array; |
|
161 | + private $before_comma_array; |
|
162 | + private $after_comma_len; |
|
163 | + private $after_comma_array; |
|
164 | 164 | |
165 | - /* |
|
165 | + /* |
|
166 | 166 | * result before and after comma |
167 | 167 | * |
168 | 168 | * */ |
169 | 169 | public $result_before_comma; |
170 | 170 | public $result_after_comma; |
171 | 171 | |
172 | - private $is_main1_currency = true; |
|
173 | - |
|
174 | - /** |
|
175 | - * @param int $amount |
|
176 | - * @param string $currency |
|
177 | - * |
|
178 | - * @return mixed |
|
179 | - */ |
|
180 | - public static function inArabic($amount = 0,$currency = 'sar') |
|
181 | - { |
|
182 | - return (new self)->setAmount($amount)->initValidation()->prepare()->run()->result($currency); |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * @param string $currency |
|
187 | - * |
|
188 | - * @return mixed |
|
189 | - */ |
|
190 | - public function result($currency = 'sar') |
|
191 | - { |
|
192 | - $result = $this->config['starter'].' '; |
|
193 | - |
|
194 | - if ($this->is_main1_currency){ |
|
195 | - $result .= $this->result_before_comma.' '.$this->config['currencies'][$currency]['main1']; |
|
196 | - |
|
197 | - }else{ |
|
198 | - $result .= $this->result_before_comma.' '.$this->config['currencies'][$currency]['main2']; |
|
199 | - |
|
200 | - } |
|
201 | - if ($this->after_comma_len >= 1 && $this->after_comma_sum != 00){ |
|
202 | - if (in_array($this->after_comma_sum,[ |
|
203 | - 3,4,5,6,7,8,9,10 |
|
204 | - ])){ |
|
205 | - $result .= $this->config['connection_tool'].$this->result_after_comma.' '. |
|
206 | - $this->config['currencies'][$currency]['multi']; |
|
207 | - }else{ |
|
208 | - $result .= $this->config['connection_tool'].$this->result_after_comma.' '. |
|
209 | - $this->config['currencies'][$currency]['single']; |
|
210 | - } |
|
211 | - } |
|
212 | - $result .= ' '.$this->config['end']; |
|
213 | - |
|
214 | - return str_replace(' ',' ',$result); |
|
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * @return $this |
|
219 | - */ |
|
220 | - public function run() |
|
221 | - { |
|
222 | - $this->result_before_comma = $this->runBeforeComma(); |
|
223 | - $this->result_after_comma = $this->runAfterComma(); |
|
224 | - return $this; |
|
225 | - } |
|
226 | - |
|
227 | - /** |
|
228 | - * @return $this |
|
229 | - */ |
|
230 | - public function prepare() |
|
231 | - { |
|
232 | - $this->split_parsed_number_to_two_number_depend_on_comma()->split_numbers_before_comma_to_array()->split_numbers_after_comma_to_array(); |
|
233 | - return $this; |
|
234 | - } |
|
235 | - |
|
236 | - } |
|
172 | + private $is_main1_currency = true; |
|
173 | + |
|
174 | + /** |
|
175 | + * @param int $amount |
|
176 | + * @param string $currency |
|
177 | + * |
|
178 | + * @return mixed |
|
179 | + */ |
|
180 | + public static function inArabic($amount = 0,$currency = 'sar') |
|
181 | + { |
|
182 | + return (new self)->setAmount($amount)->initValidation()->prepare()->run()->result($currency); |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * @param string $currency |
|
187 | + * |
|
188 | + * @return mixed |
|
189 | + */ |
|
190 | + public function result($currency = 'sar') |
|
191 | + { |
|
192 | + $result = $this->config['starter'].' '; |
|
193 | + |
|
194 | + if ($this->is_main1_currency){ |
|
195 | + $result .= $this->result_before_comma.' '.$this->config['currencies'][$currency]['main1']; |
|
196 | + |
|
197 | + }else{ |
|
198 | + $result .= $this->result_before_comma.' '.$this->config['currencies'][$currency]['main2']; |
|
199 | + |
|
200 | + } |
|
201 | + if ($this->after_comma_len >= 1 && $this->after_comma_sum != 00){ |
|
202 | + if (in_array($this->after_comma_sum,[ |
|
203 | + 3,4,5,6,7,8,9,10 |
|
204 | + ])){ |
|
205 | + $result .= $this->config['connection_tool'].$this->result_after_comma.' '. |
|
206 | + $this->config['currencies'][$currency]['multi']; |
|
207 | + }else{ |
|
208 | + $result .= $this->config['connection_tool'].$this->result_after_comma.' '. |
|
209 | + $this->config['currencies'][$currency]['single']; |
|
210 | + } |
|
211 | + } |
|
212 | + $result .= ' '.$this->config['end']; |
|
213 | + |
|
214 | + return str_replace(' ',' ',$result); |
|
215 | + } |
|
216 | + |
|
217 | + /** |
|
218 | + * @return $this |
|
219 | + */ |
|
220 | + public function run() |
|
221 | + { |
|
222 | + $this->result_before_comma = $this->runBeforeComma(); |
|
223 | + $this->result_after_comma = $this->runAfterComma(); |
|
224 | + return $this; |
|
225 | + } |
|
226 | + |
|
227 | + /** |
|
228 | + * @return $this |
|
229 | + */ |
|
230 | + public function prepare() |
|
231 | + { |
|
232 | + $this->split_parsed_number_to_two_number_depend_on_comma()->split_numbers_before_comma_to_array()->split_numbers_after_comma_to_array(); |
|
233 | + return $this; |
|
234 | + } |
|
235 | + |
|
236 | + } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | class Tafqeet |
11 | 11 | { |
12 | - use Calculators,Handler,Validation,App; |
|
12 | + use Calculators, Handler, Validation, App; |
|
13 | 13 | |
14 | 14 | public $config = [ |
15 | 15 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * |
178 | 178 | * @return mixed |
179 | 179 | */ |
180 | - public static function inArabic($amount = 0,$currency = 'sar') |
|
180 | + public static function inArabic($amount = 0, $currency = 'sar') |
|
181 | 181 | { |
182 | 182 | return (new self)->setAmount($amount)->initValidation()->prepare()->run()->result($currency); |
183 | 183 | } |
@@ -191,27 +191,27 @@ discard block |
||
191 | 191 | { |
192 | 192 | $result = $this->config['starter'].' '; |
193 | 193 | |
194 | - if ($this->is_main1_currency){ |
|
194 | + if ($this->is_main1_currency) { |
|
195 | 195 | $result .= $this->result_before_comma.' '.$this->config['currencies'][$currency]['main1']; |
196 | 196 | |
197 | - }else{ |
|
197 | + }else { |
|
198 | 198 | $result .= $this->result_before_comma.' '.$this->config['currencies'][$currency]['main2']; |
199 | 199 | |
200 | 200 | } |
201 | - if ($this->after_comma_len >= 1 && $this->after_comma_sum != 00){ |
|
202 | - if (in_array($this->after_comma_sum,[ |
|
203 | - 3,4,5,6,7,8,9,10 |
|
204 | - ])){ |
|
201 | + if ($this->after_comma_len>=1 && $this->after_comma_sum != 00) { |
|
202 | + if (in_array($this->after_comma_sum, [ |
|
203 | + 3, 4, 5, 6, 7, 8, 9, 10 |
|
204 | + ])) { |
|
205 | 205 | $result .= $this->config['connection_tool'].$this->result_after_comma.' '. |
206 | 206 | $this->config['currencies'][$currency]['multi']; |
207 | - }else{ |
|
207 | + }else { |
|
208 | 208 | $result .= $this->config['connection_tool'].$this->result_after_comma.' '. |
209 | 209 | $this->config['currencies'][$currency]['single']; |
210 | 210 | } |
211 | 211 | } |
212 | 212 | $result .= ' '.$this->config['end']; |
213 | 213 | |
214 | - return str_replace(' ',' ',$result); |
|
214 | + return str_replace(' ', ' ', $result); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |