File tree 1 file changed +6
-0
lines changed
1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change 5
5
use Picqer \Barcode \Barcode ;
6
6
use Picqer \Barcode \BarcodeBar ;
7
7
use Picqer \Barcode \Exceptions \InvalidCharacterException ;
8
+ use Picqer \Barcode \Exceptions \InvalidCheckDigitException ;
8
9
use Picqer \Barcode \Exceptions \InvalidLengthException ;
9
10
10
11
class TypeITF14 implements TypeInterface
11
12
{
12
13
/**
13
14
* @throws InvalidLengthException
14
15
* @throws InvalidCharacterException
16
+ * @throws InvalidCheckDigitException
15
17
*/
16
18
public function getBarcodeData (string $ code ): Barcode
17
19
{
@@ -35,6 +37,10 @@ public function getBarcodeData(string $code): Barcode
35
37
36
38
if (strlen ($ code ) === 13 ) {
37
39
$ code .= $ this ->getChecksum ($ code );
40
+ } elseif (substr ($ code , -1 ) !== $ this ->getChecksum (substr ($ code , 0 , -1 ))) {
41
+ // If length of given barcode is same as final length, barcode is including checksum
42
+ // Make sure that checksum is the same as we calculated
43
+ throw new InvalidCheckDigitException ();
38
44
}
39
45
40
46
$ barcode = new Barcode ($ code );
You can’t perform that action at this time.
0 commit comments