Skip to content

Commit

Permalink
Fix checksum validation in case control number equals 10 (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyubendo authored Dec 21, 2021
1 parent 79821cc commit c5cd66c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public function isValid(): bool
}

$control = (int)($controlSum - (11 * (int)($controlSum / 11)));
if ($control === 10) {
$control = 0;
}

return $control == (int)$split[9];
}
Expand Down
7 changes: 7 additions & 0 deletions tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ public function testInvalidInn(): void
new Inn\Parser("invalidInn");
}

public function testValidCheckSum(): void
{
$parser = new Inn\Parser("3584004820");

$this->assertEquals(true, $parser->isValid());
}

public function testMaximalValue(): void
{
$minValue = Inn\Parser::minimalValue();
Expand Down

0 comments on commit c5cd66c

Please sign in to comment.