Complex classes like DefaultPrinter often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use DefaultPrinter, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
35 | abstract class DefaultPrinter implements PrinterInterface |
||
36 | { |
||
37 | //set standards |
||
38 | const NUL = "\x0"; //Nulo |
||
39 | const EOT = "\x4"; //EOT fim da transmissão |
||
40 | const ENQ = "\x5"; //ENQ colocar na fila Pedido de status 1 |
||
41 | const HT = "\x9"; //tabulação horizontal |
||
42 | const VT = "\xb"; //tabulação vertical |
||
43 | const LF = "\x0a"; //Inicia a impressão e avança uma linha |
||
44 | const FF = "\x0c"; //avança pagina |
||
45 | const CR = "\x0d"; //retorno de carro |
||
46 | const DLE = "\x10"; //Data Link Escape |
||
47 | const CAN = "\x18"; //CAN Cancela linha enviada |
||
48 | const BEL = "\x07"; //BEL sinal sonoro |
||
49 | const ESC = "\x1b"; //escape |
||
50 | const FS = "\x1c"; //FS |
||
51 | const GS = "\x1d"; //GS |
||
52 | const SO = "\x0e"; //SO Inicia modo expandido |
||
53 | const DC1 = "\x11"; //DC1 Inicia modo enfatizado |
||
54 | const DC2 = "\x12"; //DC2 Cancela modo condensado |
||
55 | const DC3 = "\x13"; //DC3 Cancela modo enfatizado |
||
56 | const DC4 = "\x14"; //DC4 Controle de dispositivo 4 Inicia modo normal |
||
57 | const SI = "\x0f"; //Seleciona modo condensado |
||
58 | const EM = "\x19"; //Avança 4 linhas |
||
59 | const DEL = "\x7f"; //Cancela último caracter |
||
60 | const NAK = "\x15"; // |
||
61 | const SYN = "\x16"; //Sincronismo |
||
62 | const NOTRANS = false; //not translate characters codepage |
||
63 | const TRANS = true; //perform a character convertion to codepage |
||
64 | const ACK = '\x06'; //Acknowledge |
||
65 | //Cut types |
||
66 | const CUT_FULL = 65; |
||
67 | const CUT_PARTIAL = 66; |
||
68 | //Image sizing options |
||
69 | const IMG_DEFAULT = 0; |
||
70 | const IMG_DOUBLE_WIDTH = 1; |
||
71 | const IMG_DOUBLE_HEIGHT = 2; |
||
72 | |||
73 | /** |
||
74 | * List all available region pages. |
||
75 | * |
||
76 | * @var array |
||
77 | */ |
||
78 | protected $aRegion = array( |
||
79 | 'USA', |
||
80 | 'FRANCE', |
||
81 | 'GERMANY', |
||
82 | 'UK', |
||
83 | 'DENMARK', |
||
84 | 'SWEDEN', |
||
85 | 'ITALY', |
||
86 | 'SPAIN', |
||
87 | 'JAPAN', |
||
88 | 'NORWAY', |
||
89 | 'DENMARK2', |
||
90 | 'SPAIN2', |
||
91 | 'LATIN', |
||
92 | 'KOREA', |
||
93 | 'SLOVENIA', |
||
94 | 'CHINA', |
||
95 | 'VIETNAM', |
||
96 | 'ARABIA' |
||
97 | ); |
||
98 | |||
99 | /** |
||
100 | * List all available code pages. |
||
101 | * |
||
102 | * @var array |
||
103 | */ |
||
104 | protected $aCodePage = array( |
||
105 | 'CP437' => array('conv' => '437', 'table' => '0', 'desc' => 'PC437: USA, Standard Europe'), |
||
106 | 'CP850' => array('conv' => '850', 'table' => '2', 'desc' => 'PC850: Multilingual'), |
||
107 | 'CP860' => array('conv' => '860', 'table' => '3', 'desc' => 'PC860: Portuguese'), |
||
108 | 'CP863' => array('conv' => '863', 'table' => '4', 'desc' => 'PC863: Canadian-French'), |
||
109 | 'CP865' => array('conv' => '865', 'table' => '5', 'desc' => 'PC865: Nordic'), |
||
110 | 'CP851' => array('conv' => '851', 'table' => '11', 'desc' => 'PC851: Greek'), |
||
111 | 'CP853' => array('conv' => '853', 'table' => '12', 'desc' => 'PC853: Turkish'), |
||
112 | 'CP857' => array('conv' => '857', 'table' => '13', 'desc' => 'PC857: Turkish'), |
||
113 | 'CP737' => array('conv' => '737', 'table' => '14', 'desc' => 'PC737: Greek'), |
||
114 | 'ISO8859-7' => array('conv' => 'ISO8859-7', 'table' => '15', 'desc' => 'ISO8859-7: Greek'), |
||
115 | 'CP866' => array('conv' => '866', 'table' => '17', 'desc' => 'PC866: Cyrillic #2'), |
||
116 | 'CP852' => array('conv' => '852', 'table' => '18', 'desc' => 'PC852: Latin2'), |
||
117 | 'CP858' => array('conv' => '858', 'table' => '19', 'desc' => 'PC858: Euro'), |
||
118 | 'CP720' => array('conv' => '720', 'table' => '32', 'desc' => 'PC720: Arabic'), |
||
119 | 'CP855' => array('conv' => '855', 'table' => '34', 'desc' => 'PC855: Cyrillic'), |
||
120 | 'CP861' => array('conv' => '861', 'table' => '35', 'desc' => 'PC861: Icelandic'), |
||
121 | 'CP862' => array('conv' => '862', 'table' => '36', 'desc' => 'PC862: Hebrew'), |
||
122 | 'CP864' => array('conv' => '864', 'table' => '37', 'desc' => 'PC864: Arabic'), |
||
123 | 'CP869' => array('conv' => '869', 'table' => '38', 'desc' => 'PC869: Greek'), |
||
124 | 'ISO8859-2' => array('conv' => 'ISO8859-2', 'table' => '39', 'desc' => 'ISO8859-2: Latin2'), |
||
125 | 'ISO8859-15' => array('conv' => 'ISO8859-15', 'table' => '40', 'desc' => 'ISO8859-15: Latin9'), |
||
126 | 'WINDOWS-1250' => array('conv' => 'WINDOWS-1250', 'table' => '45', 'desc' => 'WPC1250: Latin2'), |
||
127 | 'WINDOWS-1251' => array('conv' => 'WINDOWS-1251', 'table' => '46', 'desc' => 'WPC1251: Cyrillic'), |
||
128 | 'WINDOWS-1252' => array('conv' => 'WINDOWS-1252', 'table' => '47', 'desc' => 'WPC1253: Greek'), |
||
129 | 'WINDOWS-1254' => array('conv' => 'WINDOWS-1254', 'table' => '48', 'desc' => 'WPC1254: Turkish'), |
||
130 | 'WINDOWS-1255' => array('conv' => 'WINDOWS-1255', 'table' => '49', 'desc' => 'WPC1255: Hebrew'), |
||
131 | 'WINDOWS-1256' => array('conv' => 'WINDOWS-1256', 'table' => '50', 'desc' => 'WPC1256: Arabic'), |
||
132 | 'WINDOWS-1257' => array('conv' => 'WINDOWS-1257', 'table' => '51', 'desc' => 'WPC1257: Baltic Rim'), |
||
133 | 'WINDOWS-1258' => array('conv' => 'WINDOWS-1258', 'table' => '52', 'desc' => 'WPC1258: Vietnamese'), |
||
134 | ); |
||
135 | |||
136 | /** |
||
137 | * Seleted code page |
||
138 | * Defined in printer class. |
||
139 | * @var string |
||
140 | */ |
||
141 | protected $codepage = 'CP437'; |
||
142 | /** |
||
143 | * Number of codpage in printer memory. |
||
144 | * @var int |
||
145 | */ |
||
146 | protected $charsetTableNum = 0; |
||
147 | /** |
||
148 | * Selected Region character page |
||
149 | * Defined in printer class. |
||
150 | * @var string |
||
151 | */ |
||
152 | protected $region = 'LATIN'; |
||
153 | /** |
||
154 | * List all avaiable fonts |
||
155 | * @var array |
||
156 | */ |
||
157 | protected $aFont = array(0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D', 4 => 'E', 97 => 'SA', 98 => 'SB'); |
||
158 | /** |
||
159 | * Selected internal font. |
||
160 | * @var string |
||
161 | */ |
||
162 | protected $font = 'A'; |
||
163 | /** |
||
164 | * Resolution in dpi. |
||
165 | * @var int |
||
166 | */ |
||
167 | public $dpi = 203; //dots per inch |
||
168 | /** |
||
169 | * Resolution in dpmm. |
||
170 | * @var int |
||
171 | */ |
||
172 | public $dpmm = 8; //dots per mm |
||
173 | /** |
||
174 | * Maximum width paper. |
||
175 | * @var int |
||
176 | */ |
||
177 | public $widthMaxmm = 80;//mm |
||
178 | /** |
||
179 | * Selected Width paper. |
||
180 | * @var int |
||
181 | */ |
||
182 | public $widthPaper = 80;//mm |
||
183 | /** |
||
184 | * Maximum width for printed area. |
||
185 | * @var int |
||
186 | */ |
||
187 | public $widthPrint = 72;//mm |
||
188 | /** |
||
189 | * Maximum width for printed area in dots. |
||
190 | * @var int |
||
191 | */ |
||
192 | public $widthMaxdots = 576;//dots |
||
193 | /** |
||
194 | * Maximum number of characters per line. |
||
195 | * @var int |
||
196 | */ |
||
197 | public $maxchars = 48;//max characters per line |
||
198 | |||
199 | //protected property standards |
||
200 | /** |
||
201 | * Connector to printer. |
||
202 | * @var ConnectorInterface|null |
||
203 | */ |
||
204 | protected $connector = null; |
||
205 | /** |
||
206 | * Seleted printer mode. |
||
207 | * @var string |
||
208 | */ |
||
209 | protected $printerMode = 'normal'; |
||
210 | /** |
||
211 | * Selected bold mode. |
||
212 | * @var bool |
||
213 | */ |
||
214 | protected $boldMode = false; |
||
215 | /** |
||
216 | * Selected italic mode. |
||
217 | * @var bool |
||
218 | */ |
||
219 | protected $italicMode = false; |
||
220 | /** |
||
221 | * Selected condenced mode. |
||
222 | * @var bool |
||
223 | */ |
||
224 | protected $condensedMode = false; |
||
225 | /** |
||
226 | * Selected expanded mode. |
||
227 | * @var bool |
||
228 | */ |
||
229 | protected $expandedMode = false; |
||
230 | /** |
||
231 | * Seleted double higth mode. |
||
232 | * @var bool |
||
233 | */ |
||
234 | protected $doubleHeigth = false; |
||
235 | /** |
||
236 | * Selected reverse colors mode. |
||
237 | * @var bool |
||
238 | */ |
||
239 | protected $reverseColors = false; |
||
240 | /** |
||
241 | * Selected under lined mode. |
||
242 | * @var bool |
||
243 | */ |
||
244 | protected $underlineMode = false; |
||
245 | /** |
||
246 | * Selected rotate 90 degrees mode |
||
247 | * @var bool |
||
248 | */ |
||
249 | protected $rotateMode = false; |
||
250 | /** |
||
251 | * Buffer class. |
||
252 | * @var Buffer |
||
253 | */ |
||
254 | protected $buffer = null; |
||
255 | /** |
||
256 | * Acceptable barcodes list |
||
257 | * @var array |
||
258 | */ |
||
259 | protected $barcode1Dlist = [ |
||
260 | 'UPC_A' => 65, |
||
261 | 'UPC_E' => 66, |
||
262 | 'EAN13' => 67, |
||
263 | 'EAN8' => 68, |
||
264 | 'CODE39' => 69, |
||
265 | 'I25' => 70, |
||
266 | 'CODABAR' => 71, |
||
267 | 'CODE93' => 72, |
||
268 | 'CODE128' => 73, |
||
269 | 'GS1128' => 74, |
||
270 | 'GS1DATABAROMINI' => 75, |
||
271 | 'GS1DATABARTRUNC' => 76, |
||
272 | 'GS1DATABARLIMIT' => 77, |
||
273 | 'GS1DATABAREXPAN' => 78 |
||
274 | ]; |
||
275 | /** |
||
276 | * List of supported models |
||
277 | * @var array |
||
278 | */ |
||
279 | protected $modelList = [ |
||
280 | 'T20' |
||
281 | ]; |
||
282 | /** |
||
283 | * Selected model |
||
284 | * @var string |
||
285 | */ |
||
286 | protected $printerModel = 'T20'; |
||
287 | |||
288 | /** |
||
289 | * Class constructor |
||
290 | * Instantiates the data buffer. |
||
291 | * |
||
292 | * @param ConnectorInterface $conn |
||
293 | */ |
||
294 | public function __construct(ConnectorInterface $conn = null) |
||
295 | { |
||
296 | if (!is_null($conn)) { |
||
297 | $this->connector = $conn; |
||
298 | } |
||
299 | $this->buffer = new Buffer(); |
||
300 | } |
||
301 | |||
302 | /** |
||
303 | * Return default printer model |
||
304 | * @param string $model |
||
305 | * @return string|array |
||
306 | */ |
||
307 | public function defaultModel($model = null) |
||
308 | { |
||
309 | if (!is_null($model)) { |
||
310 | $model = strtoupper(trim($model)); |
||
311 | if ($model == 'ALL') { |
||
312 | return $this->modelList; |
||
313 | } |
||
314 | } |
||
315 | if (array_key_exists($model, $this->modelList)) { |
||
316 | 27 | $this->printerModel = $model; |
|
317 | } |
||
318 | 27 | return $model; |
|
319 | } |
||
320 | |||
321 | 27 | /** |
|
322 | 27 | * Returns a default region for codepage |
|
323 | * if param $region is null will return actual default region from class |
||
324 | * if param $region is 'all' will return a array with all avaiable regions |
||
325 | * if param $region is a string will set the region parameter of class and returns it. |
||
326 | * NOTE: This command do not set the printer, only class parameters |
||
327 | * |
||
328 | * @param string $region |
||
329 | 20 | * @return string|array |
|
330 | */ |
||
331 | 20 | public function defaultRegionPage($region = null) |
|
332 | 20 | { |
|
333 | 20 | if (!is_null($region)) { |
|
334 | $region = strtoupper(trim($region)); |
||
335 | if ($region == 'ALL') { |
||
336 | 20 | return $this->aRegion; |
|
337 | 20 | } |
|
338 | $reg = array_search($region, $this->aRegion, true); |
||
339 | if ($reg !== false) { |
||
340 | 20 | $this->region = $region; |
|
341 | } |
||
342 | } |
||
343 | return $this->region; |
||
344 | } |
||
345 | |||
346 | /** |
||
347 | * Returns a default codepage |
||
348 | * if param $codepage is null will return actual default codepage from class |
||
349 | * if param $codepage is 'all' will return a array with all avaiable codepages |
||
350 | * if param $codepage is a string will set the codepage parameter of class and returns it. |
||
351 | * NOTE: This command do not set the printer, only class parameters |
||
352 | * |
||
353 | 21 | * @param string $codepage |
|
354 | * @return string|array |
||
355 | 21 | */ |
|
356 | 2 | public function defaultCodePage($codepage = null) |
|
357 | 2 | { |
|
358 | 1 | if (!is_null($codepage)) { |
|
359 | $codepage = strtoupper(trim($codepage)); |
||
360 | 2 | if ($codepage == 'ALL') { |
|
361 | 2 | return array_keys($this->aCodePage); |
|
362 | 2 | } |
|
363 | 2 | if (array_key_exists($codepage, $this->aCodePage)) { |
|
364 | 2 | $this->codepage = $codepage; |
|
365 | 21 | $table = $this->aCodePage[$codepage]; |
|
366 | $this->charsetTableNum = $table['table']; |
||
367 | } |
||
368 | } |
||
369 | return $this->codepage; |
||
370 | } |
||
371 | |||
372 | /** |
||
373 | * Returns the default printer font |
||
374 | * A - Font A (12 x 24) |
||
375 | * B - Font B (9 x 17) |
||
376 | * C - Font C |
||
377 | * D - Font D |
||
378 | 21 | * E - Font E |
|
379 | * Special A |
||
380 | 21 | * Special B |
|
381 | 3 | * Default Font A. |
|
382 | 3 | * if param $font is null will return actual default font from class |
|
383 | 1 | * if param $font is 'all' will return a array with all avaiable printer fonts |
|
384 | * if param $font is a string will set the font parameter of class and returns it. |
||
385 | 3 | * NOTE: This command do not set the printer, only class parameters |
|
386 | 3 | * |
|
387 | 3 | * @param string $font |
|
388 | 3 | * @return array|string |
|
389 | 3 | */ |
|
390 | 3 | public function defaultFont($font = null) |
|
391 | 21 | { |
|
392 | if (!is_null($font)) { |
||
393 | $font = strtoupper(trim($font)); |
||
394 | if ($font == 'ALL') { |
||
395 | //return array |
||
396 | return $this->aFont; |
||
397 | } |
||
398 | //set $this->font |
||
399 | $fonts = array_flip($this->aFont); |
||
400 | $keys = array_keys($fonts); |
||
401 | $reg = array_search($font, $keys, true); |
||
402 | if ($reg !== false) { |
||
403 | $this->font = $font; |
||
404 | } |
||
405 | } |
||
406 | return $this->font; |
||
407 | } |
||
408 | |||
409 | /** |
||
410 | * initialize printer |
||
411 | * Clears the data in the print buffer and resets the printer modes to |
||
412 | 22 | * the modes that were in effect when the power was turned on. |
|
413 | */ |
||
414 | 22 | public function initialize() |
|
415 | 3 | { |
|
416 | 3 | $this->rotateMode = false; |
|
417 | $this->boldMode = false; |
||
418 | 1 | $this->italicMode = false; |
|
419 | $this->underlineMode = false; |
||
420 | $this->printerMode = 'normal'; |
||
421 | 2 | $this->defaultModel(); |
|
422 | 2 | $this->defaultCodePage(); |
|
423 | 2 | $this->defaultRegionPage(); |
|
424 | 2 | $this->defaultFont(); |
|
425 | 2 | $this->buffer->write(self::ESC.'@'); |
|
426 | 2 | $this->setPrintMode(); |
|
427 | 2 | $this->setFont(); |
|
428 | 21 | $this->setCodePage(); |
|
429 | $this->setRegionPage(); |
||
430 | } |
||
431 | |||
432 | /** |
||
433 | * Set the printer mode. |
||
434 | */ |
||
435 | abstract public function setPrintMode($mode = null); |
||
436 | 21 | ||
437 | /** |
||
438 | 21 | * Set a codepage table in printer. |
|
439 | 21 | * |
|
440 | 21 | * @param string $codepage |
|
441 | 21 | */ |
|
442 | 21 | public function setCodePage($codepage = null) |
|
447 | 21 | ||
448 | 21 | /** |
|
449 | 21 | * Set a region page. |
|
450 | 21 | * The numeric key of array $this->aRegion is the command parameter. |
|
451 | 21 | * |
|
452 | 21 | * @param string $region |
|
453 | */ |
||
454 | public function setRegionPage($region = null) |
||
460 | |||
461 | /** |
||
462 | * Set a printer font |
||
463 | * If send a valid font name will set the printer otherelse a default font is selected |
||
464 | 20 | * |
|
465 | * @param string $font |
||
466 | 20 | */ |
|
467 | 20 | public function setFont($font = null) |
|
473 | |||
474 | /** |
||
475 | * Set emphasys mode on or off. |
||
476 | 20 | */ |
|
477 | public function setBold() |
||
486 | |||
487 | /** |
||
488 | * Set underline mode on or off. |
||
489 | 20 | */ |
|
490 | public function setUnderlined() |
||
499 | 1 | ||
500 | /** |
||
501 | 1 | * Set italic mode on or off |
|
502 | 1 | * |
|
503 | 1 | * @return bool |
|
504 | 1 | */ |
|
505 | 1 | public function setItalic() |
|
509 | |||
510 | /** |
||
511 | * Aligns all data in one line to the selected layout in standard mode. |
||
512 | 1 | * L - left C - center R - rigth |
|
513 | * |
||
514 | 1 | * @param string $align |
|
515 | 1 | */ |
|
516 | 1 | public function setAlign($align = null) |
|
534 | |||
535 | /** |
||
536 | * Turns white/black reverse print On or Off for characters. |
||
537 | * n = odd: On, n = even: Off. |
||
538 | 1 | */ |
|
539 | public function setReverseColors() |
||
548 | 1 | ||
549 | /** |
||
550 | * Set expanded mode. |
||
551 | 1 | * @param int $size multiplies normal size 1 - 8 |
|
552 | 1 | */ |
|
553 | 1 | public function setExpanded($size = null) |
|
569 | 1 | ||
570 | /** |
||
571 | * Set condensed mode. |
||
572 | * @return void |
||
573 | */ |
||
574 | public function setCondensed() |
||
579 | |||
580 | 1 | /** |
|
581 | 1 | * Set rotate 90 degrees. |
|
582 | 1 | * @return void |
|
583 | 1 | */ |
|
584 | 1 | public function setRotate90() |
|
593 | |||
594 | /** |
||
595 | * Send message or command to buffer |
||
596 | * when sending commands is not required to convert characters, |
||
597 | * so the variable may translate by false. |
||
598 | * @param string $text |
||
599 | */ |
||
600 | public function text($text = '') |
||
605 | 1 | ||
606 | /** |
||
607 | 1 | * Set horizontal and vertical motion units |
|
608 | 1 | * $horizontal => character spacing 1/x" |
|
609 | 1 | * $vertical => line spacing 1/y". |
|
610 | 1 | * @param int $horizontal |
|
611 | 1 | * @param int $vertical |
|
612 | 1 | */ |
|
613 | 1 | public function setSpacing($horizontal = 30, $vertical = 30) |
|
619 | |||
620 | /** |
||
621 | * Set right-side character spacing |
||
622 | 1 | * 0 ≤ n ≤ 255 => 1/x". |
|
623 | * @param int $value |
||
624 | 1 | */ |
|
625 | 1 | public function setCharSpacing($value = 3) |
|
630 | |||
631 | /** |
||
632 | * Line spacing |
||
633 | * The default is set to zero and 30/180 " |
||
634 | * any different number of zero will generate multiples of. |
||
635 | * n 1/180-inch vertical motion |
||
636 | 1 | * normal paragraph 30/180" => 4.23 mm |
|
637 | * @param int $value |
||
638 | 1 | */ |
|
639 | 1 | public function setParagraph($value = 0) |
|
654 | |||
655 | /** |
||
656 | * Prints data and feeds paper n lines |
||
657 | * ESC d n Prints data and feeds paper n lines. |
||
658 | * @param int|null $lines |
||
659 | */ |
||
660 | public function lineFeed($lines = 1) |
||
669 | 1 | ||
670 | 1 | /** |
|
671 | * Prints data and feeds paper n dots |
||
672 | 1 | * ESC J n Prints data and feeds paper n dots. |
|
673 | * @param int $dots |
||
674 | 1 | */ |
|
675 | public function dotFeed($dots = 1) |
||
680 | |||
681 | /** |
||
682 | * Generate a pulse, for opening a cash drawer if one is connected. |
||
683 | * The default settings should open an Epson drawer. |
||
684 | * @param int $pin 0 or 1, for pin 2 or pin 5 kick-out connector respectively. |
||
685 | * @param int $on_ms pulse ON time, in milliseconds. |
||
686 | 1 | * @param int $off_ms pulse OFF time, in milliseconds. |
|
687 | */ |
||
688 | 1 | public function pulse($pin = 0, $on_ms = 120, $off_ms = 240) |
|
695 | |||
696 | /** |
||
697 | * Cut the paper. |
||
698 | * @param int $mode FULL or PARTIAL. If not specified, FULL will be used. |
||
699 | * @param int $lines Number of lines to feed after cut |
||
700 | */ |
||
701 | public function cut($mode = 'PARTIAL', $lines = 3) |
||
711 | |||
712 | /** |
||
713 | * Implements barcodes 1D |
||
714 | * GS k m n d1...dn |
||
715 | * Prints bar code. n specifies the data length. |
||
716 | 1 | * m bar code system number of d (=k) |
|
717 | * "A" UPC-A 11 or 12 |
||
718 | 1 | * "B" UPC-E 6, 7, 8, 11 or 12 |
|
719 | 1 | * "C" JAN13 / EAN13 12 or 13 |
|
720 | 1 | * "D" JAN8 / EAN8 7 or 8 |
|
721 | 1 | * "E" CODE39 1 or more |
|
722 | 1 | * "F" ITF even |
|
723 | * "G" CODABAR (NW-7) 2 or more |
||
724 | * "H" CODE93 1–255 |
||
725 | * "I" CODE128 2–255 |
||
726 | * "J" GS1-128 2–255 |
||
727 | * "K" GS1 DataBar Omnidirectional 13 |
||
728 | * "L" GS1 DataBar Truncated 13 |
||
729 | * "M" GS1 DataBar Limited 13 |
||
730 | 1 | * "N" GS1 DataBar Expanded 2–255. |
|
731 | * |
||
732 | 1 | * GS h n Sets bar code height to n dots. |
|
733 | 1 | * GS w n Sets bar width of bar code. n = 2–6 (thin–thick) |
|
734 | 1 | * GS H n Selects print position of HRI characters. |
|
735 | 1 | * n = 0, "0": Not printed |
|
736 | 1 | * n = 1, "1": Above the bar code |
|
737 | * n = 2, "2": Below the bar code |
||
738 | 1 | * n = 3, "3": Both above and below the bar code |
|
739 | 1 | * GS f n Selects font for the HRI characters. |
|
740 | * n = 0, "0": Font A, |
||
741 | * n = 1, "1": Font B |
||
742 | * |
||
743 | * @param string $data |
||
744 | * @param string $type Default CODE128 |
||
745 | * @param int $height |
||
746 | * @param int $lineWidth |
||
747 | * @param string $txtPosition |
||
748 | * @param string $txtFont |
||
749 | */ |
||
750 | public function barcode( |
||
800 | 1 | ||
801 | 1 | /** |
|
802 | 1 | * Print PDF 417 2D barcode |
|
803 | * @param string $data |
||
804 | * @param integer $ecc |
||
805 | 1 | * @param integer $pheight |
|
806 | * @param integer $pwidth |
||
807 | * @param integer $colunms |
||
808 | 1 | * @return boolean |
|
809 | */ |
||
810 | public function barcodePDF417($data = '', $ecc = 5, $pheight = 2, $pwidth = 2, $colunms = 3) |
||
855 | |||
856 | /** |
||
857 | * Prints QRCode |
||
858 | * @param string $data barcode data |
||
859 | * @param string $level correction level L,M,Q ou H |
||
860 | * @param int $modelo QRCode model 1, 2 ou 0 Micro |
||
861 | * @param int $wmod width bar 3 ~ 16 |
||
862 | */ |
||
863 | public function barcodeQRCode($data = '', $level = 'L', $modelo = 2, $wmod = 4) |
||
901 | 1 | ||
902 | /** |
||
903 | 1 | * Return all data buffer. |
|
904 | * |
||
905 | 1 | * @param string $type specifies the return format |
|
906 | */ |
||
907 | 1 | public function getBuffer($type = '') |
|
942 | |||
943 | /** |
||
944 | 20 | * Send commands from buffer to connector printer. |
|
945 | * @param ConnectorInterface $conn |
||
946 | 20 | * @return string|void |
|
947 | 20 | */ |
|
948 | public function send(ConnectorInterface $conn = null) |
||
961 | |||
962 | /** |
||
963 | * Insert a image. |
||
964 | * |
||
965 | * @param string $filename Path to image file |
||
966 | * @param int $width |
||
967 | * @param int $height |
||
968 | * @param int $size 0-normal 1-Double Width 2-Double Heigth |
||
969 | * @throws RuntimeException |
||
970 | 20 | */ |
|
971 | public function putImage($filename = '', $width = null, $height = null, $size = 0) |
||
990 | |||
991 | /** |
||
992 | * Close and clean buffer |
||
993 | * All data will be lost. |
||
994 | */ |
||
995 | public function close() |
||
999 | 1 | ||
1000 | /** |
||
1001 | * Wrapper for GS ( L, to calculate and send correct data length. |
||
1002 | 1 | * |
|
1003 | 1 | * @param string $m Modifier/variant for function. Usually '0'. |
|
1004 | * @param string $fn Function number to use, as character. |
||
1005 | * @param string $data Data to send. |
||
1006 | */ |
||
1007 | protected function sendGraphicsData($m, $fn, $data = '') |
||
1012 | 1 | ||
1013 | 1 | /** |
|
1014 | 1 | * Generate two characters for a number: |
|
1015 | 1 | * In lower and higher parts, or more parts as needed. |
|
1016 | 1 | * |
|
1017 | 1 | * @param int $input Input number |
|
1018 | * @param int $length The number of bytes to output (1 - 4). |
||
1019 | */ |
||
1020 | protected static function intLowHigh($input, $length) |
||
1030 | |||
1031 | /** |
||
1032 | * Convert widths and heights to characters. |
||
1033 | * Used before sending graphics to set the size. |
||
1034 | * |
||
1035 | 1 | * @param array $inputs |
|
1036 | * @param bool $long True to use 4 bytes, false to use 2 |
||
1037 | 1 | * @return string |
|
1038 | 1 | */ |
|
1039 | 1 | protected static function dataHeader(array $inputs, $long = true) |
|
1052 | 1 | ||
1053 | 1 | /** |
|
1054 | 1 | * Verify if the argument given is not a boolean. |
|
1055 | 1 | * |
|
1056 | 1 | * @param bool $test the input to test |
|
1057 | * @param bool $default the default value |
||
1058 | * @return bool |
||
1059 | */ |
||
1060 | protected static function validateBoolean($test, $default) |
||
1067 | 1 | ||
1068 | /** |
||
1069 | 1 | * Verify if the argument given is not an integer within the specified range. |
|
1070 | 1 | * will return default instead |
|
1071 | 1 | * @param int|null $test the input to test |
|
1072 | 1 | * @param int $min the minimum allowable value (inclusive) |
|
1073 | 1 | * @param int $max the maximum allowable value (inclusive) |
|
1074 | * @param int $default the default value |
||
1075 | * @return int|null |
||
1076 | */ |
||
1077 | 1 | protected static function validateInteger($test, $min, $max, $default) |
|
1084 | |||
1085 | /** |
||
1086 | * Translate the text from UTF-8 for the specified codepage |
||
1087 | * this translation uses "iconv" and admits texts ONLY in UTF-8. |
||
1088 | * |
||
1089 | * @param string $text |
||
1090 | * @return string |
||
1091 | */ |
||
1092 | protected function translate($text = '') |
||
1103 | } |
||
1104 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.