PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.18
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.18
1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 All 164 releases
woocommerce-pos / vendor_prefixed / picqer / php-barcode-generator / src / BarcodeGenerator.php

BarcodeGenerator.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.18, at vendor_prefixed/picqer/php-barcode-generator/src/BarcodeGenerator.php

189 lines 7.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * General PHP Barcode Generator
5 *
6 * @author Casper Bakker - picqer.com
7 * Based on TCPDF Barcode Generator
8 */
9 // Copyright (C) 2002-2015 Nicola Asuni - Tecnick.com LTD
10 //
11 // This file was part of TCPDF software library.
12 //
13 // TCPDF is free software: you can redistribute it and/or modify it
14 // under the terms of the GNU Lesser General Public License as
15 // published by the Free Software Foundation, either version 3 of the
16 // License, or (at your option) any later version.
17 //
18 // TCPDF is distributed in the hope that it will be useful, but
19 // WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 // See the GNU Lesser General Public License for more details.
22 //
23 // You should have received a copy of the License
24 // along with TCPDF. If not, see
25 // <http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT>.
26 //
27 // See LICENSE.TXT file for more information.
28 namespace WCPOS\Vendor\Picqer\Barcode;
29
30 use WCPOS\Vendor\Picqer\Barcode\Exceptions\UnknownTypeException;
31 use WCPOS\Vendor\Picqer\Barcode\Types\TypeCodabar;
32 use WCPOS\Vendor\Picqer\Barcode\Types\TypeCode11;
33 use WCPOS\Vendor\Picqer\Barcode\Types\TypeCode128;
34 use WCPOS\Vendor\Picqer\Barcode\Types\TypeCode128A;
35 use WCPOS\Vendor\Picqer\Barcode\Types\TypeCode128B;
36 use WCPOS\Vendor\Picqer\Barcode\Types\TypeCode128C;
37 use WCPOS\Vendor\Picqer\Barcode\Types\TypeCode32;
38 use WCPOS\Vendor\Picqer\Barcode\Types\TypeCode39;
39 use WCPOS\Vendor\Picqer\Barcode\Types\TypeCode39Checksum;
40 use WCPOS\Vendor\Picqer\Barcode\Types\TypeCode39Extended;
41 use WCPOS\Vendor\Picqer\Barcode\Types\TypeCode39ExtendedChecksum;
42 use WCPOS\Vendor\Picqer\Barcode\Types\TypeCode93;
43 use WCPOS\Vendor\Picqer\Barcode\Types\TypeEan13;
44 use WCPOS\Vendor\Picqer\Barcode\Types\TypeEan8;
45 use WCPOS\Vendor\Picqer\Barcode\Types\TypeIntelligentMailBarcode;
46 use WCPOS\Vendor\Picqer\Barcode\Types\TypeInterleaved25;
47 use WCPOS\Vendor\Picqer\Barcode\Types\TypeInterleaved25Checksum;
48 use WCPOS\Vendor\Picqer\Barcode\Types\TypeITF14;
49 use WCPOS\Vendor\Picqer\Barcode\Types\TypeKix;
50 use WCPOS\Vendor\Picqer\Barcode\Types\TypeMsi;
51 use WCPOS\Vendor\Picqer\Barcode\Types\TypeMsiChecksum;
52 use WCPOS\Vendor\Picqer\Barcode\Types\TypePharmacode;
53 use WCPOS\Vendor\Picqer\Barcode\Types\TypePharmacodeTwoCode;
54 use WCPOS\Vendor\Picqer\Barcode\Types\TypePlanet;
55 use WCPOS\Vendor\Picqer\Barcode\Types\TypePostnet;
56 use WCPOS\Vendor\Picqer\Barcode\Types\TypeRms4cc;
57 use WCPOS\Vendor\Picqer\Barcode\Types\TypeStandard2of5;
58 use WCPOS\Vendor\Picqer\Barcode\Types\TypeStandard2of5Checksum;
59 use WCPOS\Vendor\Picqer\Barcode\Types\TypeTelepen;
60 use WCPOS\Vendor\Picqer\Barcode\Types\TypeUpcA;
61 use WCPOS\Vendor\Picqer\Barcode\Types\TypeUpcE;
62 use WCPOS\Vendor\Picqer\Barcode\Types\TypeUpcExtension2;
63 use WCPOS\Vendor\Picqer\Barcode\Types\TypeUpcExtension5;
64 abstract class BarcodeGenerator
65 {
66 const TYPE_CODE_32 = 'C32';
67 const TYPE_CODE_39 = 'C39';
68 const TYPE_CODE_39_CHECKSUM = 'C39+';
69 const TYPE_CODE_39E = 'C39E';
70 // CODE 39 EXTENDED
71 const TYPE_CODE_39E_CHECKSUM = 'C39E+';
72 // CODE 39 EXTENDED + CHECKSUM
73 const TYPE_CODE_93 = 'C93';
74 const TYPE_STANDARD_2_5 = 'S25';
75 const TYPE_STANDARD_2_5_CHECKSUM = 'S25+';
76 const TYPE_INTERLEAVED_2_5 = 'I25';
77 const TYPE_INTERLEAVED_2_5_CHECKSUM = 'I25+';
78 const TYPE_ITF_14 = 'ITF14';
79 const TYPE_CODE_128 = 'C128';
80 const TYPE_CODE_128_A = 'C128A';
81 const TYPE_CODE_128_B = 'C128B';
82 const TYPE_CODE_128_C = 'C128C';
83 const TYPE_EAN_2 = 'EAN2';
84 // 2-Digits UPC-Based Extention
85 const TYPE_EAN_5 = 'EAN5';
86 // 5-Digits UPC-Based Extention
87 const TYPE_EAN_8 = 'EAN8';
88 const TYPE_EAN_13 = 'EAN13';
89 const TYPE_UPC_A = 'UPCA';
90 const TYPE_UPC_E = 'UPCE';
91 const TYPE_MSI = 'MSI';
92 // MSI (Variation of Plessey code)
93 const TYPE_MSI_CHECKSUM = 'MSI+';
94 // MSI + CHECKSUM (modulo 11)
95 const TYPE_POSTNET = 'POSTNET';
96 const TYPE_PLANET = 'PLANET';
97 const TYPE_TELEPEN_ALPHA = 'TELEPENALPHA';
98 const TYPE_TELEPEN_NUMERIC = 'TELEPENNUMERIC';
99 const TYPE_RMS4CC = 'RMS4CC';
100 // RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)
101 const TYPE_KIX = 'KIX';
102 // KIX (Klant index - Customer index)
103 const TYPE_IMB = 'IMB';
104 // IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200
105 const TYPE_CODABAR = 'CODABAR';
106 const TYPE_CODE_11 = 'CODE11';
107 const TYPE_PHARMA_CODE = 'PHARMA';
108 const TYPE_PHARMA_CODE_TWO_TRACKS = 'PHARMA2T';
109 protected function getBarcodeData(string $code, string $type) : Barcode
110 {
111 $barcodeDataBuilder = $this->createDataBuilderForType($type);
112 return $barcodeDataBuilder->getBarcodeData($code);
113 }
114 protected function createDataBuilderForType(string $type)
115 {
116 switch (\strtoupper($type)) {
117 case self::TYPE_CODE_32:
118 return new TypeCode32();
119 case self::TYPE_CODE_39:
120 return new TypeCode39();
121 case self::TYPE_CODE_39_CHECKSUM:
122 return new TypeCode39Checksum();
123 case self::TYPE_CODE_39E:
124 return new TypeCode39Extended();
125 case self::TYPE_CODE_39E_CHECKSUM:
126 return new TypeCode39ExtendedChecksum();
127 case self::TYPE_CODE_93:
128 return new TypeCode93();
129 case self::TYPE_STANDARD_2_5:
130 return new TypeStandard2of5();
131 case self::TYPE_STANDARD_2_5_CHECKSUM:
132 return new TypeStandard2of5Checksum();
133 case self::TYPE_INTERLEAVED_2_5:
134 return new TypeInterleaved25();
135 case self::TYPE_INTERLEAVED_2_5_CHECKSUM:
136 return new TypeInterleaved25Checksum();
137 case self::TYPE_ITF_14:
138 return new TypeITF14();
139 case self::TYPE_CODE_128:
140 return new TypeCode128();
141 case self::TYPE_CODE_128_A:
142 return new TypeCode128A();
143 case self::TYPE_CODE_128_B:
144 return new TypeCode128B();
145 case self::TYPE_CODE_128_C:
146 return new TypeCode128C();
147 case self::TYPE_EAN_2:
148 return new TypeUpcExtension2();
149 case self::TYPE_EAN_5:
150 return new TypeUpcExtension5();
151 case self::TYPE_EAN_8:
152 return new TypeEan8();
153 case self::TYPE_EAN_13:
154 return new TypeEan13();
155 case self::TYPE_UPC_A:
156 return new TypeUpcA();
157 case self::TYPE_UPC_E:
158 return new TypeUpcE();
159 case self::TYPE_MSI:
160 return new TypeMsi();
161 case self::TYPE_MSI_CHECKSUM:
162 return new TypeMsiChecksum();
163 case self::TYPE_POSTNET:
164 return new TypePostnet();
165 case self::TYPE_PLANET:
166 return new TypePlanet();
167 case self::TYPE_RMS4CC:
168 return new TypeRms4cc();
169 case self::TYPE_KIX:
170 return new TypeKix();
171 case self::TYPE_IMB:
172 return new TypeIntelligentMailBarcode();
173 case self::TYPE_CODABAR:
174 return new TypeCodabar();
175 case self::TYPE_CODE_11:
176 return new TypeCode11();
177 case self::TYPE_PHARMA_CODE:
178 return new TypePharmacode();
179 case self::TYPE_PHARMA_CODE_TWO_TRACKS:
180 return new TypePharmacodeTwoCode();
181 case self::TYPE_TELEPEN_ALPHA:
182 return new TypeTelepen();
183 case self::TYPE_TELEPEN_NUMERIC:
184 return new TypeTelepen('numeric');
185 }
186 throw new UnknownTypeException();
187 }
188 }
189