@@ -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)!='') |
@@ -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) |
@@ -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 | + } |