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  | 
            ||
| 33 | abstract class DefaultPrinter implements PrinterInterface  | 
            ||
| 34 | { | 
            ||
| 35 | //set standards  | 
            ||
| 36 | const NUL = "\x0"; //Nulo  | 
            ||
| 37 | const EOT = "\x4"; //EOT fim da transmissão  | 
            ||
| 38 | const ENQ = "\x5"; //ENQ colocar na fila Pedido de status 1  | 
            ||
| 39 | const HT = "\x9"; //tabulação horizontal  | 
            ||
| 40 | const VT = "\xb"; //tabulação vertical  | 
            ||
| 41 | const LF = "\x0a"; //Inicia a impressão e avança uma linha  | 
            ||
| 42 | const FF = "\x0c"; //avança pagina  | 
            ||
| 43 | const CR = "\x0d"; //retorno de carro  | 
            ||
| 44 | const DLE = "\x10"; //Data Link Escape  | 
            ||
| 45 | const CAN = "\x18"; //CAN Cancela linha enviada  | 
            ||
| 46 | const BEL = "\x07"; //BEL sinal sonoro  | 
            ||
| 47 | const ESC = "\x1b"; //escape  | 
            ||
| 48 | const FS = "\x1c"; //FS  | 
            ||
| 49 | const GS = "\x1d"; //GS  | 
            ||
| 50 | const SO = "\x0e"; //SO Inicia modo expandido  | 
            ||
| 51 | const DC1 = "\x11"; //DC1 Inicia modo enfatizado  | 
            ||
| 52 | const DC2 = "\x12"; //DC2 Cancela modo condensado  | 
            ||
| 53 | const DC3 = "\x13"; //DC3 Cancela modo enfatizado  | 
            ||
| 54 | const DC4 = "\x14"; //DC4 Controle de dispositivo 4 Inicia modo normal  | 
            ||
| 55 | const SI = "\x0f"; //Seleciona modo condensado  | 
            ||
| 56 | const EM = "\x19"; //Avança 4 linhas  | 
            ||
| 57 | const DEL = "\x7f"; //Cancela último caracter  | 
            ||
| 58 | const SYN = "\x16"; //Sincronismo  | 
            ||
| 59 | const NOTRANS = false; //not translate characters codepage  | 
            ||
| 60 | const TRANS = true; //perform a character convertion to codepage  | 
            ||
| 61 | |||
| 62 | // Cut types  | 
            ||
| 63 | const CUT_FULL = 65;  | 
            ||
| 64 | const CUT_PARTIAL = 66;  | 
            ||
| 65 | |||
| 66 | //1D barcode types  | 
            ||
| 67 | const UPC_A = 'A';  | 
            ||
| 68 | const UPC_E = 'B';  | 
            ||
| 69 | const EAN13 = 'C';  | 
            ||
| 70 | const EAN8 = 'D';  | 
            ||
| 71 | const CODE39 = 'E';  | 
            ||
| 72 | const ITF = 'F';  | 
            ||
| 73 | const CODABAR = 'G';  | 
            ||
| 74 | const CODE93 = 'H';  | 
            ||
| 75 | const CODE128 = 'I';  | 
            ||
| 76 | const GS1_128 = 'J';  | 
            ||
| 77 | const GS1_DataBar_Omnidirectional = 'K';  | 
            ||
| 78 | const GS1_DataBar_Truncated = 'L';  | 
            ||
| 79 | const GS1_DataBar_Limited = 'M';  | 
            ||
| 80 | const GS1_DataBar_Expanded = 'N';  | 
            ||
| 81 | |||
| 82 | /**  | 
            ||
| 83 | * List all available region pages.  | 
            ||
| 84 | *  | 
            ||
| 85 | * @var array  | 
            ||
| 86 | */  | 
            ||
| 87 | protected $aRegion = array(  | 
            ||
| 88 | 'USA',  | 
            ||
| 89 | 'FRANCE',  | 
            ||
| 90 | 'GERMANY',  | 
            ||
| 91 | 'UK',  | 
            ||
| 92 | 'DENMARK',  | 
            ||
| 93 | 'SWEDEN',  | 
            ||
| 94 | 'ITALY',  | 
            ||
| 95 | 'SPAIN',  | 
            ||
| 96 | 'JAPAN',  | 
            ||
| 97 | 'NORWAY',  | 
            ||
| 98 | 'DENMARK2',  | 
            ||
| 99 | 'SPAIN2',  | 
            ||
| 100 | 'LATIN',  | 
            ||
| 101 | 'KOREA',  | 
            ||
| 102 | 'SLOVENIA',  | 
            ||
| 103 | 'CHINA',  | 
            ||
| 104 | 'VIETNAM',  | 
            ||
| 105 | 'ARABIA',  | 
            ||
| 106 | );  | 
            ||
| 107 | |||
| 108 | /**  | 
            ||
| 109 | * List all available code pages.  | 
            ||
| 110 | *  | 
            ||
| 111 | * @var array  | 
            ||
| 112 | */  | 
            ||
| 113 | protected $aCodePage = array(  | 
            ||
| 114 |         'CP437' => array('conv' => '437', 'table' => '0', 'desc' => 'PC437: USA, Standard Europe'), | 
            ||
| 115 |         'CP850' => array('conv' => '850', 'table' => '2', 'desc' => 'PC850: Multilingual'), | 
            ||
| 116 |         'CP860' => array('conv' => '860', 'table' => '3', 'desc' => 'PC860: Portuguese'), | 
            ||
| 117 |         'CP863' => array('conv' => '863', 'table' => '4', 'desc' => 'PC863: Canadian-French'), | 
            ||
| 118 |         'CP865' => array('conv' => '865', 'table' => '5', 'desc' => 'PC865: Nordic'), | 
            ||
| 119 |         'CP851' => array('conv' => '851', 'table' => '11', 'desc' => 'PC851: Greek'), | 
            ||
| 120 |         'CP853' => array('conv' => '853', 'table' => '12', 'desc' => 'PC853: Turkish'), | 
            ||
| 121 |         'CP857' => array('conv' => '857', 'table' => '13', 'desc' => 'PC857: Turkish'), | 
            ||
| 122 |         'CP737' => array('conv' => '737', 'table' => '14', 'desc' => 'PC737: Greek'), | 
            ||
| 123 |         'ISO8859-7' => array('conv' => 'ISO8859-7', 'table' => '15', 'desc' => 'ISO8859-7: Greek'), | 
            ||
| 124 |         'CP866' => array('conv' => '866', 'table' => '17', 'desc' => 'PC866: Cyrillic #2'), | 
            ||
| 125 |         'CP852' => array('conv' => '852', 'table' => '18', 'desc' => 'PC852: Latin2'), | 
            ||
| 126 |         'CP858' => array('conv' => '858', 'table' => '19', 'desc' => 'PC858: Euro'), | 
            ||
| 127 |         'CP720' => array('conv' => '720', 'table' => '32', 'desc' => 'PC720: Arabic'), | 
            ||
| 128 |         'CP855' => array('conv' => '855', 'table' => '34', 'desc' => 'PC855: Cyrillic'), | 
            ||
| 129 |         'CP861' => array('conv' => '861', 'table' => '35', 'desc' => 'PC861: Icelandic'), | 
            ||
| 130 |         'CP862' => array('conv' => '862', 'table' => '36', 'desc' => 'PC862: Hebrew'), | 
            ||
| 131 |         'CP864' => array('conv' => '864', 'table' => '37', 'desc' => 'PC864: Arabic'), | 
            ||
| 132 |         'CP869' => array('conv' => '869', 'table' => '38', 'desc' => 'PC869: Greek'), | 
            ||
| 133 |         'ISO8859-2' => array('conv' => 'ISO8859-2', 'table' => '39', 'desc' => 'ISO8859-2: Latin2'), | 
            ||
| 134 |         'ISO8859-15' => array('conv' => 'ISO8859-15', 'table' => '40', 'desc' => 'ISO8859-15: Latin9'), | 
            ||
| 135 |         'WINDOWS-1250' => array('conv' => 'WINDOWS-1250', 'table' => '45', 'desc' => 'WPC1250: Latin2'), | 
            ||
| 136 |         'WINDOWS-1251' => array('conv' => 'WINDOWS-1251', 'table' => '46', 'desc' => 'WPC1251: Cyrillic'), | 
            ||
| 137 |         'WINDOWS-1252' => array('conv' => 'WINDOWS-1252', 'table' => '47', 'desc' => 'WPC1253: Greek'), | 
            ||
| 138 |         'WINDOWS-1254' => array('conv' => 'WINDOWS-1254', 'table' => '48', 'desc' => 'WPC1254: Turkish'), | 
            ||
| 139 |         'WINDOWS-1255' => array('conv' => 'WINDOWS-1255', 'table' => '49', 'desc' => 'WPC1255: Hebrew'), | 
            ||
| 140 |         'WINDOWS-1256' => array('conv' => 'WINDOWS-1256', 'table' => '50', 'desc' => 'WPC1256: Arabic'), | 
            ||
| 141 |         'WINDOWS-1257' => array('conv' => 'WINDOWS-1257', 'table' => '51', 'desc' => 'WPC1257: Baltic Rim'), | 
            ||
| 142 |         'WINDOWS-1258' => array('conv' => 'WINDOWS-1258', 'table' => '52', 'desc' => 'WPC1258: Vietnamese'), | 
            ||
| 143 | );  | 
            ||
| 144 | /**  | 
            ||
| 145 | * Seleted code page  | 
            ||
| 146 | * Defined in printer class.  | 
            ||
| 147 | *  | 
            ||
| 148 | * @var string  | 
            ||
| 149 | */  | 
            ||
| 150 | protected $codepage = 'CP437';  | 
            ||
| 151 | /**  | 
            ||
| 152 | * Number of codpage in printer memory.  | 
            ||
| 153 | *  | 
            ||
| 154 | * @var int  | 
            ||
| 155 | */  | 
            ||
| 156 | protected $charsetTableNum = 0;  | 
            ||
| 157 | /**  | 
            ||
| 158 | * Selected Region character page  | 
            ||
| 159 | * Defined in printer class.  | 
            ||
| 160 | *  | 
            ||
| 161 | * @var string  | 
            ||
| 162 | */  | 
            ||
| 163 | protected $region = 'LATIN';  | 
            ||
| 164 | /**  | 
            ||
| 165 | * List all avaiable fonts  | 
            ||
| 166 | * @var array  | 
            ||
| 167 | */  | 
            ||
| 168 | protected $aFont = array(0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D', 4 => 'E', 97 => 'SA', 98 => 'SB');  | 
            ||
| 169 | /**  | 
            ||
| 170 | * Selected internal font.  | 
            ||
| 171 | *  | 
            ||
| 172 | * @var string  | 
            ||
| 173 | */  | 
            ||
| 174 | protected $font = 'A';  | 
            ||
| 175 | /**  | 
            ||
| 176 | * Resolution in dpi.  | 
            ||
| 177 | *  | 
            ||
| 178 | * @var int  | 
            ||
| 179 | */  | 
            ||
| 180 | public $dpi = 203; //dots per inch  | 
            ||
| 181 | /**  | 
            ||
| 182 | * Resolution in dpmm.  | 
            ||
| 183 | *  | 
            ||
| 184 | * @var int  | 
            ||
| 185 | */  | 
            ||
| 186 | public $dpmm = 8; //dots per mm  | 
            ||
| 187 | /**  | 
            ||
| 188 | * Maximum width paper.  | 
            ||
| 189 | *  | 
            ||
| 190 | * @var int  | 
            ||
| 191 | */  | 
            ||
| 192 | public $widthMaxmm = 80;//mm  | 
            ||
| 193 | /**  | 
            ||
| 194 | * Selected Width paper.  | 
            ||
| 195 | *  | 
            ||
| 196 | * @var int  | 
            ||
| 197 | */  | 
            ||
| 198 | public $widthPaper = 80;//mm  | 
            ||
| 199 | /**  | 
            ||
| 200 | * Maximum width for printed area.  | 
            ||
| 201 | *  | 
            ||
| 202 | * @var int  | 
            ||
| 203 | */  | 
            ||
| 204 | public $widthPrint = 72;//mm  | 
            ||
| 205 | /**  | 
            ||
| 206 | * Maximum width for printed area in dots.  | 
            ||
| 207 | *  | 
            ||
| 208 | * @var int  | 
            ||
| 209 | */  | 
            ||
| 210 | public $widthMaxdots = 576;//dots  | 
            ||
| 211 | /**  | 
            ||
| 212 | * Maximum number of characters per line.  | 
            ||
| 213 | *  | 
            ||
| 214 | * @var int  | 
            ||
| 215 | */  | 
            ||
| 216 | public $maxchars = 48;//max characters per line  | 
            ||
| 217 | |||
| 218 | //protected property standards  | 
            ||
| 219 | /**  | 
            ||
| 220 | * Connector to printer.  | 
            ||
| 221 | *  | 
            ||
| 222 | * @var ConnectosInterface  | 
            ||
| 223 | */  | 
            ||
| 224 | protected $connector = null;  | 
            ||
| 225 | /**  | 
            ||
| 226 | * Seleted printer mode.  | 
            ||
| 227 | *  | 
            ||
| 228 | * @var string  | 
            ||
| 229 | */  | 
            ||
| 230 | protected $printerMode = 'normal';  | 
            ||
| 231 | /**  | 
            ||
| 232 | * Selected bold mode.  | 
            ||
| 233 | *  | 
            ||
| 234 | * @var bool  | 
            ||
| 235 | */  | 
            ||
| 236 | protected $boldMode = false;  | 
            ||
| 237 | /**  | 
            ||
| 238 | * Selected reverse colors mode.  | 
            ||
| 239 | *  | 
            ||
| 240 | * @var bool  | 
            ||
| 241 | */  | 
            ||
| 242 | protected $reverseColors = false;  | 
            ||
| 243 | /**  | 
            ||
| 244 | * Selected under lined mode.  | 
            ||
| 245 | *  | 
            ||
| 246 | * @var bool  | 
            ||
| 247 | */  | 
            ||
| 248 | protected $underlineMode = false;  | 
            ||
| 249 | /**  | 
            ||
| 250 | * Selected rotate 90 degrees mode  | 
            ||
| 251 | * @var bool  | 
            ||
| 252 | */  | 
            ||
| 253 | protected $rotateMode = false;  | 
            ||
| 254 | /**  | 
            ||
| 255 | * Buffer class.  | 
            ||
| 256 | *  | 
            ||
| 257 | * @var Connectors\Buffer  | 
            ||
| 258 | */  | 
            ||
| 259 | protected $buffer = null;  | 
            ||
| 260 | |||
| 261 | /**  | 
            ||
| 262 | * Class constructor  | 
            ||
| 263 | * Instantiates the data buffer.  | 
            ||
| 264 | *  | 
            ||
| 265 | * @param ConnectorInterface $conn  | 
            ||
| 266 | */  | 
            ||
| 267 | public function __construct(ConnectorInterface $conn = null)  | 
            ||
| 274 | |||
| 275 | /**  | 
            ||
| 276 | * Returns a default region for codepage  | 
            ||
| 277 | * if param $region is null will return actual default region from class  | 
            ||
| 278 | * if param $region is 'all' will return a array with all avaiable regions  | 
            ||
| 279 | * if param $region is a string will set the region parameter of class and returns it.  | 
            ||
| 280 | * NOTE: This command do not set the printer, only class parameters  | 
            ||
| 281 | *  | 
            ||
| 282 | * @param string $region  | 
            ||
| 283 | * @return string|array  | 
            ||
| 284 | */  | 
            ||
| 285 | public function defaultRegionPage($region = null)  | 
            ||
| 300 | |||
| 301 | /**  | 
            ||
| 302 | * Returns a default codepage  | 
            ||
| 303 | * if param $codepage is null will return actual default codepage from class  | 
            ||
| 304 | * if param $codepage is 'all' will return a array with all avaiable codepages  | 
            ||
| 305 | * if param $codepage is a string will set the codepage parameter of class and returns it.  | 
            ||
| 306 | * NOTE: This command do not set the printer, only class parameters  | 
            ||
| 307 | *  | 
            ||
| 308 | * @param string $codepage  | 
            ||
| 309 | * @return string|array  | 
            ||
| 310 | */  | 
            ||
| 311 | public function defaultCodePage($codepage = null)  | 
            ||
| 328 | |||
| 329 | /**  | 
            ||
| 330 | * Set a codepage table in printer.  | 
            ||
| 331 | *  | 
            ||
| 332 | * @param string $codepage  | 
            ||
| 333 | */  | 
            ||
| 334 | public function setCodePage($codepage = null)  | 
            ||
| 339 | |||
| 340 | /**  | 
            ||
| 341 | * Set a region page.  | 
            ||
| 342 | * The numeric key of array $this->aRegion is the command parameter.  | 
            ||
| 343 | *  | 
            ||
| 344 | * @param string $region  | 
            ||
| 345 | */  | 
            ||
| 346 | public function setRegionPage($region = null)  | 
            ||
| 352 | |||
| 353 | /**  | 
            ||
| 354 | * Returns the default printer font  | 
            ||
| 355 | * A - Font A (12 x 24)  | 
            ||
| 356 | * B - Font B (9 x 17)  | 
            ||
| 357 | * C - Font C  | 
            ||
| 358 | * D - Font D  | 
            ||
| 359 | * E - Font E  | 
            ||
| 360 | * Special A  | 
            ||
| 361 | * Special B  | 
            ||
| 362 | * Default Font A.  | 
            ||
| 363 | * if param $font is null will return actual default font from class  | 
            ||
| 364 | * if param $font is 'all' will return a array with all avaiable printer fonts  | 
            ||
| 365 | * if param $font is a string will set the font parameter of class and returns it.  | 
            ||
| 366 | * NOTE: This command do not set the printer, only class parameters  | 
            ||
| 367 | *  | 
            ||
| 368 | * @param string $font  | 
            ||
| 369 | * @return array|string  | 
            ||
| 370 | */  | 
            ||
| 371 | public function defaultFont($font = null)  | 
            ||
| 389 | |||
| 390 | /**  | 
            ||
| 391 | * Set a printer font  | 
            ||
| 392 | * If send a valid font name will set the printer otherelse a default font is selected  | 
            ||
| 393 | * @param string $font  | 
            ||
| 394 | */  | 
            ||
| 395 | public function setFont($font = null)  | 
            ||
| 401 | |||
| 402 | /**  | 
            ||
| 403 | * Set emphasys mode on or off.  | 
            ||
| 404 | */  | 
            ||
| 405 | public function setBold()  | 
            ||
| 416 | |||
| 417 | /**  | 
            ||
| 418 | * Set underline mode on or off.  | 
            ||
| 419 | */  | 
            ||
| 420 | public function setUnderlined()  | 
            ||
| 431 | |||
| 432 | /**  | 
            ||
| 433 | * Aligns all data in one line to the selected layout in standard mode.  | 
            ||
| 434 | * L - left C - center R - rigth  | 
            ||
| 435 | *  | 
            ||
| 436 | * @param string $align  | 
            ||
| 437 | */  | 
            ||
| 438 | public function setAlign($align = null)  | 
            ||
| 456 | |||
| 457 | /**  | 
            ||
| 458 | * Turns white/black reverse print On or Off for characters.  | 
            ||
| 459 | * n = odd: On, n = even: Off.  | 
            ||
| 460 | */  | 
            ||
| 461 | public function setReverseColors()  | 
            ||
| 472 | |||
| 473 | /**  | 
            ||
| 474 | * Set expanded mode.  | 
            ||
| 475 | * @param int $size multiplies normal size 1 - 8  | 
            ||
| 476 | */  | 
            ||
| 477 | public function setExpanded($size = null)  | 
            ||
| 496 | |||
| 497 | /**  | 
            ||
| 498 | * Set condensed mode.  | 
            ||
| 499 | */  | 
            ||
| 500 | public function setCondensed()  | 
            ||
| 505 | |||
| 506 | |||
| 507 | /**  | 
            ||
| 508 | * Set the printer mode.  | 
            ||
| 509 | */  | 
            ||
| 510 | abstract public function setPrintMode($mode = null);  | 
            ||
| 511 | |||
| 512 | /**  | 
            ||
| 513 | * Set rotate 90 degrees.  | 
            ||
| 514 | */  | 
            ||
| 515 | public function setRotate90()  | 
            ||
| 526 | |||
| 527 | /**  | 
            ||
| 528 | * initialize printer  | 
            ||
| 529 | * Clears the data in the print buffer and resets the printer modes to  | 
            ||
| 530 | * the modes that were in effect when the power was turned on.  | 
            ||
| 531 | */  | 
            ||
| 532 | public function initialize()  | 
            ||
| 542 | |||
| 543 | /**  | 
            ||
| 544 | * Send message or command to buffer  | 
            ||
| 545 | * when sending commands is not required to convert characters,  | 
            ||
| 546 | * so the variable may translate by false.  | 
            ||
| 547 | *  | 
            ||
| 548 | * @param string $text  | 
            ||
| 549 | */  | 
            ||
| 550 | public function text($text = '')  | 
            ||
| 556 | |||
| 557 | /**  | 
            ||
| 558 | * Set horizontal and vertical motion units  | 
            ||
| 559 | * $horizontal => character spacing 1/x"  | 
            ||
| 560 | * $vertical => line spacing 1/y".  | 
            ||
| 561 | *  | 
            ||
| 562 | * @param int $horizontal  | 
            ||
| 563 | * @param int $vertical  | 
            ||
| 564 | */  | 
            ||
| 565 | public function setSpacing($horizontal = 30, $vertical = 30)  | 
            ||
| 569 | |||
| 570 | /**  | 
            ||
| 571 | * Set right-side character spacing  | 
            ||
| 572 | * 0 ≤ n ≤ 255 => 1/x".  | 
            ||
| 573 | *  | 
            ||
| 574 | * @param int $value  | 
            ||
| 575 | */  | 
            ||
| 576 | public function setCharSpacing($value = 3)  | 
            ||
| 580 | |||
| 581 | /**  | 
            ||
| 582 | * Line spacing  | 
            ||
| 583 | * The default is set to zero and 30/180 "  | 
            ||
| 584 | * any different number of zero will generate multiples of.  | 
            ||
| 585 | *  | 
            ||
| 586 | * @param int $paragraph  | 
            ||
| 587 | */  | 
            ||
| 588 | public function setParagraph($value = 0)  | 
            ||
| 603 | |||
| 604 | /**  | 
            ||
| 605 | * Prints data and feeds paper n lines  | 
            ||
| 606 | * ESC d n Prints data and feeds paper n lines.  | 
            ||
| 607 | *  | 
            ||
| 608 | * @param type $lines  | 
            ||
| 609 | */  | 
            ||
| 610 | public function lineFeed($lines = 1)  | 
            ||
| 618 | |||
| 619 | /**  | 
            ||
| 620 | * Prints data and feeds paper n dots  | 
            ||
| 621 | * ESC J n Prints data and feeds paper n dots.  | 
            ||
| 622 | *  | 
            ||
| 623 | * @param int $dots  | 
            ||
| 624 | */  | 
            ||
| 625 | public function dotFeed($dots = 1)  | 
            ||
| 630 | |||
| 631 | /**  | 
            ||
| 632 | * Generate a pulse, for opening a cash drawer if one is connected.  | 
            ||
| 633 | * The default settings should open an Epson drawer.  | 
            ||
| 634 | *  | 
            ||
| 635 | * @param int $pin 0 or 1, for pin 2 or pin 5 kick-out connector respectively.  | 
            ||
| 636 | * @param int $on_ms pulse ON time, in milliseconds.  | 
            ||
| 637 | * @param int $off_ms pulse OFF time, in milliseconds.  | 
            ||
| 638 | */  | 
            ||
| 639 | public function pulse($pin = 0, $on_ms = 120, $off_ms = 240)  | 
            ||
| 646 | |||
| 647 | /**  | 
            ||
| 648 | * Cut the paper.  | 
            ||
| 649 | *  | 
            ||
| 650 | * @param int $mode FULL or PARTIAL. If not specified, FULL will be used.  | 
            ||
| 651 | * @param int $lines Number of lines to feed after cut  | 
            ||
| 652 | */  | 
            ||
| 653 | public function cut($mode = 'FULL', $lines = 3)  | 
            ||
| 663 | |||
| 664 | /**  | 
            ||
| 665 | * Implements barcodes  | 
            ||
| 666 | * GS k m n d1...dn  | 
            ||
| 667 | * Prints bar code. n specifies the data length.  | 
            ||
| 668 | * m bar code system number of d (=k)  | 
            ||
| 669 | * "A" UPC-A 11 or 12  | 
            ||
| 670 | * "B" UPC-E 6, 7, 8, 11 or 12  | 
            ||
| 671 | * "C" JAN13 / EAN13 12 or 13  | 
            ||
| 672 | * "D" JAN8 / EAN8 7 or 8  | 
            ||
| 673 | * "E" CODE39 1 or more  | 
            ||
| 674 | * "F" ITF even  | 
            ||
| 675 | * "G" CODABAR (NW-7) 2 or more  | 
            ||
| 676 | * "H" CODE93 1–255  | 
            ||
| 677 | * "I" CODE128 2–255  | 
            ||
| 678 | * "J" GS1-128 2–255  | 
            ||
| 679 | * "K" GS1 DataBar Omnidirectional 13  | 
            ||
| 680 | * "L" GS1 DataBar Truncated 13  | 
            ||
| 681 | * "M" GS1 DataBar Limited 13  | 
            ||
| 682 | * "N" GS1 DataBar Expanded 2–255.  | 
            ||
| 683 | *  | 
            ||
| 684 | * GS h n Sets bar code height to n dots.  | 
            ||
| 685 | * GS w n Sets bar width of bar code. n = 2–6 (thin–thick)  | 
            ||
| 686 | * GS H n Selects print position of HRI characters.  | 
            ||
| 687 | * n = 0, "0": Not printed  | 
            ||
| 688 | * n = 1, "1": Above the bar code  | 
            ||
| 689 | * n = 2, "2": Below the bar code  | 
            ||
| 690 | * n = 3, "3": Both above and below the bar code  | 
            ||
| 691 | * GS f n Selects font for the HRI characters.  | 
            ||
| 692 | * n = 0, "0": Font A,  | 
            ||
| 693 | * n = 1, "1": Font B  | 
            ||
| 694 | *  | 
            ||
| 695 | * @param int $type Default CODE128  | 
            ||
| 696 | * @param int $height  | 
            ||
| 697 | * @param int $lineWidth  | 
            ||
| 698 | * @param string $txtPosition  | 
            ||
| 699 | * @param string $txtFont  | 
            ||
| 700 | * @param string $data  | 
            ||
| 701 | */  | 
            ||
| 702 | public function barcode(  | 
            ||
| 742 | |||
| 743 | /**  | 
            ||
| 744 | * Imprime o QR Code  | 
            ||
| 745 | * @param string $texto Dados a serem inseridos no QRCode  | 
            ||
| 746 | * @param string $level Nivel de correção L,M,Q ou H  | 
            ||
| 747 | * @param int $modelo modelo de QRCode 1, 2 ou 0 Micro  | 
            ||
| 748 | * @param int $wmod largura da barra 3 ~ 16  | 
            ||
| 749 | */  | 
            ||
| 750 | public function barcodeQRCode($texto = '', $level = 'L', $modelo = 2, $wmod = 4)  | 
            ||
| 787 | |||
| 788 | /**  | 
            ||
| 789 | * Close and clean buffer  | 
            ||
| 790 | * All data will be lost.  | 
            ||
| 791 | */  | 
            ||
| 792 | public function close()  | 
            ||
| 796 | |||
| 797 | /**  | 
            ||
| 798 | * Return all data buffer.  | 
            ||
| 799 | *  | 
            ||
| 800 | * @param string $type specifies the return format  | 
            ||
| 801 | */  | 
            ||
| 802 | public function getBuffer($type = '')  | 
            ||
| 837 | |||
| 838 | /**  | 
            ||
| 839 | * Send commands from buffer to connector printer.  | 
            ||
| 840 | */  | 
            ||
| 841 | public function send(ConnectorInterface $conn = null)  | 
            ||
| 854 | |||
| 855 | /**  | 
            ||
| 856 | *  | 
            ||
| 857 | * @param type $type  | 
            ||
| 858 | * @param type $data  | 
            ||
| 859 | * @param type $source  | 
            ||
| 860 | * @throws InvalidArgumentException  | 
            ||
| 861 | */  | 
            ||
| 862 | protected static function validateBarcodeData($type, $data, $source)  | 
            ||
| 885 | |||
| 886 | /**  | 
            ||
| 887 | * Insert a image.  | 
            ||
| 888 | *  | 
            ||
| 889 | * @param string $filename Path to image file  | 
            ||
| 890 | * @param float $width  | 
            ||
| 891 | * @param float $height  | 
            ||
| 892 | * @throws RuntimeException  | 
            ||
| 893 | */  | 
            ||
| 894 | public function putImage($filename = '', $width = null, $height = null)  | 
            ||
| 912 | |||
| 913 | /**  | 
            ||
| 914 | * Calculate the size of the word.  | 
            ||
| 915 | *  | 
            ||
| 916 | * @param string $data  | 
            ||
| 917 | */  | 
            ||
| 918 | protected function getWordLength($data = '')  | 
            ||
| 923 | |||
| 924 | /**  | 
            ||
| 925 | * Generate two characters for a number:  | 
            ||
| 926 | * In lower and higher parts, or more parts as needed.  | 
            ||
| 927 | *  | 
            ||
| 928 | * @param int $int Input number  | 
            ||
| 929 | * @param int $length The number of bytes to output (1 - 4).  | 
            ||
| 930 | */  | 
            ||
| 931 | protected static function intLowHigh($input, $length)  | 
            ||
| 941 | |||
| 942 | /**  | 
            ||
| 943 | * Convert widths and heights to characters.  | 
            ||
| 944 | * Used before sending graphics to set the size.  | 
            ||
| 945 | *  | 
            ||
| 946 | * @param array $inputs  | 
            ||
| 947 | * @param bool $long True to use 4 bytes, false to use 2  | 
            ||
| 948 | * @return string  | 
            ||
| 949 | */  | 
            ||
| 950 | protected static function dataHeader(array $inputs, $long = true)  | 
            ||
| 963 | |||
| 964 | /**  | 
            ||
| 965 | * Throw an exception if the argument given is not a boolean.  | 
            ||
| 966 | *  | 
            ||
| 967 | * @param bool $test the input to test  | 
            ||
| 968 | * @param string $source the name of the function calling this  | 
            ||
| 969 | */  | 
            ||
| 970 | protected static function validateBoolean($test, $source)  | 
            ||
| 976 | |||
| 977 | /**  | 
            ||
| 978 | * Throw an exception if the argument given is not an integer within the specified range.  | 
            ||
| 979 | *  | 
            ||
| 980 | * @param int $test the input to test  | 
            ||
| 981 | * @param int $min the minimum allowable value (inclusive)  | 
            ||
| 982 | * @param int $max the maximum allowable value (inclusive)  | 
            ||
| 983 | * @param string $source the name of the function calling this  | 
            ||
| 984 | */  | 
            ||
| 985 | protected static function validateInteger($test, $min, $max, $source)  | 
            ||
| 991 | |||
| 992 | /**  | 
            ||
| 993 | * Throw an exception if the argument given can't be cast to a string.  | 
            ||
| 994 | *  | 
            ||
| 995 | * @param string $test the input to test  | 
            ||
| 996 | * @param string $source the name of the function calling this  | 
            ||
| 997 | */  | 
            ||
| 998 | protected static function validateString($test, $source)  | 
            ||
| 1004 | |||
| 1005 | /**  | 
            ||
| 1006 | * Translate the text from UTF-8 for the specified codepage  | 
            ||
| 1007 | * this translation uses "iconv" and admits texts ONLY in UTF-8.  | 
            ||
| 1008 | *  | 
            ||
| 1009 | * @param string $text  | 
            ||
| 1010 | *  | 
            ||
| 1011 | * @return string  | 
            ||
| 1012 | */  | 
            ||
| 1013 | protected function translate($text = '')  | 
            ||
| 1024 | |||
| 1025 | /**  | 
            ||
| 1026 | * Wrapper for GS ( L, to calculate and send correct data length.  | 
            ||
| 1027 | *  | 
            ||
| 1028 | * @param string $m Modifier/variant for function. Usually '0'.  | 
            ||
| 1029 | * @param string $fn Function number to use, as character.  | 
            ||
| 1030 | * @param string $data Data to send.  | 
            ||
| 1031 | *  | 
            ||
| 1032 | * @throws InvalidArgumentException Where the input lengths are bad.  | 
            ||
| 1033 | */  | 
            ||
| 1034 | private function sendGraphicsData($m, $fn, $data = '')  | 
            ||
| 1042 | }  | 
            ||
| 1043 | 
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..