Completed
Push — master ( 492d4a...b6cd50 )
by Roberto
06:18 queued 03:33
created

Daruma::setFont()   B

Complexity

Conditions 5
Paths 16

Size

Total Lines 15
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 15
ccs 0
cts 10
cp 0
rs 8.8571
cc 5
eloc 13
nc 16
nop 1
crap 30
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
20
final class Daruma extends DefaultPrinter implements PrinterInterface
21
{
22
    /**
23
     * List all available code pages.
24
     *
25
     * @var array
26
     */
27
    protected $aCodePage = array(
28
        'ISO8859-1' => array('conv' => 'ISO8859-1', 'table' => '0', 'desc' => 'ISO8859-1: Latin1'),
29
    );
30
    /**
31
     * List all available region pages.
32
     *
33
     * @var array
34
     */
35
    protected $aRegion = array(
36
        'LATIN',
37
    );
38
    /**
39
     * List all avaiable fonts
40
     *
41
     * @var array
42
     */
43
    protected $aFont = array(0 => 'normal', 1 => 'elite');
44
    /**
45
     * Selected internal font.
46
     *
47
     * @var string
48
     */
49
    protected $font = 'normal';
50
    /**
51
     * Seleted code page
52
     * Defined in printer class.
53
     *
54
     * @var string
55
     */
56
    protected $codepage = 'ISO8859-1';
57
    /**
58
     * Acceptable barcodes list
59
     * @var array
60
     */
61
    protected $barcode1Dlist = [
62
        'EAN13' => 1,
63
        'EAN8' => 2,
64
        'S25' => 3,
65
        'I25' => 4,
66
        'CODE128' => 5,
67
        'CODE39' => 6,
68
        'CODE93' => 7,
69
        'UPC_A' => 8,
70
        'CODABAR' => 9,
71
        'MSI' => 10,
72
        'CODE11' => 11
73
    ];
74
    /**
75
     * List of supported models
76
     * @var array
77
     */
78
    protected $modelList = [
79
        'DR600',
80
        'DR700'
81
    ];
82
    /**
83
     * Selected model
84
     * @var string
85
     */
86
    protected $printerModel = 'DR700';
87
    
88
    //public function __construct(); 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.

Loading history...
89
    //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.

Loading history...
90
    //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.

Loading history...
91
    //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.

Loading history...
92
    //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.

Loading history...
93
    //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.

Loading history...
94
    //
95
    //          0000000000111111111122222222223333333333
96
    //          0123456789012345678901234567890123456789
97
    //[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.

Loading history...
98
    /**
99
     * Select printer mode
100
     *
101
     * @param string $mode
102
     */
103
    public function setPrintMode($mode = null)
104
    {
105
        //not used for this printer
106
    }
107
    
108
    //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.

Loading history...
109
    
110
    /**
111
     * Set a region page.
112
     * The numeric key of array $this->aRegion is the command parameter.
113
     *
114
     * @param string $region
115
     */
116
    public function setRegionPage($region = null)
117
    {
118
        //not used for this printer
119
    }
120
    
121
    /**
122
     * Set a printer font
123
     * If send a valid font name will set the printer otherelse a default font is selected
124
     *     ESC ! n
125
     *        n (BIT)           FUNÇÃO
126
     *            0 ..... 0      fonte normal
127
     *                    1      fonte elite
128
     *            3 ..... 0      desliga enfatizado
129
     *                    1      liga enfatizado
130
     *            4 ..... 0      desliga dupla altura
131
     *                    1      liga dupla altura
132
     *            5 ..... 0      desliga expandido
133
     *                    1      liga expandido
134
     *            7 ..... 0      desliga sublinhado
135
     *                    1      liga sublinhado
136
     *
137
     * @param string $font
138
     */
139
    public function setFont($font = null)
140
    {
141
        $font = $this->defaultFont($font);
142
        $fn = array_keys($this->aFont, $font, true);
143
        $mode = $fn[0];
144
        $b = ($this->boldMode) ? 1 : 0;
145
        $d = ($this->doubleHeight) ? 1 : 0;
0 ignored issues
show
Bug introduced by
The property doubleHeight does not seem to exist. Did you mean doubleHeigth?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
146
        $e = ($this->expandedMode) ? 1 : 0;
147
        $u = ($this->underlineMode) ? 1 : 0;
148
        $mode += ((2**3) * $b);
149
        $mode += ((2**4) * $d);
150
        $mode += ((2**5) * $e);
151
        $mode += ((2**7) * $u);
152
        $this->buffer->write(self::ESC.'!'.chr($mode));
153
    }
154
155
    /**
156
     * Set emphasys mode on or off.
157
     */
158
    public function setBold()
159
    {
160
        $this->boldMode = ! $this->boldMode;
161
        if ($this->boldMode) {
162
            $this->buffer->write(self::ESC . 'E');
163
        } else {
164
            $this->buffer->write(self::ESC . 'F');
165
        }
166
    }
167
168
    /**
169
     * Set Italic mode
170
     * Apenas para V.02.20.00 ou superior.
171
     */
172
    public function setItalic()
173
    {
174
        $n = 1;
175
        if ($this->italicMode) {
176
            $n = 0;
177
        }
178
        $this->italicMode = ! $this->italicMode;
179
        $this->buffer->write(self::ESC . '4' .chr($n));
180
    }
181
182
    /**
183
     * Set underline mode on or off.
184
     */
185
    public function setUnderlined()
186
    {
187
        $this->underlineMode = ! $this->underlineMode;
188
        $this->buffer->write(self::ESC . '-');
189
    }
190
    
191
    /**
192
     * Set or unset condensed mode.
193
     */
194
    public function setCondensed()
195
    {
196
        $this->condensedMode = ! $this->condensedMode;
197
        if ($this->condensedMode) {
198
            $this->buffer->write(self::SI);
199
        } else {
200
            $this->buffer->write(self::DC2);
201
        }
202
    }
203
    
204
    /**
205
     * Set or unset expanded mode.
206
     *
207
     * @param integer $size not used
208
     */
209
    public function setExpanded($size = null)
210
    {
211
        $this->expandedMode = ! $this->expandedMode;
212
        $this->buffer->write(self::ESC . 'W');
213
    }
214
    
215
    /**
216
     * Aligns all data in one line to the selected layout in standard mode.
217
     * L - left  C - center  R - rigth
218
     * OBS: O comando de justificação de texto desliga as configurações de margem.
219
     *      Apenas para V.02.20.00 ou superior.
220
     *
221
     * @param string $align
222
     */
223
    public function setAlign($align = null)
224
    {
225
        if (is_null($align)) {
226
            $align = 'L';
227
        }
228
        $value = strtoupper($align);
229
        switch ($value) {
230
            case 'C':
231
                $mode = 1;
232
                break;
233
            case 'R':
234
                $mode = 2;
235
                break;
236
            default:
237
                $mode = 0;
238
        }
239
        $this->buffer->write(self::ESC . 'j' . chr($mode));
240
    }
241
    
242
    /**
243
     * Turns white/black reverse print On or Off for characters.
244
     */
245
    public function setReverseColors()
246
    {
247
        //not used for this printer
248
    }
249
250
    /**
251
     * Set rotate 90 degrees.
252
     */
253
    public function setRotate90()
254
    {
255
        //not used for this printer
256
    }
257
    
258
    /**
259
     * Set horizontal and vertical motion units
260
     * $horizontal => character spacing 1/x"
261
     * $vertical => line spacing 1/y".
262
     * DLE A x y
263
     * Ajusta a unidade de movimento horizontal e vertical para aproximadamente
264
     *   25.4/x mm {1/x"} e 25.4/y mm {1/y"}. A unidade horizontal (x) não é utilizada
265
     * na impressora.
266
     *   Faixa: 0 ≤ x ≤ 255
267
     *          0 ≤ y ≤ 255
268
     * Padrão: x = 200 (sem uso na impressora)
269
     *         y = 400
270
     * Quando x e y são igual a zero, o valor padrão é carregado.
271
     *
272
     * @param int $horizontal
273
     * @param int $vertical
274
     */
275
    public function setSpacing($horizontal = 30, $vertical = 30)
276
    {
277
        $horizontal = self::validateInteger($horizontal, 0, 255, 30);
278
        $vertical = self::validateInteger($vertical, 0, 255, 30);
279
        $this->buffer->write(self::DLE.'A'.chr($horizontal).chr($vertical));
280
    }
281
    
282
    /**
283
     * Set right-side character spacing
284
     * 0 ≤ n ≤ 255 => 1/x".
285
     *
286
     * @param int $value
287
     */
288
    public function setCharSpacing($value = 3)
289
    {
290
        //not used for this printer
291
    }
292
    
293
    //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.

Loading history...
294
    //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.

Loading history...
295
    
296
    /**
297
     * Prints data and feeds paper n lines
298
     * ESC d n Prints data and feeds paper n lines.
299
     *
300
     * @param integer $lines
301
     */
302
    public function lineFeed($lines = 1)
303
    {
304
        $lines = self::validateInteger($lines, 0, 255, 1);
305
        for ($lin = 1; $lin <= $lines; $lin++) {
306
            $this->buffer->write(self::LF);
307
        }
308
    }
309
310
    //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.

Loading history...
311
312
    /**
313
     * Insert a image.
314
     * DLE X m xL xH yL yH d1....dk
315
     *  m   Mode    Vertical Dot Density    Horizontal Dot Density
316
     *  0 Normal         200 dpi                200 dpi
317
     *  1 Double-width   200 dpi                100 dpi
318
     *  2 Double-height  100 dpi                200 dpi
319
     *  3 Quadruple      100 dpi                100 dpi
320
     *
321
     * @param  string $filename Path to image file
322
     * @param  float  $width
323
     * @param  float  $height
324
     * @param  int    $size     0-normal 1-Double Width 2-Double Heigth 3-Quadruple
325
     * @throws RuntimeException
326
     */
327
    public function putImage($filename = '', $width = null, $height = null, $size = 0)
328
    {
329
        try {
330
            $img = new Graphics($filename, $width, $height);
331
        } catch (RuntimeException $e) {
0 ignored issues
show
Bug introduced by
The class Posprint\Printers\RuntimeException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
332
            throw new RuntimeException($e->getMessage());
333
        } catch (InvalidArgumentException $e) {
0 ignored issues
show
Bug introduced by
The class Posprint\Printers\InvalidArgumentException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
334
            throw new RuntimeException($e->getMessage());
335
        }
336
        $size = self::validateInteger($size, 0, 3, 0);
337
        $imgHeader = self::dataHeader(array($img->getWidth(), $img->getHeight()), true);
338
        $this->buffer->write(self::DLE . 'X' . chr($size) . $imgHeader . $img->getRasterImage());
339
    }
340
    
341
    /**
342
     * Generate a pulse, for opening a cash drawer if one is connected.
343
     *
344
     * @param int $pin    not for this printer
345
     * @param int $on_ms  not for this printer
346
     * @param int $off_ms not for this printer
347
     */
348
    public function pulse($pin = 0, $on_ms = 120, $off_ms = 240)
349
    {
350
        $this->buffer->write(self::ESC . 'p');
351
    }
352
353
    /**
354
     * Cut the paper.
355
     *
356
     * @param int $mode  FULL or PARTIAL. not for this printer.
357
     * @param int $lines Number of lines to feed after cut
358
     */
359
    public function cut($mode = 'PARTIAL', $lines = 3)
360
    {
361
        $this->buffer->write(self::ESC.'m');
362
        $this->lineFeed($lines);
363
    }
364
    
365
    /**
366
     * Implements barcodes 1D
367
     * ESC b n1 n2 n3 n4 s1...sn NULL
368
     *  n1 – tipo do código a ser impresso
369
     *      EAN13 1
370
     *      EAN8 2
371
     *      S2OF5 3
372
     *      I2OF5 4
373
     *      CODE128 5
374
     *      CODE39 6
375
     *      CODE93 7
376
     *      UPC_A 8
377
     *      CODABAR 9
378
     *      MSI 10
379
     *      CODE11 11
380
     *  n2 – largura da barra. De 2 a 5. Se 0, é usado 2.
381
     *  n3 – altura da barra. De 50 a 200. Se 0, é usado 50.
382
     *  n4 – se 1, imprime o código abaixo das barras
383
     *  s1...sn – string contendo o código.
384
     *      EAN-13: 12 dígitos de 0 a 9
385
     *      EAN–8: 7 dígitos de 0 a 9
386
     *      UPC–A: 11 dígitos de 0 a 9
387
     *      CODE 39 : Tamanho variável. 0-9, A-Z, '-', '.', '%', '/', '$', ' ', '+'
388
     *      O caracter '*' de start/stop é inserido automaticamente.
389
     *      Sem dígito de verificação MOD 43
390
     *      CODE 93: Tamanho variável. 0-9, A-Z, '-', '.', ' ', '$', '/', '+', '%'
391
     *      O caracter '*' de start/stop é inserido automaticamente.
392
     *      CODABAR: tamanho variável. 0 - 9, '$', '-', ':', '/', '.', '+'
393
     *      Existem 4 diferentes caracteres de start/stop: A, B, C, and D que são
394
     *      usados em pares e não podem aparecer em nenhum outro lugar do código.
395
     *      Sem dígito de verificação
396
     *      CODE 11: Tamanho variável. 0 a 9
397
     *      Checksum de dois caracteres.
398
     *      CODE 128: Tamanho variável. Todos os caracteres ASCII.
399
     *      Interleaved 2 of 5: tamanho sempre par. 0 a 9. Sem dígito de verificação
400
     *      Standard 2 of 5 (Industrial): 0 a 9. Sem dígito de verificação
401
     *      MSI/Plessey: tamanho variável. 0 - 9. 1 dígito de verificação
402
     *
403
     * @param int    $type        Default CODE128
404
     * @param int    $height
405
     * @param int    $lineWidth
406
     * @param string $txtPosition
407
     * @param string $txtFont
408
     * @param string $data
409
     */
410
    public function barcode(
411
        $data = '123456',
412
        $type = 'CODE128',
413
        $height = 162,
414
        $lineWidth = 2,
415
        $txtPosition = 'none',
416
        $txtFont = ''
417
    ) {
418
        if (! $data = Barcodes\Barcode1DAnalysis::validate($data, $type)) {
419
            throw new \InvalidArgumentException('Data or barcode type is incorrect.');
420
        }
421
        if (! array_key_exists($type, $this->barcode1Dlist)) {
422
            throw new \InvalidArgumentException('This barcode type is not listed.');
423
        }
424
        $id = $this->barcode1Dlist[$type];
425
        $height = self::validateInteger($height, 50, 200, 50);
426
        $lineWidth = self::validateInteger($lineWidth, 2, 5, 2);
427
        $n4 = 0;
428
        if ($txtPosition != 'none') {
429
            $n4 = 1;
430
        }
431
        $this->buffer->write(self::ESC . 'b' . chr($id) . chr($lineWidth) . chr($height) . chr($n4) . $data);
432
    }
433
434
    /**
435
     * Print PDF 417 2D barcode
436
     * @param string $data
437
     * @param integer $ecc
438
     * @param integer $pheight
439
     * @param integer $pwidth
440
     * @param integer $colunms
441
     * @return boolean
442
     */
443
    public function barcodePDF417($data = '', $ecc = 5, $pheight = 2, $pwidth = 2, $colunms = 3)
444
    {
445
        if (empty($data)) {
446
            return false;
447
        }
448
        $length = strlen($data)+6;
449
        if ($length > 906) {
450
            return false;
451
        }
452
        $pheight = self::validateInteger($pheight, 1, 8, 2);
453
        $pwidth = self::validateInteger($pwidth, 1, 8, 2);
454
        $pH = intval($length / 256);
455
        $pL = ($length % 256);
456
        //[ESC] <128> <–Size><+Size> <–Columns><+Columns> <–Height><+Height> <–Width><+Width>
457
        //<D001> <D002> . . . <Dnnn>
458
        //Size inclui os demais 6 bytes de controle
459
        //Size ≤ 906
460
        //nnn = Size – 6
461
        $cH = intval($colunms / 256);
462
        $cL = ($colunms % 256);
463
        $hH = intval($pheight / 256);
464
        $hL = ($pheight % 256);
465
        $wH = intval($pwidth / 256);
466
        $wL = ($pwidth % 256);
467
        
468
        $this->buffer->write(self::ESC
469
            . chr(128)
470
            . chr($pL)
471
            . chr($pH)
472
            . chr($cL)
473
            . chr($cH)
474
            . chr($hL)
475
            . chr($hH)
476
            . chr($wL)
477
            . chr($wH)
478
            . $data);
479
    }
480
    
481
    /**
482
     * Print QR Code
483
     * [ESC] <129> <–Size><+Size> <Width> <Ecc> <D001> <D002> . . . <Dnnn>
484
     * Size inclui os 2 bytes de controle
485
     *    Size ≤ 402
486
     *    nnn = Size – 2
487
     *   Largura do módulo (Width): 0, 4 ≤ Width ≤ 7 ( =0 para default = 5)
488
     *   Redundância (ECC): 0, M, Q, H ( =0 para cálculo automático)
489
     * Apenas para V.02.50.00 ou superior.
490
     *
491
     * @param string $data   Dados a serem inseridos no QRCode
492
     * @param string $level  Nivel de correção L,M,Q ou H
493
     * @param int    $modelo modelo de QRCode none
494
     * @param int    $wmod   largura da barra 4 ~ 7
495
     */
496
    public function barcodeQRCode($data = '', $level = 'L', $modelo = 2, $wmod = 4)
497
    {
498
        $len = strlen($data);
499
        $size = $len + 2;
500
        if ($size > 402) {
501
            return false;
502
        }
503
        $nH = round($size/256, 0);
504
        $nL = $size%256;
505
        if ($wmod > 7 || $wmod < 4) {
506
            $wmod = 5;
0 ignored issues
show
Unused Code introduced by
$wmod is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

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.

Loading history...
507
        }
508
        //set error correction level
509
        $level = strtoupper($level);
510
        switch ($level) {
511
            case 'M':
512
            case 'Q':
513
            case 'H':
514
                $ecc = $level;
515
                break;
516
            default:
517
                $ecc = 0;
518
        }
519
        $this->buffer->write(self::ESC . chr(129) . chr($nL) . chr($nH) . chr($w) . $ecc . $data);
0 ignored issues
show
Bug introduced by
The variable $w does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
520
    }
521
    //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.

Loading history...
522
    //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.

Loading history...
523
}
524