7
7
8
8
class ProcessNumber
9
9
{
10
+ /**
11
+ * @var string[]
12
+ */
10
13
protected $ words = [
11
14
'' ,
12
15
'এক ' ,
@@ -110,6 +113,9 @@ class ProcessNumber
110
113
'নিরানব্বই '
111
114
];
112
115
116
+ /**
117
+ * @var string[]
118
+ */
113
119
protected $ bn_num = [
114
120
'শূন্য ' ,
115
121
'এক ' ,
@@ -123,6 +129,9 @@ class ProcessNumber
123
129
'নয় '
124
130
];
125
131
132
+ /**
133
+ * @var string[]
134
+ */
126
135
protected $ numbers = [
127
136
'০ ' ,
128
137
'১ ' ,
@@ -137,6 +146,10 @@ class ProcessNumber
137
146
];
138
147
139
148
149
+ /**
150
+ * @throws InvalidNumber
151
+ * @throws InvalidRange
152
+ */
140
153
public function isValid ($ number )
141
154
{
142
155
if (!is_numeric ($ number )) {
@@ -148,6 +161,12 @@ public function isValid($number)
148
161
}
149
162
}
150
163
164
+ /**
165
+ * @param $number
166
+ * @return string
167
+ * @throws InvalidNumber
168
+ * @throws InvalidRange
169
+ */
151
170
public function bnNum ($ number )
152
171
{
153
172
$ this ->isValid ($ number );
@@ -156,9 +175,15 @@ public function bnNum($number)
156
175
}
157
176
158
177
178
+ /**
179
+ * @param $number
180
+ * @return string
181
+ * @throws InvalidNumber
182
+ * @throws InvalidRange
183
+ */
159
184
public function bnWord ($ number )
160
185
{
161
- $ valid = $ this ->isValid ($ number );
186
+ $ this ->isValid ($ number );
162
187
163
188
if ($ number == 0 ) {
164
189
return 'শূন্য ' ;
@@ -171,6 +196,12 @@ public function bnWord($number)
171
196
return $ this ->toWord ($ number );
172
197
}
173
198
199
+ /**
200
+ * @param $number
201
+ * @return string
202
+ * @throws InvalidNumber
203
+ * @throws InvalidRange
204
+ */
174
205
public function bnMoney ($ number )
175
206
{
176
207
$ this ->isValid ($ number );
@@ -186,6 +217,10 @@ public function bnMoney($number)
186
217
return $ this ->toWord ($ number ) . ' টাকা ' ;
187
218
}
188
219
220
+ /**
221
+ * @throws InvalidNumber
222
+ * @throws InvalidRange
223
+ */
189
224
public function bnCommaLakh ($ number )
190
225
{
191
226
$ this ->isValid ($ number );
@@ -195,6 +230,10 @@ public function bnCommaLakh($number)
195
230
return strtr ($ n , $ this ->numbers );
196
231
}
197
232
233
+ /**
234
+ * @param $num
235
+ * @return string
236
+ */
198
237
protected function toWord ($ num )
199
238
{
200
239
$ text = '' ;
@@ -228,19 +267,23 @@ protected function toWord($num)
228
267
$ text .= $ this ->words [$ hundred ] . ' শত ' ;
229
268
}
230
269
231
- $ hundred_div = ( int ) ( $ thousand_div % 100 ) ;
270
+ $ hundred_div = $ thousand_div % 100 ;
232
271
if ($ hundred_div > 0 ) {
233
272
$ text .= $ this ->words [$ hundred_div ];
234
273
}
235
274
236
275
return $ text ;
237
276
}
238
277
278
+ /**
279
+ * @param $num
280
+ * @return string
281
+ */
239
282
protected function toDecimalWord ($ num )
240
283
{
241
284
$ text = '' ;
242
285
$ decimalParts = str_split ($ num );
243
- foreach ($ decimalParts as $ key => $ decimalPart ) {
286
+ foreach ($ decimalParts as $ decimalPart ) {
244
287
$ text .= $ this ->bn_num [$ decimalPart ] . ' ' ;
245
288
}
246
289
@@ -249,7 +292,7 @@ protected function toDecimalWord($num)
249
292
250
293
/**
251
294
* Convert float number to text
252
- *
295
+ *
253
296
*/
254
297
private function convertFloatNumberToWord ($ number )
255
298
{
@@ -264,7 +307,8 @@ private function convertFloatNumberToWord($number)
264
307
265
308
/**
266
309
* Convert float number to money format
267
- *
310
+ * @param $number
311
+ * @return string
268
312
*/
269
313
private function convertFloatNumberToMoneyFormat ($ number )
270
314
{
0 commit comments