Skip to content
This repository has been archived by the owner on Apr 11, 2018. It is now read-only.

Commit

Permalink
Fix for luhn not generating correct check digit
Browse files Browse the repository at this point in the history
  • Loading branch information
brettminnie committed Jun 18, 2014
1 parent dc29e80 commit 22256d8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Opg/Common/Model/Entity/LuhnCheckDigit.php
Expand Up @@ -19,7 +19,7 @@ public static function createCheckSum($number)
$checksum = 0;

foreach (str_split(strrev((string) $number)) as $i => $d) {
$checksum += ($i%2 === 0) ? $d * 2 : $d;
$checksum += ($i%2 === 0) ? array_sum(str_split($d * 2)) : $d;
}

$checksum *= 9;
Expand Down
2 changes: 1 addition & 1 deletion tests/OpgTest/Common/Model/Entity/LuhnCheckDigitTest.php
Expand Up @@ -15,7 +15,7 @@ public function testCreateEvenNumbers()

public function testCreateOddNumbers()
{
$expected = 6;
$expected = 5;
$this->assertEquals($expected, LuhnCheckDigit::createCheckSum(12345));
}

Expand Down

0 comments on commit 22256d8

Please sign in to comment.