This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Posprint\Printers; |
||
4 | |||
5 | /** |
||
6 | * Daruma class for POS printer |
||
7 | * Model: DR700 |
||
8 | * |
||
9 | * @category NFePHP |
||
10 | * @package Posprint |
||
11 | * @copyright Copyright (c) 2016 |
||
12 | * @license http://www.gnu.org/licenses/lesser.html LGPL v3 |
||
13 | * @author Roberto L. Machado <linux.rlm at gmail dot com> |
||
14 | * @link http://github.com/nfephp-org/posprint for the canonical source repository |
||
15 | */ |
||
16 | |||
17 | use Posprint\Printers\DefaultPrinter; |
||
18 | use Posprint\Printers\PrinterInterface; |
||
19 | use Posprint\Graphics\Graphics; |
||
20 | use InvalidArgumentException; |
||
21 | use RuntimeException; |
||
22 | |||
23 | final class Daruma extends DefaultPrinter implements PrinterInterface |
||
24 | { |
||
25 | /** |
||
26 | * List all available code pages. |
||
27 | * |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $aCodePage = array( |
||
31 | 'ISO8859-1' => array('conv' => 'ISO8859-1', 'table' => '0', 'desc' => 'ISO8859-1: Latin1'), |
||
32 | 'CP437' => array('conv' => '437', 'table' => '3', 'desc' => 'PC437: USA, Standard Europe'), |
||
33 | 'CP850' => array('conv' => '850', 'table' => '1', 'desc' => 'PC850: Multilingual') |
||
34 | ); |
||
35 | /** |
||
36 | * List all available region pages. |
||
37 | * |
||
38 | * @var array |
||
39 | */ |
||
40 | protected $aRegion = array( |
||
41 | 'LATIN', |
||
42 | ); |
||
43 | /** |
||
44 | * List all avaiable fonts |
||
45 | * |
||
46 | * @var array |
||
47 | */ |
||
48 | protected $aFont = array(0 => 'normal', 1 => 'elite'); |
||
49 | /** |
||
50 | * Selected internal font. |
||
51 | * |
||
52 | * @var string |
||
53 | */ |
||
54 | protected $font = 'normal'; |
||
55 | /** |
||
56 | * Seleted code page |
||
57 | * Defined in printer class. |
||
58 | * |
||
59 | * @var string |
||
60 | */ |
||
61 | protected $codepage = 'ISO8859-1'; |
||
62 | /** |
||
63 | * Acceptable barcodes list |
||
64 | * @var array |
||
65 | */ |
||
66 | protected $barcode1Dlist = [ |
||
67 | 'EAN13' => 1, |
||
68 | 'EAN8' => 2, |
||
69 | 'S25' => 3, |
||
70 | 'I25' => 4, |
||
71 | 'CODE128' => 5, |
||
72 | 'CODE39' => 6, |
||
73 | 'CODE93' => 7, |
||
74 | 'UPC_A' => 8, |
||
75 | 'CODABAR' => 9, |
||
76 | 'MSI' => 10, |
||
77 | 'CODE11' => 11 |
||
78 | ]; |
||
79 | /** |
||
80 | * List of supported models |
||
81 | * @var array |
||
82 | */ |
||
83 | protected $modelList = [ |
||
84 | 'DR600', |
||
85 | 'DR700' |
||
86 | ]; |
||
87 | /** |
||
88 | * Selected model |
||
89 | * @var string |
||
90 | */ |
||
91 | protected $printerModel = 'DR700'; |
||
92 | |||
93 | //public function __construct(); vide DefaultPrinter |
||
0 ignored issues
–
show
|
|||
94 | //public function defaultCodePage(); vide DefaultPrinter |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
42% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
95 | //public function defaultRegionPage(); vide DefaultPrinter |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
42% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
96 | //public function defaultFont(); vide DefaultPrinter |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
42% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
97 | //public function defaultModel(); vide DefaultPrinter |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
42% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
98 | //public function initialize(); vide DefaultPrinter |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
42% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
99 | // |
||
100 | // 0000000000111111111122222222223333333333 |
||
101 | // 0123456789012345678901234567890123456789 |
||
102 | //[ESC] 228 0XXXX5678X0XXX45XXXXXXXXXXXXXXXXX3456XX9 |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
103 | |||
104 | /** |
||
105 | * Select printer mode |
||
106 | * |
||
107 | * @param string $mode |
||
108 | */ |
||
109 | public function setPrintMode($mode = null) |
||
110 | { |
||
111 | //not used for this printer |
||
112 | } |
||
113 | |||
114 | //public function setCodePage(); vide DefaultPrinter |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
42% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
115 | |||
116 | /** |
||
117 | * Set a region page. |
||
118 | * The numeric key of array $this->aRegion is the command parameter. |
||
119 | * |
||
120 | * @param string $region |
||
121 | */ |
||
122 | public function setRegionPage($region = null) |
||
123 | { |
||
124 | //not used for this printer |
||
125 | } |
||
126 | |||
127 | /** |
||
128 | * Set a printer font |
||
129 | * If send a valid font name will set the printer otherelse a default font is selected |
||
130 | * ESC ! n |
||
131 | * n (BIT) FUNÇÃO |
||
132 | * 0 ..... 0 fonte normal |
||
133 | * 1 fonte elite |
||
134 | * 3 ..... 0 desliga enfatizado |
||
135 | * 1 liga enfatizado |
||
136 | * 4 ..... 0 desliga dupla altura |
||
137 | * 1 liga dupla altura |
||
138 | * 5 ..... 0 desliga expandido |
||
139 | * 1 liga expandido |
||
140 | * 7 ..... 0 desliga sublinhado |
||
141 | * 1 liga sublinhado |
||
142 | * |
||
143 | * @param string $font |
||
144 | */ |
||
145 | public function setFont($font = null) |
||
146 | { |
||
147 | $font = $this->defaultFont($font); |
||
148 | $fn = array_keys($this->aFont, $font, true); |
||
149 | $mode = $fn[0]; |
||
150 | $mode += (8 * $this->boldMode); |
||
151 | $mode += (16 * $this->doubleHeigth); |
||
152 | $mode += (32 * $this->expandedMode); |
||
153 | $mode += (128 * $this->underlineMode); |
||
154 | $this->buffer->write(self::ESC.'!'.chr($mode)); |
||
155 | } |
||
156 | |||
157 | /** |
||
158 | * Set emphasys mode on or off. |
||
159 | */ |
||
160 | public function setBold() |
||
161 | { |
||
162 | $this->boldMode = ! $this->boldMode; |
||
163 | if ($this->boldMode) { |
||
164 | $this->buffer->write(self::ESC . 'E'); |
||
165 | } else { |
||
166 | $this->buffer->write(self::ESC . 'F'); |
||
167 | } |
||
168 | } |
||
169 | |||
170 | /** |
||
171 | * Set Italic mode |
||
172 | * Apenas para V.02.20.00 ou superior. |
||
173 | */ |
||
174 | public function setItalic() |
||
175 | { |
||
176 | $n = 1; |
||
177 | if ($this->italicMode) { |
||
178 | $n = 0; |
||
179 | } |
||
180 | $this->italicMode = ! $this->italicMode; |
||
181 | $this->buffer->write(self::ESC . '4' .chr($n)); |
||
182 | } |
||
183 | |||
184 | /** |
||
185 | * Set underline mode on or off. |
||
186 | */ |
||
187 | public function setUnderlined() |
||
188 | { |
||
189 | $this->underlineMode = ! $this->underlineMode; |
||
190 | $this->buffer->write(self::ESC . '-'); |
||
191 | } |
||
192 | |||
193 | /** |
||
194 | * Set or unset condensed mode. |
||
195 | */ |
||
196 | public function setCondensed() |
||
197 | { |
||
198 | $this->condensedMode = ! $this->condensedMode; |
||
199 | if ($this->condensedMode) { |
||
200 | $this->buffer->write(self::SI); |
||
201 | } else { |
||
202 | $this->buffer->write(self::DC2); |
||
203 | } |
||
204 | } |
||
205 | |||
206 | /** |
||
207 | * Set or unset expanded mode. |
||
208 | * |
||
209 | * @param integer $size not used |
||
210 | */ |
||
211 | public function setExpanded($size = null) |
||
212 | { |
||
213 | $this->expandedMode = ! $this->expandedMode; |
||
214 | $this->buffer->write(self::ESC . 'W'); |
||
215 | } |
||
216 | |||
217 | /** |
||
218 | * Aligns all data in one line to the selected layout in standard mode. |
||
219 | * L - left C - center R - rigth |
||
220 | * OBS: O comando de justificação de texto desliga as configurações de margem. |
||
221 | * Apenas para V.02.20.00 ou superior. |
||
222 | * |
||
223 | * @param string $align |
||
224 | */ |
||
225 | public function setAlign($align = null) |
||
226 | { |
||
227 | if (is_null($align)) { |
||
228 | $align = 'L'; |
||
229 | } |
||
230 | $value = strtoupper($align); |
||
231 | switch ($value) { |
||
232 | case 'C': |
||
233 | $mode = 1; |
||
234 | break; |
||
235 | case 'R': |
||
236 | $mode = 2; |
||
237 | break; |
||
238 | default: |
||
239 | $mode = 0; |
||
240 | } |
||
241 | $this->buffer->write(self::ESC . 'j' . chr($mode)); |
||
242 | } |
||
243 | |||
244 | /** |
||
245 | * Turns white/black reverse print On or Off for characters. |
||
246 | */ |
||
247 | public function setReverseColors() |
||
248 | { |
||
249 | //not used for this printer |
||
250 | } |
||
251 | |||
252 | /** |
||
253 | * Set rotate 90 degrees. |
||
254 | */ |
||
255 | public function setRotate90() |
||
256 | { |
||
257 | //not used for this printer |
||
258 | } |
||
259 | |||
260 | /** |
||
261 | * Set horizontal and vertical motion units |
||
262 | * $horizontal => character spacing 1/x" |
||
263 | * $vertical => line spacing 1/y". |
||
264 | * DLE A x y |
||
265 | * Ajusta a unidade de movimento horizontal e vertical para aproximadamente |
||
266 | * 25.4/x mm {1/x"} e 25.4/y mm {1/y"}. A unidade horizontal (x) não é utilizada |
||
267 | * na impressora. |
||
268 | * Faixa: 0 ≤ x ≤ 255 |
||
269 | * 0 ≤ y ≤ 255 |
||
270 | * Padrão: x = 200 (sem uso na impressora) |
||
271 | * y = 400 |
||
272 | * Quando x e y são igual a zero, o valor padrão é carregado. |
||
273 | * |
||
274 | * @param int $horizontal |
||
275 | * @param int $vertical |
||
276 | */ |
||
277 | public function setSpacing($horizontal = 30, $vertical = 30) |
||
278 | { |
||
279 | $horizontal = self::validateInteger($horizontal, 0, 255, 30); |
||
280 | $vertical = self::validateInteger($vertical, 0, 255, 30); |
||
281 | $this->buffer->write(self::DLE.'A'.chr($horizontal).chr($vertical)); |
||
282 | } |
||
283 | |||
284 | /** |
||
285 | * Set right-side character spacing |
||
286 | * 0 ≤ n ≤ 255 => 1/x". |
||
287 | * |
||
288 | * @param int $value |
||
289 | */ |
||
290 | public function setCharSpacing($value = 3) |
||
291 | { |
||
292 | //not used for this printer |
||
293 | } |
||
294 | |||
295 | //public function setParagraph(); vide DefaultPrinter |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
42% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
296 | //public function text(); vide default |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
297 | |||
298 | /** |
||
299 | * Prints data and feeds paper n lines |
||
300 | * ESC d n Prints data and feeds paper n lines. |
||
301 | * |
||
302 | * @param integer $lines |
||
303 | */ |
||
304 | public function lineFeed($lines = 1) |
||
305 | { |
||
306 | $lines = self::validateInteger($lines, 0, 255, 1); |
||
307 | for ($lin = 1; $lin <= $lines; $lin++) { |
||
308 | $this->buffer->write(self::LF); |
||
309 | } |
||
310 | } |
||
311 | |||
312 | //public function dotFeed(); vide default |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
313 | |||
314 | /** |
||
315 | * Insert a image. |
||
316 | * DLE X m xL xH yL yH d1....dk |
||
317 | * m Mode Vertical Dot Density Horizontal Dot Density |
||
318 | * 0 Normal 200 dpi 200 dpi |
||
319 | * 1 Double-width 200 dpi 100 dpi |
||
320 | * 2 Double-height 100 dpi 200 dpi |
||
321 | * 3 Quadruple 100 dpi 100 dpi |
||
322 | * |
||
323 | * @param string $filename Path to image file |
||
324 | * @param int $width |
||
325 | * @param int $height |
||
326 | * @param int $size 0-normal 1-Double Width 2-Double Heigth 3-Quadruple |
||
327 | * @throws RuntimeException |
||
328 | */ |
||
329 | public function putImage($filename = '', $width = null, $height = null, $size = 0) |
||
330 | { |
||
331 | try { |
||
332 | $img = new Graphics($filename, $width, $height); |
||
333 | } catch (RuntimeException $e) { |
||
334 | throw new RuntimeException($e->getMessage()); |
||
335 | } catch (InvalidArgumentException $e) { |
||
336 | throw new RuntimeException($e->getMessage()); |
||
337 | } |
||
338 | $size = self::validateInteger($size, 0, 3, 0); |
||
339 | $imgHeader = self::dataHeader(array($img->getWidth(), $img->getHeight()), true); |
||
340 | $this->buffer->write(self::DLE . 'X' . chr($size) . $imgHeader . $img->getRasterImage()); |
||
341 | } |
||
342 | |||
343 | /** |
||
344 | * Generate a pulse, for opening a cash drawer if one is connected. |
||
345 | * |
||
346 | * @param int $pin not for this printer |
||
347 | * @param int $on_ms not for this printer |
||
348 | * @param int $off_ms not for this printer |
||
349 | */ |
||
350 | public function pulse($pin = 0, $on_ms = 120, $off_ms = 240) |
||
351 | { |
||
352 | $this->buffer->write(self::ESC . 'p'); |
||
353 | } |
||
354 | |||
355 | /** |
||
356 | * Cut the paper. |
||
357 | * |
||
358 | * @param int $mode FULL or PARTIAL. not for this printer. |
||
359 | * @param int $lines Number of lines to feed after cut |
||
360 | */ |
||
361 | public function cut($mode = 'PARTIAL', $lines = 3) |
||
362 | { |
||
363 | $this->buffer->write(self::ESC.'m'); |
||
364 | $this->lineFeed($lines); |
||
365 | } |
||
366 | |||
367 | /** |
||
368 | * Implements barcodes 1D |
||
369 | * ESC b n1 n2 n3 n4 s1...sn NULL |
||
370 | * n1 – tipo do código a ser impresso |
||
371 | * EAN13 1 |
||
372 | * EAN8 2 |
||
373 | * S2OF5 3 |
||
374 | * I2OF5 4 |
||
375 | * CODE128 5 |
||
376 | * CODE39 6 |
||
377 | * CODE93 7 |
||
378 | * UPC_A 8 |
||
379 | * CODABAR 9 |
||
380 | * MSI 10 |
||
381 | * CODE11 11 |
||
382 | * n2 – largura da barra. De 2 a 5. Se 0, é usado 2. |
||
383 | * n3 – altura da barra. De 50 a 200. Se 0, é usado 50. |
||
384 | * n4 – se 1, imprime o código abaixo das barras |
||
385 | * s1...sn – string contendo o código. |
||
386 | * EAN-13: 12 dígitos de 0 a 9 |
||
387 | * EAN–8: 7 dígitos de 0 a 9 |
||
388 | * UPC–A: 11 dígitos de 0 a 9 |
||
389 | * CODE 39 : Tamanho variável. 0-9, A-Z, '-', '.', '%', '/', '$', ' ', '+' |
||
390 | * O caracter '*' de start/stop é inserido automaticamente. |
||
391 | * Sem dígito de verificação MOD 43 |
||
392 | * CODE 93: Tamanho variável. 0-9, A-Z, '-', '.', ' ', '$', '/', '+', '%' |
||
393 | * O caracter '*' de start/stop é inserido automaticamente. |
||
394 | * CODABAR: tamanho variável. 0 - 9, '$', '-', ':', '/', '.', '+' |
||
395 | * Existem 4 diferentes caracteres de start/stop: A, B, C, and D que são |
||
396 | * usados em pares e não podem aparecer em nenhum outro lugar do código. |
||
397 | * Sem dígito de verificação |
||
398 | * CODE 11: Tamanho variável. 0 a 9 |
||
399 | * Checksum de dois caracteres. |
||
400 | * CODE 128: Tamanho variável. Todos os caracteres ASCII. |
||
401 | * Interleaved 2 of 5: tamanho sempre par. 0 a 9. Sem dígito de verificação |
||
402 | * Standard 2 of 5 (Industrial): 0 a 9. Sem dígito de verificação |
||
403 | * MSI/Plessey: tamanho variável. 0 - 9. 1 dígito de verificação |
||
404 | * |
||
405 | * @param string $type Default CODE128 |
||
406 | * @param int $height |
||
407 | * @param int $lineWidth |
||
408 | * @param string $txtPosition |
||
409 | * @param string $txtFont |
||
410 | * @param string $data |
||
411 | */ |
||
412 | public function barcode( |
||
413 | $data = '123456', |
||
414 | $type = 'CODE128', |
||
415 | $height = 162, |
||
416 | $lineWidth = 2, |
||
417 | $txtPosition = 'none', |
||
418 | $txtFont = '' |
||
419 | ) { |
||
420 | if (! $data = Barcodes\Barcode1DAnalysis::validate($data, $type)) { |
||
421 | throw new \InvalidArgumentException('Data or barcode type is incorrect.'); |
||
422 | } |
||
423 | if (! array_key_exists($type, $this->barcode1Dlist)) { |
||
424 | throw new \InvalidArgumentException('This barcode type is not listed.'); |
||
425 | } |
||
426 | $id = $this->barcode1Dlist[$type]; |
||
427 | $height = self::validateInteger($height, 50, 200, 50); |
||
428 | $lineWidth = self::validateInteger($lineWidth, 2, 5, 2); |
||
429 | $n4 = 0; |
||
430 | if ($txtPosition != 'none') { |
||
431 | $n4 = 1; |
||
432 | } |
||
433 | $this->buffer->write(self::ESC . 'b' . chr($id) . chr($lineWidth) . chr($height) . chr($n4) . $data); |
||
434 | } |
||
435 | |||
436 | /** |
||
437 | * Print PDF 417 2D barcode |
||
438 | * @param string $data |
||
439 | * @param integer $ecc |
||
440 | * @param integer $pheight |
||
441 | * @param integer $pwidth |
||
442 | * @param integer $colunms |
||
443 | * @return boolean |
||
444 | */ |
||
445 | public function barcodePDF417($data = '', $ecc = 5, $pheight = 2, $pwidth = 2, $colunms = 3) |
||
446 | { |
||
447 | if (empty($data)) { |
||
448 | return false; |
||
449 | } |
||
450 | $length = strlen($data)+6; |
||
451 | if ($length > 906) { |
||
452 | return false; |
||
453 | } |
||
454 | $pheight = self::validateInteger($pheight, 1, 8, 2); |
||
455 | $pwidth = self::validateInteger($pwidth, 1, 8, 2); |
||
456 | $pH = intval($length / 256); |
||
457 | $pL = ($length % 256); |
||
458 | //[ESC] <128> <–Size><+Size> <–Columns><+Columns> <–Height><+Height> <–Width><+Width> |
||
459 | //<D001> <D002> . . . <Dnnn> |
||
460 | //Size inclui os demais 6 bytes de controle |
||
461 | //Size ≤ 906 |
||
462 | //nnn = Size – 6 |
||
463 | $cH = intval($colunms / 256); |
||
464 | $cL = ($colunms % 256); |
||
465 | $hH = intval($pheight / 256); |
||
466 | $hL = ($pheight % 256); |
||
467 | $wH = intval($pwidth / 256); |
||
468 | $wL = ($pwidth % 256); |
||
469 | |||
470 | $this->buffer->write(self::ESC |
||
471 | . chr(128) |
||
472 | . chr($pL) |
||
473 | . chr($pH) |
||
474 | . chr($cL) |
||
475 | . chr($cH) |
||
476 | . chr($hL) |
||
477 | . chr($hH) |
||
478 | . chr($wL) |
||
479 | . chr($wH) |
||
480 | . $data); |
||
481 | } |
||
482 | |||
483 | /** |
||
484 | * Print QR Code |
||
485 | * [ESC] <129> <–Size><+Size> <Width> <Ecc> <D001> <D002> . . . <Dnnn> |
||
486 | * Size inclui os 2 bytes de controle |
||
487 | * Size ≤ 402 |
||
488 | * nnn = Size – 2 |
||
489 | * Largura do módulo (Width): 0, 4 ≤ Width ≤ 7 ( =0 para default = 5) |
||
490 | * Redundância (ECC): 0, M, Q, H ( =0 para cálculo automático) |
||
491 | * Apenas para V.02.50.00 ou superior. |
||
492 | * |
||
493 | * @param string $data Dados a serem inseridos no QRCode |
||
494 | * @param string $level Nivel de correção L,M,Q ou H |
||
495 | * @param int $modelo modelo de QRCode none |
||
496 | * @param int $wmod largura da barra 4 ~ 7 |
||
497 | */ |
||
498 | public function barcodeQRCode($data = '', $level = 'L', $modelo = 2, $wmod = 4) |
||
499 | { |
||
500 | $len = strlen($data); |
||
501 | $size = $len + 2; |
||
502 | if ($size > 402) { |
||
503 | return false; |
||
504 | } |
||
505 | $nH = round($size/256, 0); |
||
506 | $nL = $size%256; |
||
507 | if ($wmod > 7 || $wmod < 4) { |
||
508 | $wmod = 5; |
||
509 | } |
||
510 | //set error correction level |
||
511 | $level = strtoupper($level); |
||
512 | switch ($level) { |
||
513 | case 'M': |
||
514 | case 'Q': |
||
515 | case 'H': |
||
516 | $ecc = $level; |
||
517 | break; |
||
518 | default: |
||
519 | $ecc = 0; |
||
520 | } |
||
521 | $this->buffer->write(self::ESC . chr(129) . chr($nL) . chr($nH) . chr($wmod) . $ecc . $data); |
||
522 | } |
||
523 | //public function send(); vide DefultPrinter |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
42% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
524 | //public function close(); vide DefaultPrinter |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
42% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
525 | } |
||
526 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.