Skip to content

Commit d6dc5fc

Browse files
thalfmtonicospinelli
authored andcommitted
Choose Module for Bahia State Registration (#37)
Current discoverModule method has missing a rule to choose what Module is used to calculate digit checker when numbers starting with number 8. Numbers starting with 0, 1, 2, 3, 4, 5 or 8 must be calculated with Module 10. Numbers starting with 6, 7 ou 9 must be calculated with Module 11. [http://www.sintegra.gov.br/Cad_Estados/cad_BA.html](Bahia Rules) fix #36
1 parent 4c6b8e1 commit d6dc5fc

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/StateRegistration/Bahia.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Brazanation\Documents\StateRegistration;
44

55
use Brazanation\Documents\DigitCalculator;
6+
use function in_array;
67

78
final class Bahia extends State
89
{
@@ -60,7 +61,7 @@ private function discoverModule($baseNumber)
6061
if (strlen($baseNumber) == 6) {
6162
$charToCheck = substr($baseNumber, 0, 1);
6263
}
63-
if (6 <= $charToCheck && $charToCheck <= 9) {
64+
if (in_array($charToCheck, [6,7,9])) {
6465
return DigitCalculator::MODULE_11;
6566
}
6667

tests/StateRegistration/BahiaTest.php

+7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ public function provideValidNumbers()
2222
['0635718-30'],
2323
['770288-84'],
2424
['077.028.884'],
25+
['085456408'],
26+
['78215597'],
27+
['75467384'],
28+
['45564835'],
29+
['01314209'],
30+
['111568918'],
31+
['039681030']
2532
];
2633
}
2734

0 commit comments

Comments
 (0)