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 |
||
| 34 | abstract class DefaultPrinter implements PrinterInterface |
||
| 35 | { |
||
| 36 | //set standards |
||
| 37 | const NUL = "\x0"; //Nulo |
||
| 38 | const EOT = "\x4"; //EOT fim da transmissão |
||
| 39 | const ENQ = "\x5"; //ENQ colocar na fila Pedido de status 1 |
||
| 40 | const HT = "\x9"; //tabulação horizontal |
||
| 41 | const VT = "\xb"; //tabulação vertical |
||
| 42 | const LF = "\x0a"; //Inicia a impressão e avança uma linha |
||
| 43 | const FF = "\x0c"; //avança pagina |
||
| 44 | const CR = "\x0d"; //retorno de carro |
||
| 45 | const DLE = "\x10"; //Data Link Escape |
||
| 46 | const CAN = "\x18"; //CAN Cancela linha enviada |
||
| 47 | const BEL = "\x07"; //BEL sinal sonoro |
||
| 48 | const ESC = "\x1b"; //escape |
||
| 49 | const FS = "\x1c"; //FS |
||
| 50 | const GS = "\x1d"; //GS |
||
| 51 | const SO = "\x0e"; //SO Inicia modo expandido |
||
| 52 | const DC1 = "\x11"; //DC1 Inicia modo enfatizado |
||
| 53 | const DC2 = "\x12"; //DC2 Cancela modo condensado |
||
| 54 | const DC3 = "\x13"; //DC3 Cancela modo enfatizado |
||
| 55 | const DC4 = "\x14"; //DC4 Controle de dispositivo 4 Inicia modo normal |
||
| 56 | const SI = "\x0f"; //Seleciona modo condensado |
||
| 57 | const EM = "\x19"; //Avança 4 linhas |
||
| 58 | const DEL = "\x7f"; //Cancela último caracter |
||
| 59 | const SYN = "\x16"; //Sincronismo |
||
| 60 | const NOTRANS = false; //not translate characters codepage |
||
| 61 | const TRANS = true; //perform a character convertion to codepage |
||
| 62 | |||
| 63 | //Cut types |
||
| 64 | const CUT_FULL = 65; |
||
| 65 | const CUT_PARTIAL = 66; |
||
| 66 | |||
| 67 | //Image sizing options |
||
| 68 | const IMG_DEFAULT = 0; |
||
| 69 | const IMG_DOUBLE_WIDTH = 1; |
||
| 70 | const IMG_DOUBLE_HEIGHT = 2; |
||
| 71 | |||
| 72 | /** |
||
| 73 | * List all available region pages. |
||
| 74 | * |
||
| 75 | * @var array |
||
| 76 | */ |
||
| 77 | protected $aRegion = array( |
||
| 78 | 'USA', |
||
| 79 | 'FRANCE', |
||
| 80 | 'GERMANY', |
||
| 81 | 'UK', |
||
| 82 | 'DENMARK', |
||
| 83 | 'SWEDEN', |
||
| 84 | 'ITALY', |
||
| 85 | 'SPAIN', |
||
| 86 | 'JAPAN', |
||
| 87 | 'NORWAY', |
||
| 88 | 'DENMARK2', |
||
| 89 | 'SPAIN2', |
||
| 90 | 'LATIN', |
||
| 91 | 'KOREA', |
||
| 92 | 'SLOVENIA', |
||
| 93 | 'CHINA', |
||
| 94 | 'VIETNAM', |
||
| 95 | 'ARABIA' |
||
| 96 | ); |
||
| 97 | |||
| 98 | /** |
||
| 99 | * List all available code pages. |
||
| 100 | * |
||
| 101 | * @var array |
||
| 102 | */ |
||
| 103 | protected $aCodePage = array( |
||
| 104 | 'CP437' => array('conv' => '437', 'table' => '0', 'desc' => 'PC437: USA, Standard Europe'), |
||
| 105 | 'CP850' => array('conv' => '850', 'table' => '2', 'desc' => 'PC850: Multilingual'), |
||
| 106 | 'CP860' => array('conv' => '860', 'table' => '3', 'desc' => 'PC860: Portuguese'), |
||
| 107 | 'CP863' => array('conv' => '863', 'table' => '4', 'desc' => 'PC863: Canadian-French'), |
||
| 108 | 'CP865' => array('conv' => '865', 'table' => '5', 'desc' => 'PC865: Nordic'), |
||
| 109 | 'CP851' => array('conv' => '851', 'table' => '11', 'desc' => 'PC851: Greek'), |
||
| 110 | 'CP853' => array('conv' => '853', 'table' => '12', 'desc' => 'PC853: Turkish'), |
||
| 111 | 'CP857' => array('conv' => '857', 'table' => '13', 'desc' => 'PC857: Turkish'), |
||
| 112 | 'CP737' => array('conv' => '737', 'table' => '14', 'desc' => 'PC737: Greek'), |
||
| 113 | 'ISO8859-7' => array('conv' => 'ISO8859-7', 'table' => '15', 'desc' => 'ISO8859-7: Greek'), |
||
| 114 | 'CP866' => array('conv' => '866', 'table' => '17', 'desc' => 'PC866: Cyrillic #2'), |
||
| 115 | 'CP852' => array('conv' => '852', 'table' => '18', 'desc' => 'PC852: Latin2'), |
||
| 116 | 'CP858' => array('conv' => '858', 'table' => '19', 'desc' => 'PC858: Euro'), |
||
| 117 | 'CP720' => array('conv' => '720', 'table' => '32', 'desc' => 'PC720: Arabic'), |
||
| 118 | 'CP855' => array('conv' => '855', 'table' => '34', 'desc' => 'PC855: Cyrillic'), |
||
| 119 | 'CP861' => array('conv' => '861', 'table' => '35', 'desc' => 'PC861: Icelandic'), |
||
| 120 | 'CP862' => array('conv' => '862', 'table' => '36', 'desc' => 'PC862: Hebrew'), |
||
| 121 | 'CP864' => array('conv' => '864', 'table' => '37', 'desc' => 'PC864: Arabic'), |
||
| 122 | 'CP869' => array('conv' => '869', 'table' => '38', 'desc' => 'PC869: Greek'), |
||
| 123 | 'ISO8859-2' => array('conv' => 'ISO8859-2', 'table' => '39', 'desc' => 'ISO8859-2: Latin2'), |
||
| 124 | 'ISO8859-15' => array('conv' => 'ISO8859-15', 'table' => '40', 'desc' => 'ISO8859-15: Latin9'), |
||
| 125 | 'WINDOWS-1250' => array('conv' => 'WINDOWS-1250', 'table' => '45', 'desc' => 'WPC1250: Latin2'), |
||
| 126 | 'WINDOWS-1251' => array('conv' => 'WINDOWS-1251', 'table' => '46', 'desc' => 'WPC1251: Cyrillic'), |
||
| 127 | 'WINDOWS-1252' => array('conv' => 'WINDOWS-1252', 'table' => '47', 'desc' => 'WPC1253: Greek'), |
||
| 128 | 'WINDOWS-1254' => array('conv' => 'WINDOWS-1254', 'table' => '48', 'desc' => 'WPC1254: Turkish'), |
||
| 129 | 'WINDOWS-1255' => array('conv' => 'WINDOWS-1255', 'table' => '49', 'desc' => 'WPC1255: Hebrew'), |
||
| 130 | 'WINDOWS-1256' => array('conv' => 'WINDOWS-1256', 'table' => '50', 'desc' => 'WPC1256: Arabic'), |
||
| 131 | 'WINDOWS-1257' => array('conv' => 'WINDOWS-1257', 'table' => '51', 'desc' => 'WPC1257: Baltic Rim'), |
||
| 132 | 'WINDOWS-1258' => array('conv' => 'WINDOWS-1258', 'table' => '52', 'desc' => 'WPC1258: Vietnamese'), |
||
| 133 | ); |
||
| 134 | |||
| 135 | /** |
||
| 136 | * Seleted code page |
||
| 137 | * Defined in printer class. |
||
| 138 | * |
||
| 139 | * @var string |
||
| 140 | */ |
||
| 141 | protected $codepage = 'CP437'; |
||
| 142 | /** |
||
| 143 | * Number of codpage in printer memory. |
||
| 144 | * |
||
| 145 | * @var int |
||
| 146 | */ |
||
| 147 | protected $charsetTableNum = 0; |
||
| 148 | /** |
||
| 149 | * Selected Region character page |
||
| 150 | * Defined in printer class. |
||
| 151 | * |
||
| 152 | * @var string |
||
| 153 | */ |
||
| 154 | protected $region = 'LATIN'; |
||
| 155 | /** |
||
| 156 | * List all avaiable fonts |
||
| 157 | * |
||
| 158 | * @var array |
||
| 159 | */ |
||
| 160 | protected $aFont = array(0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D', 4 => 'E', 97 => 'SA', 98 => 'SB'); |
||
| 161 | /** |
||
| 162 | * Selected internal font. |
||
| 163 | * |
||
| 164 | * @var string |
||
| 165 | */ |
||
| 166 | protected $font = 'A'; |
||
| 167 | /** |
||
| 168 | * Resolution in dpi. |
||
| 169 | * |
||
| 170 | * @var int |
||
| 171 | */ |
||
| 172 | public $dpi = 203; //dots per inch |
||
| 173 | /** |
||
| 174 | * Resolution in dpmm. |
||
| 175 | * |
||
| 176 | * @var int |
||
| 177 | */ |
||
| 178 | public $dpmm = 8; //dots per mm |
||
| 179 | /** |
||
| 180 | * Maximum width paper. |
||
| 181 | * |
||
| 182 | * @var int |
||
| 183 | */ |
||
| 184 | public $widthMaxmm = 80;//mm |
||
| 185 | /** |
||
| 186 | * Selected Width paper. |
||
| 187 | * |
||
| 188 | * @var int |
||
| 189 | */ |
||
| 190 | public $widthPaper = 80;//mm |
||
| 191 | /** |
||
| 192 | * Maximum width for printed area. |
||
| 193 | * |
||
| 194 | * @var int |
||
| 195 | */ |
||
| 196 | public $widthPrint = 72;//mm |
||
| 197 | /** |
||
| 198 | * Maximum width for printed area in dots. |
||
| 199 | * |
||
| 200 | * @var int |
||
| 201 | */ |
||
| 202 | public $widthMaxdots = 576;//dots |
||
| 203 | /** |
||
| 204 | * Maximum number of characters per line. |
||
| 205 | * |
||
| 206 | * @var int |
||
| 207 | */ |
||
| 208 | public $maxchars = 48;//max characters per line |
||
| 209 | |||
| 210 | //protected property standards |
||
| 211 | /** |
||
| 212 | * Connector to printer. |
||
| 213 | * |
||
| 214 | * @var ConnectosInterface |
||
| 215 | */ |
||
| 216 | protected $connector = null; |
||
| 217 | /** |
||
| 218 | * Seleted printer mode. |
||
| 219 | * |
||
| 220 | * @var string |
||
| 221 | */ |
||
| 222 | protected $printerMode = 'normal'; |
||
| 223 | /** |
||
| 224 | * Selected bold mode. |
||
| 225 | * |
||
| 226 | * @var bool |
||
| 227 | */ |
||
| 228 | protected $boldMode = false; |
||
| 229 | /** |
||
| 230 | * Selected italic mode. |
||
| 231 | * |
||
| 232 | * @var bool |
||
| 233 | */ |
||
| 234 | protected $italicMode = false; |
||
| 235 | /** |
||
| 236 | * Selected condenced mode. |
||
| 237 | * |
||
| 238 | * @var bool |
||
| 239 | */ |
||
| 240 | protected $condensedMode = false; |
||
| 241 | /** |
||
| 242 | * Selected expanded mode. |
||
| 243 | * @var bool |
||
| 244 | */ |
||
| 245 | protected $expandedMode = false; |
||
| 246 | /** |
||
| 247 | * Seleted double higth mode. |
||
| 248 | * @var bool |
||
| 249 | */ |
||
| 250 | protected $doubleHeigth = false; |
||
| 251 | /** |
||
| 252 | * Selected reverse colors mode. |
||
| 253 | * |
||
| 254 | * @var bool |
||
| 255 | */ |
||
| 256 | protected $reverseColors = false; |
||
| 257 | /** |
||
| 258 | * Selected under lined mode. |
||
| 259 | * |
||
| 260 | * @var bool |
||
| 261 | */ |
||
| 262 | protected $underlineMode = false; |
||
| 263 | /** |
||
| 264 | * Selected rotate 90 degrees mode |
||
| 265 | * |
||
| 266 | * @var bool |
||
| 267 | */ |
||
| 268 | protected $rotateMode = false; |
||
| 269 | /** |
||
| 270 | * Buffer class. |
||
| 271 | * |
||
| 272 | * @var Connectors\Buffer |
||
| 273 | */ |
||
| 274 | protected $buffer = null; |
||
| 275 | 27 | /** |
|
| 276 | * Acceptable barcodes list |
||
| 277 | 27 | * @var array |
|
| 278 | */ |
||
| 279 | protected $barcode1Dlist = [ |
||
| 280 | 27 | 'UPC_A' => 65, |
|
| 281 | 27 | 'UPC_E' => 66, |
|
| 282 | 'EAN13' => 67, |
||
| 283 | 'EAN8' => 68, |
||
| 284 | 'CODE39' => 69, |
||
| 285 | 'I25' => 70, |
||
| 286 | 'CODABAR' => 71, |
||
| 287 | 'CODE93' => 72, |
||
| 288 | 'CODE128' => 73, |
||
| 289 | 'GS1128' => 74, |
||
| 290 | 'GS1DATABAROMINI' => 75, |
||
| 291 | 'GS1DATABARTRUNC' => 76, |
||
| 292 | 'GS1DATABARLIMIT' => 77, |
||
| 293 | 2 | 'GS1DATABAREXPAN' => 78 |
|
| 294 | ]; |
||
| 295 | 2 | /** |
|
| 296 | 2 | * List of supported models |
|
| 297 | 2 | * @var array |
|
| 298 | 1 | */ |
|
| 299 | protected $modelList = [ |
||
| 300 | 2 | 'T20' |
|
| 301 | 2 | ]; |
|
| 302 | 2 | /** |
|
| 303 | 2 | * Selected model |
|
| 304 | 2 | * @var string |
|
| 305 | 2 | */ |
|
| 306 | protected $printerModel = 'T20'; |
||
| 307 | |||
| 308 | /** |
||
| 309 | * Class constructor |
||
| 310 | * Instantiates the data buffer. |
||
| 311 | * |
||
| 312 | * @param ConnectorInterface $conn |
||
| 313 | */ |
||
| 314 | public function __construct(ConnectorInterface $conn = null) |
||
| 321 | 21 | ||
| 322 | 21 | /** |
|
| 323 | 1 | * Return default printer model |
|
| 324 | * @param string $model |
||
| 325 | 21 | * @return string|array |
|
| 326 | 3 | */ |
|
| 327 | 3 | public function defaultModel($model = 'T20') |
|
| 340 | |||
| 341 | 2 | /** |
|
| 342 | 2 | * Returns a default region for codepage |
|
| 343 | 2 | * if param $region is null will return actual default region from class |
|
| 344 | * if param $region is 'all' will return a array with all avaiable regions |
||
| 345 | * if param $region is a string will set the region parameter of class and returns it. |
||
| 346 | * NOTE: This command do not set the printer, only class parameters |
||
| 347 | * |
||
| 348 | * @param string $region |
||
| 349 | * @return string|array |
||
| 350 | */ |
||
| 351 | 1 | public function defaultRegionPage($region = null) |
|
| 365 | |||
| 366 | /** |
||
| 367 | * Returns a default codepage |
||
| 368 | * if param $codepage is null will return actual default codepage from class |
||
| 369 | * if param $codepage is 'all' will return a array with all avaiable codepages |
||
| 370 | * if param $codepage is a string will set the codepage parameter of class and returns it. |
||
| 371 | * NOTE: This command do not set the printer, only class parameters |
||
| 372 | * |
||
| 373 | * @param string $codepage |
||
| 374 | * @return string|array |
||
| 375 | */ |
||
| 376 | 3 | public function defaultCodePage($codepage = null) |
|
| 391 | 2 | ||
| 392 | 2 | /** |
|
| 393 | * Returns the default printer font |
||
| 394 | * A - Font A (12 x 24) |
||
| 395 | * B - Font B (9 x 17) |
||
| 396 | * C - Font C |
||
| 397 | * D - Font D |
||
| 398 | * E - Font E |
||
| 399 | * Special A |
||
| 400 | * Special B |
||
| 401 | 1 | * Default Font A. |
|
| 402 | * if param $font is null will return actual default font from class |
||
| 403 | 1 | * if param $font is 'all' will return a array with all avaiable printer fonts |
|
| 404 | 1 | * if param $font is a string will set the font parameter of class and returns it. |
|
| 405 | 1 | * NOTE: This command do not set the printer, only class parameters |
|
| 406 | 1 | * |
|
| 407 | * @param string $font |
||
| 408 | * @return array|string |
||
| 409 | */ |
||
| 410 | public function defaultFont($font = null) |
||
| 428 | 1 | ||
| 429 | 1 | /** |
|
| 430 | 1 | * initialize printer |
|
| 431 | 1 | * Clears the data in the print buffer and resets the printer modes to |
|
| 432 | 1 | * the modes that were in effect when the power was turned on. |
|
| 433 | 1 | */ |
|
| 434 | public function initialize() |
||
| 451 | |||
| 452 | /** |
||
| 453 | * Set the printer mode. |
||
| 454 | 1 | */ |
|
| 455 | abstract public function setPrintMode($mode = null); |
||
| 456 | 1 | ||
| 457 | /** |
||
| 458 | * Set a codepage table in printer. |
||
| 459 | 1 | * |
|
| 460 | * @param string $codepage |
||
| 461 | 1 | */ |
|
| 462 | 1 | public function setCodePage($codepage = null) |
|
| 467 | 1 | ||
| 468 | 1 | /** |
|
| 469 | 1 | * Set a region page. |
|
| 470 | 1 | * The numeric key of array $this->aRegion is the command parameter. |
|
| 471 | 1 | * |
|
| 472 | * @param string $region |
||
| 473 | */ |
||
| 474 | public function setRegionPage($region = null) |
||
| 480 | 1 | ||
| 481 | 1 | /** |
|
| 482 | 1 | * Set a printer font |
|
| 483 | 1 | * If send a valid font name will set the printer otherelse a default font is selected |
|
| 484 | 1 | * |
|
| 485 | * @param string $font |
||
| 486 | 1 | */ |
|
| 487 | 1 | public function setFont($font = null) |
|
| 493 | |||
| 494 | 1 | /** |
|
| 495 | * Set emphasys mode on or off. |
||
| 496 | 1 | */ |
|
| 497 | public function setBold() |
||
| 506 | 1 | ||
| 507 | 1 | /** |
|
| 508 | 1 | * Set underline mode on or off. |
|
| 509 | 1 | */ |
|
| 510 | public function setUnderlined() |
||
| 519 | |||
| 520 | /** |
||
| 521 | * Set italic mode on or off |
||
| 522 | * |
||
| 523 | * @return bool |
||
| 524 | */ |
||
| 525 | public function setItalic() |
||
| 529 | 1 | ||
| 530 | /** |
||
| 531 | 1 | * Aligns all data in one line to the selected layout in standard mode. |
|
| 532 | 1 | * L - left C - center R - rigth |
|
| 533 | 1 | * |
|
| 534 | 1 | * @param string $align |
|
| 535 | 1 | */ |
|
| 536 | 1 | public function setAlign($align = null) |
|
| 554 | 21 | ||
| 555 | 21 | /** |
|
| 556 | * Turns white/black reverse print On or Off for characters. |
||
| 557 | * n = odd: On, n = even: Off. |
||
| 558 | */ |
||
| 559 | public function setReverseColors() |
||
| 568 | 1 | ||
| 569 | /** |
||
| 570 | * Set expanded mode. |
||
| 571 | * |
||
| 572 | * @param int $size multiplies normal size 1 - 8 |
||
| 573 | */ |
||
| 574 | public function setExpanded($size = null) |
||
| 590 | |||
| 591 | 1 | /** |
|
| 592 | * Set condensed mode. |
||
| 593 | 1 | */ |
|
| 594 | 1 | public function setCondensed() |
|
| 599 | |||
| 600 | /** |
||
| 601 | * Set rotate 90 degrees. |
||
| 602 | */ |
||
| 603 | public function setRotate90() |
||
| 612 | 1 | ||
| 613 | /** |
||
| 614 | 1 | * Send message or command to buffer |
|
| 615 | * when sending commands is not required to convert characters, |
||
| 616 | 1 | * so the variable may translate by false. |
|
| 617 | * |
||
| 618 | * @param string $text |
||
| 619 | 1 | */ |
|
| 620 | 1 | public function text($text = '') |
|
| 625 | |||
| 626 | /** |
||
| 627 | * Set horizontal and vertical motion units |
||
| 628 | 1 | * $horizontal => character spacing 1/x" |
|
| 629 | * $vertical => line spacing 1/y". |
||
| 630 | 1 | * |
|
| 631 | 1 | * @param int $horizontal |
|
| 632 | 1 | * @param int $vertical |
|
| 633 | 1 | */ |
|
| 634 | public function setSpacing($horizontal = 30, $vertical = 30) |
||
| 640 | |||
| 641 | /** |
||
| 642 | * Set right-side character spacing |
||
| 643 | * 0 ≤ n ≤ 255 => 1/x". |
||
| 644 | 1 | * |
|
| 645 | * @param int $value |
||
| 646 | 1 | */ |
|
| 647 | 1 | public function setCharSpacing($value = 3) |
|
| 652 | |||
| 653 | /** |
||
| 654 | * Line spacing |
||
| 655 | * The default is set to zero and 30/180 " |
||
| 656 | * any different number of zero will generate multiples of. |
||
| 657 | * n 1/180-inch vertical motion |
||
| 658 | 1 | * normal paragraph 30/180" => 4.23 mm |
|
| 659 | * |
||
| 660 | 1 | * @param int $paragraph |
|
| 661 | 1 | */ |
|
| 662 | 1 | public function setParagraph($value = 0) |
|
| 677 | 1 | ||
| 678 | 1 | /** |
|
| 679 | * Prints data and feeds paper n lines |
||
| 680 | 1 | * ESC d n Prints data and feeds paper n lines. |
|
| 681 | 1 | * |
|
| 682 | * @param integer $lines |
||
| 683 | */ |
||
| 684 | public function lineFeed($lines = 1) |
||
| 693 | |||
| 694 | /** |
||
| 695 | * Prints data and feeds paper n dots |
||
| 696 | * ESC J n Prints data and feeds paper n dots. |
||
| 697 | * |
||
| 698 | * @param int $dots |
||
| 699 | */ |
||
| 700 | public function dotFeed($dots = 1) |
||
| 705 | |||
| 706 | /** |
||
| 707 | * Generate a pulse, for opening a cash drawer if one is connected. |
||
| 708 | * The default settings should open an Epson drawer. |
||
| 709 | * |
||
| 710 | * @param int $pin 0 or 1, for pin 2 or pin 5 kick-out connector respectively. |
||
| 711 | * @param int $on_ms pulse ON time, in milliseconds. |
||
| 712 | * @param int $off_ms pulse OFF time, in milliseconds. |
||
| 713 | */ |
||
| 714 | public function pulse($pin = 0, $on_ms = 120, $off_ms = 240) |
||
| 721 | 1 | ||
| 722 | /** |
||
| 723 | * Cut the paper. |
||
| 724 | * |
||
| 725 | * @param int $mode FULL or PARTIAL. If not specified, FULL will be used. |
||
| 726 | * @param int $lines Number of lines to feed after cut |
||
| 727 | */ |
||
| 728 | public function cut($mode = 'PARTIAL', $lines = 3) |
||
| 738 | |||
| 739 | 1 | /** |
|
| 740 | * Implements barcodes 1D |
||
| 741 | 1 | * GS k m n d1...dn |
|
| 742 | 1 | * Prints bar code. n specifies the data length. |
|
| 743 | 1 | * m bar code system number of d (=k) |
|
| 744 | 1 | * "A" UPC-A 11 or 12 |
|
| 745 | * "B" UPC-E 6, 7, 8, 11 or 12 |
||
| 746 | * "C" JAN13 / EAN13 12 or 13 |
||
| 747 | 1 | * "D" JAN8 / EAN8 7 or 8 |
|
| 748 | 1 | * "E" CODE39 1 or more |
|
| 749 | * "F" ITF even |
||
| 750 | * "G" CODABAR (NW-7) 2 or more |
||
| 751 | 1 | * "H" CODE93 1–255 |
|
| 752 | 1 | * "I" CODE128 2–255 |
|
| 753 | 1 | * "J" GS1-128 2–255 |
|
| 754 | * "K" GS1 DataBar Omnidirectional 13 |
||
| 755 | 1 | * "L" GS1 DataBar Truncated 13 |
|
| 756 | * "M" GS1 DataBar Limited 13 |
||
| 757 | 1 | * "N" GS1 DataBar Expanded 2–255. |
|
| 758 | * |
||
| 759 | 1 | * GS h n Sets bar code height to n dots. |
|
| 760 | * GS w n Sets bar width of bar code. n = 2–6 (thin–thick) |
||
| 761 | 1 | * GS H n Selects print position of HRI characters. |
|
| 762 | * n = 0, "0": Not printed |
||
| 763 | 1 | * n = 1, "1": Above the bar code |
|
| 764 | 1 | * n = 2, "2": Below the bar code |
|
| 765 | * n = 3, "3": Both above and below the bar code |
||
| 766 | * GS f n Selects font for the HRI characters. |
||
| 767 | * n = 0, "0": Font A, |
||
| 768 | * n = 1, "1": Font B |
||
| 769 | * |
||
| 770 | * @param string $data |
||
| 771 | * @param int $type Default CODE128 |
||
| 772 | * @param int $height |
||
| 773 | * @param int $lineWidth |
||
| 774 | 1 | * @param string $txtPosition |
|
| 775 | * @param string $txtFont |
||
| 776 | */ |
||
| 777 | 1 | public function barcode( |
|
| 827 | 20 | ||
| 828 | /** |
||
| 829 | * Imprime o QR Code |
||
| 830 | 20 | * |
|
| 831 | * @param string $data Dados a serem inseridos no QRCode |
||
| 832 | * @param string $level Nivel de correção L,M,Q ou H |
||
| 833 | * @param int $modelo modelo de QRCode 1, 2 ou 0 Micro |
||
| 834 | 20 | * @param int $wmod largura da barra 3 ~ 16 |
|
| 835 | */ |
||
| 836 | 20 | public function barcodeQRCode($data = '', $level = 'L', $modelo = 2, $wmod = 4) |
|
| 874 | |||
| 875 | /** |
||
| 876 | * Return all data buffer. |
||
| 877 | * |
||
| 878 | * @param string $type specifies the return format |
||
| 879 | */ |
||
| 880 | public function getBuffer($type = '') |
||
| 915 | |||
| 916 | /** |
||
| 917 | * Send commands from buffer to connector printer. |
||
| 918 | 1 | */ |
|
| 919 | public function send(ConnectorInterface $conn = null) |
||
| 932 | |||
| 933 | 1 | /** |
|
| 934 | 1 | * Insert a image. |
|
| 935 | * |
||
| 936 | * @param string $filename Path to image file |
||
| 937 | * @param float $width |
||
| 938 | * @param float $height |
||
| 939 | 1 | * @param int $size 0-normal 1-Double Width 2-Double Heigth |
|
| 940 | 1 | * @throws RuntimeException |
|
| 941 | 1 | */ |
|
| 942 | 1 | public function putImage($filename = '', $width = null, $height = null, $size = 0) |
|
| 961 | 1 | ||
| 962 | /** |
||
| 963 | * Close and clean buffer |
||
| 964 | * All data will be lost. |
||
| 965 | */ |
||
| 966 | public function close() |
||
| 970 | 1 | ||
| 971 | /** |
||
| 972 | 1 | * Wrapper for GS ( L, to calculate and send correct data length. |
|
| 973 | 1 | * |
|
| 974 | 1 | * @param string $m Modifier/variant for function. Usually '0'. |
|
| 975 | 1 | * @param string $fn Function number to use, as character. |
|
| 976 | 1 | * @param string $data Data to send. |
|
| 977 | 1 | */ |
|
| 978 | 1 | protected function sendGraphicsData($m, $fn, $data = '') |
|
| 983 | |||
| 984 | /** |
||
| 985 | * Generate two characters for a number: |
||
| 986 | * In lower and higher parts, or more parts as needed. |
||
| 987 | * |
||
| 988 | * @param int $int Input number |
||
| 989 | 1 | * @param int $length The number of bytes to output (1 - 4). |
|
| 990 | */ |
||
| 991 | 1 | protected static function intLowHigh($input, $length) |
|
| 1001 | |||
| 1002 | /** |
||
| 1003 | * Convert widths and heights to characters. |
||
| 1004 | * Used before sending graphics to set the size. |
||
| 1005 | * |
||
| 1006 | * @param array $inputs |
||
| 1007 | * @param bool $long True to use 4 bytes, false to use 2 |
||
| 1008 | * @return string |
||
| 1009 | */ |
||
| 1010 | protected static function dataHeader(array $inputs, $long = true) |
||
| 1023 | |||
| 1024 | /** |
||
| 1025 | * Verify if the argument given is not a boolean. |
||
| 1026 | * |
||
| 1027 | * @param bool $test the input to test |
||
| 1028 | 10 | * @param bool $default the default value |
|
| 1029 | * @return bool |
||
| 1030 | 10 | */ |
|
| 1031 | 1 | protected static function validateBoolean($test, $default) |
|
| 1038 | |||
| 1039 | /** |
||
| 1040 | * Verify if the argument given is not an integer within the specified range. |
||
| 1041 | * will return default instead |
||
| 1042 | * |
||
| 1043 | * @param int $test the input to test |
||
| 1044 | * @param int $min the minimum allowable value (inclusive) |
||
| 1045 | * @param int $max the maximum allowable value (inclusive) |
||
| 1046 | * @param int $default the default value |
||
| 1047 | * @return int |
||
| 1048 | */ |
||
| 1049 | protected static function validateInteger($test, $min, $max, $default) |
||
| 1056 | |||
| 1057 | /** |
||
| 1058 | 1 | * Verify if the argument given can't be cast to a string. |
|
| 1059 | * |
||
| 1060 | 1 | * @param string $test the input to test |
|
| 1061 | 1 | * @param string $default the default value |
|
| 1062 | 1 | * @return string |
|
| 1063 | 1 | */ |
|
| 1064 | 1 | protected static function validateString($test, $default) |
|
| 1071 | |||
| 1072 | /** |
||
| 1073 | * Translate the text from UTF-8 for the specified codepage |
||
| 1074 | * this translation uses "iconv" and admits texts ONLY in UTF-8. |
||
| 1075 | * |
||
| 1076 | * @param string $text |
||
| 1077 | * @return string |
||
| 1078 | */ |
||
| 1079 | protected function translate($text = '') |
||
| 1090 | } |
||
| 1091 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..