Skip to content

Commit acaf80f

Browse files
committed
Fixed checksum calculation for ITF14 barcode type
source: How to calculate a check digit manually https://www.gs1.org/services/how-calculate-check-digit-manually
1 parent 0cc7fbd commit acaf80f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Types/TypeITF14.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ private function getChecksum(string $code): string
7373
$total = 0;
7474

7575
for ($charIndex = 0; $charIndex <= (strlen($code) - 1); $charIndex++) {
76-
$integerOfChar = intval($code . substr($charIndex, 1));
77-
$total += $integerOfChar * (($charIndex === 0 || $charIndex % 2 === 0) ? 3 : 1);
76+
$integerOfChar = intval($code[$charIndex]);
77+
$total += $integerOfChar * ($charIndex % 2 === 0 ? 3 : 1);
7878
}
7979

8080
$checksum = 10 - ($total % 10);

0 commit comments

Comments
 (0)