@@ -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,151 +1,151 @@ |
||
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 | - 'connection_tool' => ' و', |
|
16 | - 'default_currency' => 'sar', |
|
17 | - 'starter' => 'فقط', |
|
18 | - 'end' => 'لاغير', |
|
19 | - 'currencies' => [ |
|
20 | - 'sar' => [ |
|
21 | - 'main1' => 'ريال', |
|
22 | - 'main2' => 'ريالاً', |
|
23 | - 'single' => 'هللة', |
|
24 | - 'multi' => 'هللات' |
|
25 | - ], |
|
26 | - |
|
27 | - 'sdg' => [ |
|
28 | - 'main1' => 'قرش', |
|
29 | - 'main2' => 'قرشاً', |
|
30 | - 'single' => 'قرش', |
|
31 | - 'multi' => 'قروش' |
|
32 | - ], |
|
33 | - |
|
34 | - 'usd' => [ |
|
35 | - 'main1' => 'دولار', |
|
36 | - 'main2' => 'دولاراً', |
|
37 | - 'single' => 'سنت', |
|
38 | - 'multi' => 'سنت' |
|
39 | - ], |
|
40 | - |
|
41 | - |
|
42 | - ], |
|
43 | - |
|
44 | - ]; |
|
45 | - /* |
|
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 | + 'connection_tool' => ' و', |
|
16 | + 'default_currency' => 'sar', |
|
17 | + 'starter' => 'فقط', |
|
18 | + 'end' => 'لاغير', |
|
19 | + 'currencies' => [ |
|
20 | + 'sar' => [ |
|
21 | + 'main1' => 'ريال', |
|
22 | + 'main2' => 'ريالاً', |
|
23 | + 'single' => 'هللة', |
|
24 | + 'multi' => 'هللات' |
|
25 | + ], |
|
26 | + |
|
27 | + 'sdg' => [ |
|
28 | + 'main1' => 'قرش', |
|
29 | + 'main2' => 'قرشاً', |
|
30 | + 'single' => 'قرش', |
|
31 | + 'multi' => 'قروش' |
|
32 | + ], |
|
33 | + |
|
34 | + 'usd' => [ |
|
35 | + 'main1' => 'دولار', |
|
36 | + 'main2' => 'دولاراً', |
|
37 | + 'single' => 'سنت', |
|
38 | + 'multi' => 'سنت' |
|
39 | + ], |
|
40 | + |
|
41 | + |
|
42 | + ], |
|
43 | + |
|
44 | + ]; |
|
45 | + /* |
|
46 | 46 | * parsed number |
47 | 47 | * */ |
48 | - public $after_comma_sum; |
|
48 | + public $after_comma_sum; |
|
49 | 49 | |
50 | - /* |
|
50 | + /* |
|
51 | 51 | * array of numbers after split process |
52 | 52 | * */ |
53 | - private $parsed_number; |
|
53 | + private $parsed_number; |
|
54 | 54 | |
55 | - /* |
|
55 | + /* |
|
56 | 56 | * all number array |
57 | 57 | * all array count |
58 | 58 | * */ |
59 | - private $parsed_number_array = []; |
|
60 | - private $all_numbers_len; |
|
59 | + private $parsed_number_array = []; |
|
60 | + private $all_numbers_len; |
|
61 | 61 | |
62 | - /* |
|
62 | + /* |
|
63 | 63 | * before comma number array |
64 | 64 | * before comma array count |
65 | 65 | * */ |
66 | - private $all_numbers_array; |
|
67 | - private $before_comma_len; |
|
66 | + private $all_numbers_array; |
|
67 | + private $before_comma_len; |
|
68 | 68 | |
69 | - /* |
|
69 | + /* |
|
70 | 70 | * after comma number array |
71 | 71 | * after comma array count |
72 | 72 | * */ |
73 | - private $before_comma_array; |
|
74 | - private $after_comma_len; |
|
75 | - private $after_comma_array; |
|
73 | + private $before_comma_array; |
|
74 | + private $after_comma_len; |
|
75 | + private $after_comma_array; |
|
76 | 76 | |
77 | - /* |
|
77 | + /* |
|
78 | 78 | * result before and after comma |
79 | 79 | * |
80 | 80 | * */ |
81 | - private $result_before_comma; |
|
82 | - private $result_after_comma; |
|
81 | + private $result_before_comma; |
|
82 | + private $result_after_comma; |
|
83 | 83 | |
84 | - private $is_main1_currency = true; |
|
84 | + private $is_main1_currency = true; |
|
85 | 85 | |
86 | - /** |
|
87 | - * @param int $amount |
|
88 | - * @param string $currency |
|
89 | - * |
|
90 | - * @return mixed |
|
91 | - */ |
|
92 | - public static function inArabic($amount = 0,$currency = 'sar') |
|
93 | - { |
|
86 | + /** |
|
87 | + * @param int $amount |
|
88 | + * @param string $currency |
|
89 | + * |
|
90 | + * @return mixed |
|
91 | + */ |
|
92 | + public static function inArabic($amount = 0,$currency = 'sar') |
|
93 | + { |
|
94 | 94 | |
95 | - $amount = money_format("%i",$amount); // update the amount to be always 2 digit after comma |
|
95 | + $amount = money_format("%i",$amount); // update the amount to be always 2 digit after comma |
|
96 | 96 | |
97 | 97 | // |
98 | - return (new self)->setAmount($amount)->initValidation()->prepare()->run()->result($currency); |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * @param string $currency |
|
103 | - * |
|
104 | - * @return mixed |
|
105 | - */ |
|
106 | - public function result($currency = 'sar') |
|
107 | - { |
|
108 | - $result = $this->config['starter'].' '; |
|
109 | - |
|
110 | - if ($this->is_main1_currency){ |
|
111 | - $result .= $this->result_before_comma.' '.$this->config['currencies'][$currency]['main1']; |
|
112 | - |
|
113 | - }else{ |
|
114 | - $result .= $this->result_before_comma.' '.$this->config['currencies'][$currency]['main2']; |
|
115 | - |
|
116 | - } |
|
117 | - if ($this->after_comma_len >= 1 && $this->after_comma_sum != 00){ |
|
118 | - if (in_array($this->after_comma_sum,[ |
|
119 | - 3,4,5,6,7,8,9,10 |
|
120 | - ])){ |
|
121 | - $result .= $this->config['connection_tool'].$this->result_after_comma.' '. |
|
122 | - $this->config['currencies'][$currency]['multi']; |
|
123 | - }else{ |
|
124 | - $result .= $this->config['connection_tool'].$this->result_after_comma.' '. |
|
125 | - $this->config['currencies'][$currency]['single']; |
|
126 | - } |
|
127 | - } |
|
128 | - $result .= ' '.$this->config['end']; |
|
129 | - |
|
130 | - return str_replace(' ',' ',$result); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * @return $this |
|
135 | - */ |
|
136 | - public function run() |
|
137 | - { |
|
138 | - $this->result_before_comma = $this->runBeforeComma(); |
|
139 | - $this->result_after_comma = $this->runAfterComma(); |
|
140 | - return $this; |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * @return $this |
|
145 | - */ |
|
146 | - public function prepare() |
|
147 | - { |
|
148 | - $this->split_parsed_number_to_two_number_depend_on_comma()->split_numbers_before_comma_to_array()->split_numbers_after_comma_to_array(); |
|
149 | - return $this; |
|
150 | - } |
|
151 | - } |
|
98 | + return (new self)->setAmount($amount)->initValidation()->prepare()->run()->result($currency); |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * @param string $currency |
|
103 | + * |
|
104 | + * @return mixed |
|
105 | + */ |
|
106 | + public function result($currency = 'sar') |
|
107 | + { |
|
108 | + $result = $this->config['starter'].' '; |
|
109 | + |
|
110 | + if ($this->is_main1_currency){ |
|
111 | + $result .= $this->result_before_comma.' '.$this->config['currencies'][$currency]['main1']; |
|
112 | + |
|
113 | + }else{ |
|
114 | + $result .= $this->result_before_comma.' '.$this->config['currencies'][$currency]['main2']; |
|
115 | + |
|
116 | + } |
|
117 | + if ($this->after_comma_len >= 1 && $this->after_comma_sum != 00){ |
|
118 | + if (in_array($this->after_comma_sum,[ |
|
119 | + 3,4,5,6,7,8,9,10 |
|
120 | + ])){ |
|
121 | + $result .= $this->config['connection_tool'].$this->result_after_comma.' '. |
|
122 | + $this->config['currencies'][$currency]['multi']; |
|
123 | + }else{ |
|
124 | + $result .= $this->config['connection_tool'].$this->result_after_comma.' '. |
|
125 | + $this->config['currencies'][$currency]['single']; |
|
126 | + } |
|
127 | + } |
|
128 | + $result .= ' '.$this->config['end']; |
|
129 | + |
|
130 | + return str_replace(' ',' ',$result); |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * @return $this |
|
135 | + */ |
|
136 | + public function run() |
|
137 | + { |
|
138 | + $this->result_before_comma = $this->runBeforeComma(); |
|
139 | + $this->result_after_comma = $this->runAfterComma(); |
|
140 | + return $this; |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * @return $this |
|
145 | + */ |
|
146 | + public function prepare() |
|
147 | + { |
|
148 | + $this->split_parsed_number_to_two_number_depend_on_comma()->split_numbers_before_comma_to_array()->split_numbers_after_comma_to_array(); |
|
149 | + return $this; |
|
150 | + } |
|
151 | + } |