1- <?php
2-
3- namespace Picqer \Barcode \Types ;
1+ <?php namespace Igor \BaseCode \Classes \Barcode \Types ;
42
53use Picqer \Barcode \Barcode ;
64use Picqer \Barcode \BarcodeBar ;
75use Picqer \Barcode \Exceptions \InvalidCharacterException ;
86use Picqer \Barcode \Exceptions \InvalidLengthException ;
97use Picqer \Barcode \Types \TypeInterface ;
108
11- /**
12- * ITF-14 is the GS1 implementation of an Interleaved 2 of 5 (ITF) bar code
13- * to encode a Global Trade Item Number. ITF-14 symbols are generally used
14- * on packaging levels of a product, such as a case box of 24 cans of soup.
15- * The ITF-14 will always encode 14 digits.
16- */
17-
18- class TypeITF14 implements TypeInterface
9+ class TypeCodeITF14 implements TypeInterface
1910{
2011 /**
2112 * @throws InvalidLengthException
@@ -37,8 +28,7 @@ public function getBarcodeData(string $code): Barcode
3728 $ chr ['8 ' ] = '21121 ' ;
3829 $ chr ['9 ' ] = '12121 ' ;
3930
40-
41- if (strlen ($ code ) == 13 ) {
31+ if (strlen ($ code ) === 13 ) {
4232 $ total = 0 ;
4333
4434 for ($ i = 0 ; $ i <= strlen ($ code ) - 1 ; $ i ++) {
@@ -48,8 +38,9 @@ public function getBarcodeData(string $code): Barcode
4838
4939 $ cs = $ total % 10 ;
5040 $ cs = 10 - $ cs ;
51- if ($ cs === 10 )
41+ if ($ cs === 10 ) {
5242 $ cs = 0 ;
43+ }
5344
5445 $ code .= (string ) $ cs ;
5546 }
@@ -71,8 +62,7 @@ public function getBarcodeData(string $code): Barcode
7162 }
7263
7364 for ($ i = 0 ; $ i < strlen ($ code ); $ i += 2 ) {
74-
75- if (!isset ($ chr [$ code {$ i }]) || !isset ($ chr [$ code {$ i + 1 }])) {
65+ if (!isset ($ chr [$ code [$ i ]]) || !isset ($ chr [$ code [$ i + 1 ]])) {
7666 throw new InvalidCharacterException ();
7767 }
7868
@@ -93,14 +83,13 @@ public function getBarcodeData(string $code): Barcode
9383 foreach ($ pmixedarr as $ x ) {
9484 if ($ bars ) {
9585 $ t = true ;
96- $ w = ($ x === '1 ' ) ? '1 ' : '2 ' ;
9786 } else {
9887 $ t = false ;
99- $ w = ($ x === '1 ' ) ? '1 ' : '2 ' ;
10088 }
89+ $ w = ($ x === '1 ' ) ? '1 ' : '2 ' ;
10190
10291 $ barcode ->addBar (new BarcodeBar ($ w , 1 , $ t ));
103- $ bars = !$ bars ;
92+ $ bars = !$ bars ;
10493 ++$ k ;
10594 }
10695 }
0 commit comments