Skip to content

Commit 50f240b

Browse files
authored
Merge pull request #2 from rakibdevs/hotfix/bncommalakh-protected
Fixed Protected Method Issue and Refactor
2 parents c8cedd2 + b632daa commit 50f240b

8 files changed

+275
-140
lines changed

src/Exceptions/InvalidNumber.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Rakibhstu\Banglanumber\Exceptions;
34

45
use Exception;
@@ -9,4 +10,4 @@ public static function message()
910
{
1011
return new static("The given value is not a valid number.");
1112
}
12-
}
13+
}

src/Exceptions/InvalidRange.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?php
2+
23
namespace Rakibhstu\Banglanumber\Exceptions;
34

45
use Exception;
56

6-
class InvalidRange extends Exception
7+
class InvalidRange extends Exception
78
{
89
public static function message($max = 999999999999999)
910
{
10-
return new static("The given value is not in valid range. Maximum accepted value is ".$max);
11+
return new static("The given value is not in valid range. Maximum accepted value is " . $max);
1112
}
12-
}
13+
}

src/NumberToBangla.php

+6-9
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,32 @@ class NumberToBangla
1313

1414
public function __construct()
1515
{
16-
$this->process = new ProcessNumber;
17-
$this->date = new ProcessDate;
16+
$this->process = new ProcessNumber();
17+
$this->date = new ProcessDate();
1818
}
1919

2020
public function bnNum($number)
2121
{
2222
return $this->process->bnNum($number);
2323
}
2424

25-
2625
public function bnWord($number)
27-
{
26+
{
2827
return $this->process->bnWord($number);
2928
}
3029

3130
public function bnMoney($number)
32-
{
31+
{
3332
return $this->process->bnMoney($number);
3433
}
3534

3635
public function bnCommaLakh($number)
3736
{
38-
return $this->process->bnCommaLakh($number);
37+
return $this->process->bnCommaLakh($number);
3938
}
4039

41-
public function bnMonth($number)
40+
public function bnMonth($number)
4241
{
4342
return $this->date->bnMonth($number);
44-
4543
}
46-
4744
}

src/NumberToBanglaServiceProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class NumberToBanglaServiceProvider extends ServiceProvider
1515
public function register()
1616
{
1717
$this->app->singleton(NumberToBangla::class);
18-
18+
1919
$this->app->alias(NumberToBangla::class, 'bangla-number');
2020
}
2121

src/ProcessDate.php

+37-30
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,55 @@
77

88
class ProcessDate
99
{
10-
11-
protected $bn_month = array(
12-
'1' => 'জানুয়ারি',
13-
'2' => 'ফেব্রুয়ারি',
14-
'3' => 'মার্চ',
15-
'4' => 'এপ্রিল',
16-
'5' => 'মে',
17-
'6' => 'জুন',
18-
'7' => 'জুলাই',
19-
'8' => 'আগস্ট',
20-
'9' => 'সেপ্টেম্বর',
21-
'10' => 'অক্টোবর',
22-
'11' => 'নভেম্বর',
23-
'12' => 'ডিসেম্বর'
24-
);
25-
26-
protected $numbers = array('','','','','','','','','','');
27-
28-
29-
public function isValid($number)
10+
protected $bn_month = [
11+
'1' => 'জানুয়ারি',
12+
'2' => 'ফেব্রুয়ারি',
13+
'3' => 'মার্চ',
14+
'4' => 'এপ্রিল',
15+
'5' => 'মে',
16+
'6' => 'জুন',
17+
'7' => 'জুলাই',
18+
'8' => 'আগস্ট',
19+
'9' => 'সেপ্টেম্বর',
20+
'10' => 'অক্টোবর',
21+
'11' => 'নভেম্বর',
22+
'12' => 'ডিসেম্বর'
23+
];
24+
25+
protected $numbers = [
26+
'',
27+
'',
28+
'',
29+
'',
30+
'',
31+
'',
32+
'',
33+
'',
34+
'',
35+
''
36+
];
37+
38+
39+
public function isValid($number)
3040
{
31-
if(!is_numeric($number)){
41+
if (!is_numeric($number)) {
3242
throw InvalidNumber::message();
3343
}
3444

35-
if($number > 999999999999999 || strpos($number, 'E') !== false){
45+
if ($number > 999999999999999 || strpos($number, 'E') !== false) {
3646
throw InvalidRange::message();
3747
}
3848
}
3949

4050

41-
public function bnMonth($number)
51+
public function bnMonth($number)
4252
{
4353
$this->isValid($number);
4454

45-
if($number >= 1 && $number <= 12 ){
55+
if ($number >= 1 && $number <= 12) {
4656
return $this->bn_month[(int)$number];
47-
}else{
48-
throw InvalidRange::message(12);
4957
}
50-
51-
}
5258

53-
54-
}
59+
throw InvalidRange::message(12);
60+
}
61+
}

0 commit comments

Comments
 (0)