Passed
Push — master ( 05ae39...42a567 )
by Roberto
57s queued 10s
created

Damdfe::headerMDFeRetrato()   D

Complexity

Conditions 12
Paths 216

Size

Total Lines 140

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 156

Importance

Changes 0
Metric Value
cc 12
nc 216
nop 3
dl 0
loc 140
ccs 0
cts 128
cp 0
crap 156
rs 4.7466
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace NFePHP\DA\MDFe;
4
5
/**
6
 * Esta classe gera do PDF do MDFDe, conforme regras e estruturas
7
 * estabelecidas pela SEFAZ.
8
 *
9
 * @category  Library
10
 * @package   nfephp-org/sped-da
11
 * @name      Damdfe.php
12
 * @copyright 2009-2016 NFePHP
13
 * @license   http://www.gnu.org/licenses/lesser.html LGPL v3
14
 * @link      http://github.com/nfephp-org/sped-da for the canonical source repository
15
 * @author    Leandro C. Lopez <leandro dot castoldi at gmail dot com>
16
 */
17
18
use Com\Tecnick\Barcode\Barcode;
19
use NFePHP\DA\Legacy\Dom;
20
use NFePHP\DA\Legacy\Common;
21
use NFePHP\DA\Legacy\Pdf;
22
23
class Damdfe extends Common
24
{
25
    //publicas
26
    public $logoAlign = 'L'; //alinhamento do logo
27
    public $yDados = 0;
28
    public $debugMode = 0; //ativa ou desativa o modo de debug
29
    //privadas
30
    protected $pdf; // objeto fpdf()
31
    protected $xml; // string XML NFe
32
    protected $logomarca = ''; // path para logomarca em jpg
33
    protected $errMsg = ''; // mesagens de erro
34
    protected $errStatus = false;// status de erro TRUE um erro ocorreu false sem erros
35
    protected $orientacao = 'P'; //orientação da DANFE P-Retrato ou L-Paisagem
36
    protected $papel = 'A4'; //formato do papel
37
    //destivo do arquivo pdf I-borwser, S-retorna o arquivo, D-força download, F-salva em arquivo local
38
    protected $destino = 'I';
39
    protected $pdfDir = ''; //diretorio para salvar o pdf com a opção de destino = F
40
    protected $fontePadrao = 'Times'; //Nome da Fonte para gerar o DANFE
41
    protected $version = '3.00a';
42
    protected $wPrint; //largura imprimivel
43
    protected $hPrint; //comprimento imprimivel
44
    protected $formatoChave = "#### #### #### #### #### #### #### #### #### #### ####";
45
    protected $margemInterna = 2;
46
47
    //variaveis da damdfe
48
    protected $id;
49
    protected $chMDFe;
50
    protected $tpAmb;
51
    protected $cOrgao;
52
    protected $xCondUso;
53
    protected $dhEvento;
54
    protected $cStat;
55
    protected $xMotivo;
56
    protected $CNPJDest = '';
57
    protected $dhRegEvento;
58
    protected $nProt;
59
    protected $tpEmis;
60
    protected $qrCodMDFe;
61
    //objetos
62
    private $dom;
63
64
    /**
65
     * __construct
66
     *
67
     * @param string $xmlfile Arquivo XML da MDFe
68
     * @param string $sOrientacao (Opcional) Orientação da impressão P-retrato L-Paisagem
69
     * @param string $sPapel Tamanho do papel (Ex. A4)
70
     * @param string $sPathLogo Caminho para o arquivo do logo
71
     * @param string $sDestino Estabelece a direção do envio do documento PDF I-browser D-browser com download S-
72
     * @param string $sDirPDF Caminho para o diretorio de armazenamento dos arquivos PDF
73
     * @param string $fonteDAMDFE Nome da fonte alternativa do DAnfe
0 ignored issues
show
Bug introduced by
There is no parameter named $fonteDAMDFE. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
74
     * @param integer $mododebug 0-Não 1-Sim e 2-nada (2 default)
75
     */
76
    public function __construct(
77
        $xmlfile = '',
78
        $sOrientacao = '',
79
        $sPapel = '',
80
        $sPathLogo = '',
81
        $sDestino = 'I',
82
        $sDirPDF = '',
83
        $fontePDF = '',
84
        $mododebug = 2
85
    ) {
86
        //define o caminho base da instalação do sistema
87
        if (!defined('PATH_ROOT')) {
88
            define('PATH_ROOT', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR);
89
        }
90
        //ajuste do tempo limite de resposta do processo
91
        set_time_limit(1800);
92
        //definição do caminho para o diretorio com as fontes do FDPF
93
        if (!defined('FPDF_FONTPATH')) {
94
            define('FPDF_FONTPATH', 'font/');
95
        }
96
97
        if (is_numeric($mododebug)) {
98
            $this->debugMode = $mododebug;
0 ignored issues
show
Documentation Bug introduced by
It seems like $mododebug can also be of type double or string. However, the property $debugMode is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
99
        }
100
        if ($this->debugMode) {
101
            //ativar modo debug
102
            error_reporting(E_ALL);
103
            ini_set('display_errors', 'On');
104
        } else {
105
            //desativar modo debug
106
            error_reporting(0);
107
            ini_set('display_errors', 'Off');
108
        }
109
        $this->orientacao = $sOrientacao;
110
        $this->papel = $sPapel;
111
        $this->pdf = '';
112
        $this->xml = $xmlfile;
113
        $this->logomarca = $sPathLogo;
114
        $this->destino = $sDestino;
115
        $this->pdfDir = $sDirPDF;
116
        // verifica se foi passa a fonte a ser usada
117
        if (empty($fontePDF)) {
118
            $this->fontePadrao = 'Times';
119
        } else {
120
            $this->fontePadrao = $fontePDF;
121
        }
122
        //se for passado o xml
123
        if (empty($xmlfile)) {
124
            $this->errMsg = 'Um caminho para o arquivo xml da MDFe deve ser passado!';
125
            $this->errStatus = true;
126
        }
127
        if (!is_file($xmlfile)) {
128
            $this->errMsg = 'Um caminho para o arquivo xml da MDFe deve ser passado!';
129
            $this->errStatus = true;
130
        }
131
132
        $this->dom = new Dom();
133
        $this->dom->loadXML($this->xml);
134
        $this->mdfeProc = $this->dom->getElementsByTagName("mdfeProc")->item(0);
0 ignored issues
show
Bug introduced by
The property mdfeProc does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
135
        $this->infMDFe = $this->dom->getElementsByTagName("infMDFe")->item(0);
0 ignored issues
show
Bug introduced by
The property infMDFe does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
136
        $this->emit = $this->dom->getElementsByTagName("emit")->item(0);
0 ignored issues
show
Bug introduced by
The property emit does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
137
        if ($this->dom->getElementsByTagName("CPF")->item(0)) {
138
            $this->CPF = $this->dom->getElementsByTagName("CPF")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property CPF does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
139
        } else {
140
            $this->CNPJ = $this->dom->getElementsByTagName("CNPJ")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property CNPJ does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
141
        }
142
        $this->IE = $this->dom->getElementsByTagName("IE")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property IE does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
143
        $this->xNome = $this->dom->getElementsByTagName("xNome")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property xNome does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
144
        $this->enderEmit = $this->dom->getElementsByTagName("enderEmit")->item(0);
0 ignored issues
show
Bug introduced by
The property enderEmit does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
145
        $this->xLgr = $this->dom->getElementsByTagName("xLgr")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property xLgr does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
146
        $this->nro = $this->dom->getElementsByTagName("nro")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property nro does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
147
        $this->xBairro = $this->dom->getElementsByTagName("xBairro")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property xBairro does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
148
        $this->UF = $this->dom->getElementsByTagName("UF")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property UF does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
149
        $this->xMun = $this->dom->getElementsByTagName("xMun")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property xMun does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
150
        $this->CEP = $this->dom->getElementsByTagName("CEP")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property CEP does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
151
        $this->ide = $this->dom->getElementsByTagName("ide")->item(0);
0 ignored issues
show
Bug introduced by
The property ide does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
152
        $this->tpAmb = $this->dom->getElementsByTagName("tpAmb")->item(0)->nodeValue;
153
        $this->mod = $this->dom->getElementsByTagName("mod")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property mod does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
154
        $this->serie = $this->dom->getElementsByTagName("serie")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property serie does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
155
        $this->dhEmi = $this->dom->getElementsByTagName("dhEmi")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property dhEmi does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
156
        $this->UFIni = $this->dom->getElementsByTagName("UFIni")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property UFIni does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
157
        $this->UFFim = $this->dom->getElementsByTagName("UFFim")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property UFFim does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
158
        $this->nMDF = $this->dom->getElementsByTagName("nMDF")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property nMDF does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
159
        $this->tpEmis = $this->dom->getElementsByTagName("tpEmis")->item(0)->nodeValue;
160
        $this->tot = $this->dom->getElementsByTagName("tot")->item(0);
0 ignored issues
show
Bug introduced by
The property tot does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
161
        $this->qNFe = "";
0 ignored issues
show
Bug introduced by
The property qNFe does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
162
        if ($this->dom->getElementsByTagName("qNFe")->item(0) != "") {
163
            $this->qNFe = $this->dom->getElementsByTagName("qNFe")->item(0)->nodeValue;
164
        }
165
        $this->qNF = "";
0 ignored issues
show
Bug introduced by
The property qNF does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
166
        if ($this->dom->getElementsByTagName("qNF")->item(0) != "") {
167
            $this->qNF = $this->dom->getElementsByTagName("qNF")->item(0)->nodeValue;
168
        }
169
        $this->qCTe = "";
0 ignored issues
show
Bug introduced by
The property qCTe does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
170
        if ($this->dom->getElementsByTagName("qCTe")->item(0) != "") {
171
            $this->qCTe = $this->dom->getElementsByTagName("qCTe")->item(0)->nodeValue;
172
        }
173
        $this->qCT = "";
0 ignored issues
show
Bug introduced by
The property qCT does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
174
        if ($this->dom->getElementsByTagName("qCT")->item(0) != "") {
175
            $this->qCT = $this->dom->getElementsByTagName("qCT")->item(0)->nodeValue;
176
        }
177
        $this->qCarga = $this->dom->getElementsByTagName("qCarga")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property qCarga does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
178
        $this->infModal = $this->dom->getElementsByTagName("infModal")->item(0);
0 ignored issues
show
Bug introduced by
The property infModal does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
179
        $this->rodo = $this->dom->getElementsByTagName("rodo")->item(0);
0 ignored issues
show
Bug introduced by
The property rodo does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
180
        $this->ciot = "";
0 ignored issues
show
Bug introduced by
The property ciot does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
181
        if ($this->dom->getElementsByTagName('CIOT')->item(0) != "") {
182
            $this->ciot = $this->dom->getElementsByTagName('CIOT')->item(0)->nodeValue;
183
        }
184
        $this->veicTracao = $this->dom->getElementsByTagName("veicTracao")->item(0);
0 ignored issues
show
Bug introduced by
The property veicTracao does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
185
        $this->veicReboque = $this->dom->getElementsByTagName("veicReboque");
0 ignored issues
show
Bug introduced by
The property veicReboque does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
186
        $this->valePed = "";
0 ignored issues
show
Bug introduced by
The property valePed does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
187
        if ($this->dom->getElementsByTagName("valePed")->item(0) != "") {
188
            $this->valePed = $this->dom->getElementsByTagName("valePed")->item(0)->getElementsByTagName("disp");
189
        }
190
        $this->infCpl = ($infCpl = $this->dom->getElementsByTagName('infCpl')->item(0)) ? $infCpl->nodeValue : "";
0 ignored issues
show
Bug introduced by
The property infCpl does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
191
        $this->chMDFe = str_replace(
192
            'MDFe',
193
            '',
194
            $this->infMDFe->getAttribute("Id")
195
        );
196
        $this->qrCodMDFe = $this->dom->getElementsByTagName('qrCodMDFe')->item(0) ?
197
            $this->dom->getElementsByTagName('qrCodMDFe')->item(0)->nodeValue : null;
198
        if (is_object($this->mdfeProc)) {
199
            $this->nProt = !empty($this->mdfeProc->getElementsByTagName("nProt")->item(0)->nodeValue) ?
200
                $this->mdfeProc->getElementsByTagName("nProt")->item(0)->nodeValue : '';
201
            $this->dhRecbto = $this->mdfeProc->getElementsByTagName("dhRecbto")->item(0)->nodeValue;
0 ignored issues
show
Bug introduced by
The property dhRecbto does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
202
        }
203
    }//fim construct
204
205
    /**
206
     *buildMDFe
207
     *
208
     */
209
    public function buildMDFe()
210
    {
211
        $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
212
        if ($this->orientacao == 'P') {
213
            // margens do PDF
214
            $margSup = 7;
215
            $margEsq = 7;
216
            $margDir = 7;
217
            // posição inicial do relatorio
218
            $xInic = 7;
219
            $yInic = 7;
220
            if ($this->papel == 'A4') { //A4 210x297mm
221
                $maxW = 210;
222
                $maxH = 297;
223
            }
224
        } else {
225
            // margens do PDF
226
            $margSup = 7;
227
            $margEsq = 7;
228
            $margDir = 7;
229
            // posição inicial do relatorio
230
            $xInic = 7;
231
            $yInic = 7;
232
            if ($this->papel == 'A4') { //A4 210x297mm
233
                $maxH = 210;
234
                $maxW = 297;
235
            }
236
        }//orientação
237
        //largura imprimivel em mm
238
        $this->wPrint = $maxW - ($margEsq + $xInic);
0 ignored issues
show
Bug introduced by
The variable $maxW does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
239
        //comprimento imprimivel em mm
240
        $this->hPrint = $maxH - ($margSup + $yInic);
0 ignored issues
show
Bug introduced by
The variable $maxH does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
241
        // estabelece contagem de paginas
242
        $this->pdf->AliasNbPages();
243
        // fixa as margens
244
        $this->pdf->SetMargins($margEsq, $margSup, $margDir);
245
        $this->pdf->SetDrawColor(0, 0, 0);
246
        $this->pdf->SetFillColor(255, 255, 255);
247
        // inicia o documento
248
        $this->pdf->Open();
249
        // adiciona a primeira página
250
        $this->pdf->AddPage($this->orientacao, $this->papel);
251
        $this->pdf->SetLineWidth(0.1);
252
        $this->pdf->SetTextColor(0, 0, 0);
253
        //montagem da página
254
        $pag = 1;
255
        $x = $xInic;
256
        $y = $yInic;
257
        //coloca o cabeçalho Paisagem
258
        if ($this->orientacao == 'P') {
259
            $y = $this->headerMDFeRetrato($x, $y, $pag);
260
        } else {
261
            $y = $this->headerMDFePaisagem($x, $y, $pag);
262
        }
263
        //coloca os dados da MDFe
264
        $y = $this->bodyMDFe($x, $y);
265
        //coloca os dados da MDFe
266
        $y = $this->footerMDFe($x, $y);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->footerMDFe($x, $y) (which targets NFePHP\DA\MDFe\Damdfe::footerMDFe()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Unused Code introduced by
$y 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...
267
    } //fim buildCCe
268
269
    /**
270
     * headerMDFePaisagem
271
     * @param float $x
272
     * @param float $y
273
     * @param integer $pag
274
     * @return string
275
     */
276
    private function headerMDFePaisagem($x, $y, $pag)
0 ignored issues
show
Unused Code introduced by
The parameter $pag is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
277
    {
278
        $oldX = $x;
0 ignored issues
show
Unused Code introduced by
$oldX 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...
279
        $oldY = $y;
280
        $maxW = $this->wPrint;
281
        //####################################################################################
282
        //coluna esquerda identificação do emitente
283
        //$w = $maxW; //round($maxW*0.41, 0);// 80;
284
        $w = round($maxW * 0.70, 0);
285
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B');
0 ignored issues
show
Unused Code introduced by
$aFont 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...
286
        $w1 = $w;
0 ignored issues
show
Unused Code introduced by
$w1 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...
287
        $h = 30;
288
        $oldY += $h;
289
        $this->pTextBox($x, $y, $w, $h);
290
        if (is_file($this->logomarca)) {
291
            $logoInfo = getimagesize($this->logomarca);
292
            //largura da imagem em mm
293
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
294
            //altura da imagem em mm
295
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
296
            if ($this->logoAlign == 'L') {
297
                $nImgW = round($w / 3, 0);
298
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
299
                $xImg = $x + 1;
300
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
301
                //estabelecer posições do texto
302
                $x1 = round($xImg + $nImgW + 1, 0);
303
                $y1 = round($y + 2, 0);
304
                $tw = round(2 * $w / 3, 0);
305
            }
306
            if ($this->logoAlign == 'C') {
307
                $nImgH = round($h / 3, 0);
308
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
309
                $xImg = round(($w - $nImgW) / 2 + $x, 0);
310
                $yImg = $y + 3;
311
                $x1 = $x;
312
                $y1 = round($yImg + $nImgH + 1, 0);
313
                $tw = $w;
314
            }
315
            if ($this->logoAlign == 'R') {
316
                $nImgW = round($w / 3, 0);
317
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
318
                $xImg = round($x + ($w - (1 + $nImgW)), 0);
319
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
320
                $x1 = $x;
321
                $y1 = round($h / 3 + $y, 0);
322
                $tw = round(2 * $w / 3, 0);
323
            }
324
            $this->pdf->Image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg');
0 ignored issues
show
Bug introduced by
The variable $xImg does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
Bug introduced by
The variable $yImg does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
Bug introduced by
The variable $nImgW does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
Bug introduced by
The variable $nImgH does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
325
        } else {
326
            $x1 = $x;
327
            $y1 = round($h / 3 + $y, 0);
328
            $tw = $w;
329
        }
330
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
0 ignored issues
show
Unused Code introduced by
$aFont 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...
331
        $razao = $this->xNome;
0 ignored issues
show
Unused Code introduced by
$razao 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...
332
        if (isset($this->CPF)) {
333
            $cpfcnpj = 'CPF: ' . $this->pFormat($this->CPF, "###.###.###-##");
334
        } else {
335
            $cpfcnpj = 'CNPJ: ' . $this->pFormat($this->CNPJ, "###.###.###/####-##");
336
        }
337
        $ie = 'IE: ' . $this->pFormat($this->IE, '##/########');
338
        $lgr = 'Logradouro: ' . $this->xLgr;
339
        $nro = 'Nº: ' . $this->nro;
340
        $bairro = 'Bairro: ' . $this->xBairro;
341
        $CEP = $this->CEP;
342
        $CEP = 'CEP: ' . $this->pFormat($CEP, "##.###-###");
343
        $UF = 'UF: ' . $this->UF;
344
        $mun = 'Municipio: ' . $this->xMun;
345
346
        $texto = $cpfcnpj . ' - ' . $ie . "\n";
347
        $texto .= $lgr . ' - ' . $nro . "\n";
348
        $texto .= $bairro . "\n";
349
        $texto .= $UF . ' - ' . $mun . ' - ' . $CEP;
350
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
351
        $this->pTextBox($x1, $y1 + 6, $tw, 8, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Bug introduced by
The variable $x1 does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
Bug introduced by
The variable $y1 does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
Bug introduced by
The variable $tw does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
352
        //##################################################
353
        $w = round($maxW * 0.70, 0);
354
        $y = $h + 9;
355
        $this->pTextBox($x, $y, $w, 6);
356
        $aFont = array('font' => $this->fontePadrao, 'size' => 12, 'style' => 'I');
357
        $this->pTextBox(
358
            $x,
359
            $y,
360
            $w,
361
            8,
362
            'DAMDFE - Documento Auxiliar de Manifesto Eletronico de Documentos Fiscais',
363
            $aFont,
364
            'T',
365
            'C',
366
            0,
367
            ''
368
        );
369
370
        if ($this->tpAmb != 1) {
371
            $x = 10;
372
            if ($this->orientacao == 'P') {
373
                $yy = round($this->hPrint * 2 / 3, 0);
374
            } else {
375
                $yy = round($this->hPrint / 2, 0);
376
            }
377
            $h = 5;
378
            $w = $maxW - (2 * $x);
379
            $this->pdf->SetTextColor(90, 90, 90);
380
            $texto = "SEM VALOR FISCAL";
381
            $aFont = array('font' => $this->fontePadrao, 'size' => 48, 'style' => 'B');
382
            $this->pTextBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
383
            $aFont = array('font' => $this->fontePadrao, 'size' => 30, 'style' => 'B');
384
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
385
            $this->pTextBox($x, $yy + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
386
            $this->pdf->SetTextColor(0, 0, 0);
387
        } else {
388
            $x = 10;
389
            if ($this->orientacao == 'P') {
390
                $yy = round($this->hPrint * 2 / 3, 0);
391
            } else {
392
                $yy = round($this->hPrint / 2, 0);
393
            }//fim orientacao
394
            $h = 5;
395
            $w = $maxW - (2 * $x);
396
            $this->pdf->SetTextColor(90, 90, 90);
397
            //indicar FALTA DO PROTOCOLO se MDFe não for em contingência
398
            if (($this->tpEmis == 2 || $this->tpEmis == 5)) {
399
                //Contingência
400
                $texto = "DAMDFE Emitido em Contingência";
401
                $aFont = array('font' => $this->fontePadrao, 'size' => 48, 'style' => 'B');
402
                $this->pTextBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
403
                $aFont = array('font' => $this->fontePadrao, 'size' => 30, 'style' => 'B');
404
                $texto = "devido à problemas técnicos";
405
                $this->pTextBox($x, $yy + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
406
            }
407
            $this->pdf->SetTextColor(0, 0, 0);
408
        }
409
        return $y + 8;
410
    }// fim headerMDFe
411
412
    /**
413
     * headerMDFeRetrato
414
     *
415
     * @param float $x
416
     * @param float $y
417
     * @param integer $pag
418
     * @return string
419
     */
420
    private function headerMDFeRetrato($x, $y, $pag)
0 ignored issues
show
Unused Code introduced by
The parameter $pag is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
421
    {
422
        $oldX = $x;
0 ignored issues
show
Unused Code introduced by
$oldX 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...
423
        $oldY = $y;
424
        $maxW = $this->wPrint;
425
        //####################################################################################
426
        //coluna esquerda identificação do emitente
427
        //$w = $maxW; //round($maxW*0.41, 0);// 80;
428
        $w = round($maxW * 0.70, 0);
429
        $aFont = array('font' => $this->fontePadrao, 'size' => 6, 'style' => 'I');
0 ignored issues
show
Unused Code introduced by
$aFont 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...
430
        $w1 = $w;
0 ignored issues
show
Unused Code introduced by
$w1 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...
431
        $h = 20;
432
        $oldY += $h;
433
        $this->pTextBox($x, $y, $w, $h);
434
        if (is_file($this->logomarca)) {
435
            $logoInfo = getimagesize($this->logomarca);
436
            //largura da imagem em mm
437
            $logoWmm = ($logoInfo[0] / 72) * 25.4;
438
            //altura da imagem em mm
439
            $logoHmm = ($logoInfo[1] / 72) * 25.4;
440
            if ($this->logoAlign == 'L') {
441
                // ajusta a dimensão do logo
442
                $nImgW = round($w / 3, 0);
443
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
444
                $xImg = $x + 1;
445
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
446
                //estabelecer posições do texto
447
                $x1 = round($xImg + $nImgW + 1, 0);
448
                $y1 = round($y + 2, 0);
449
                $tw = round(2 * $w / 3, 0);
450
            }
451
            if ($this->logoAlign == 'C') {
452
                $nImgH = round($h / 3, 0);
453
                $nImgW = round($logoWmm * ($nImgH / $logoHmm), 0);
454
                $xImg = round(($w - $nImgW) / 2 + $x, 0);
455
                $yImg = $y + 3;
456
                $x1 = $x;
457
                $y1 = round($yImg + $nImgH + 1, 0);
458
                $tw = $w;
459
            }
460
            if ($this->logoAlign == 'R') {
461
                $nImgW = round($w / 3, 0);
462
                $nImgH = round($logoHmm * ($nImgW / $logoWmm), 0);
463
                $xImg = round($x + ($w - (1 + $nImgW)), 0);
464
                $yImg = round(($h - $nImgH) / 2, 0) + $y;
465
                $x1 = $x;
466
                $y1 = round($h / 3 + $y, 0);
467
                $tw = round(2 * $w / 3, 0);
468
            }
469
            $this->pdf->Image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg');
0 ignored issues
show
Bug introduced by
The variable $xImg does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
Bug introduced by
The variable $yImg does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
Bug introduced by
The variable $nImgW does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
Bug introduced by
The variable $nImgH does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
470
        } else {
471
            $x1 = $x;
472
            $y1 = $y;
473
            $tw = $w;
474
        }
475
476
        if ($this->qrCodMDFe !== null) {
477
            $this->pQRDAMDFE($y - 3);
478
        }
479
480
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B');
481
        $texto = $this->xNome;
482
        $this->pTextBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Bug introduced by
The variable $x1 does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
Bug introduced by
The variable $y1 does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
Bug introduced by
The variable $tw does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
483
        if (isset($this->CPF)) {
484
            $cpfcnpj = 'CPF: ' . $this->pFormat($this->CPF, "###.###.###-##");
485
        } else {
486
            $cpfcnpj = 'CNPJ: ' . $this->pFormat($this->CNPJ, "###.###.###/####-##");
487
        }
488
        $ie = 'IE: ' . $this->pFormat($this->IE, '###/#######');
489
        $lgr = 'Logradouro: ' . $this->xLgr;
490
        $nro = 'Nº: ' . $this->nro;
491
        $bairro = 'Bairro: ' . $this->xBairro;
492
        $CEP = $this->CEP;
493
        $CEP = 'CEP: ' . $this->pFormat($CEP, "##.###-###");
494
        $mun = 'Municipio: ' . $this->xMun;
495
        $UF = 'UF: ' . $this->UF;
496
        $texto = $cpfcnpj . ' - ' . $ie . "\n";
497
        $texto .= $lgr . ' - ' . $nro . "\n";
498
        $texto .= $bairro . "\n";
499
        $texto .= $UF . ' - ' . $mun . ' - ' . $CEP;
500
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
501
        $this->pTextBox($x1, $y1 + 4, $tw, 8, $texto, $aFont, 'T', 'L', 0, '');
502
        //##################################################
503
        $w = round($maxW * 0.70, 0);
504
        $y = $h + 9;
505
        $this->pTextBox($x, $y, $w, 6);
506
        $aFont = array('font' => $this->fontePadrao, 'size' => 12, 'style' => 'I');
507
        $this->pTextBox(
508
            $x,
509
            $y,
510
            $w,
511
            8,
512
            'DAMDFE - Documento Auxiliar de Manifesto Eletronico de Documentos Fiscais',
513
            $aFont,
514
            'T',
515
            'C',
516
            0,
517
            ''
518
        );
519
        if ($this->tpAmb != 1) {
520
            $x = 10;
521
            if ($this->orientacao == 'P') {
522
                $yy = round($this->hPrint * 2 / 3, 0);
523
            } else {
524
                $yy = round($this->hPrint / 2, 0);
525
            }
526
            $h = 5;
527
            $w = $maxW - (2 * $x);
528
            $this->pdf->SetTextColor(90, 90, 90);
529
            $texto = "SEM VALOR FISCAL";
530
            $aFont = array('font' => $this->fontePadrao, 'size' => 48, 'style' => 'B');
531
            $this->pTextBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
532
            $aFont = array('font' => $this->fontePadrao, 'size' => 30, 'style' => 'B');
533
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
534
            $this->pTextBox($x, $yy + 14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
535
            $this->pdf->SetTextColor(0, 0, 0);
536
        } else {
537
            $x = 10;
538
            if ($this->orientacao == 'P') {
539
                $yy = round($this->hPrint * 2 / 3, 0);
540
            } else {
541
                $yy = round($this->hPrint / 2, 0);
542
            }//fim orientacao
543
            $h = 5;
544
            $w = $maxW - (2 * $x);
545
            $this->pdf->SetTextColor(90, 90, 90);
546
            //indicar FALTA DO PROTOCOLO se MDFe não for em contingência
547
            if (($this->tpEmis == 2 || $this->tpEmis == 5)) {
548
                //Contingência
549
                $texto = "DAMDFE Emitido em Contingência";
550
                $aFont = array('font' => $this->fontePadrao, 'size' => 48, 'style' => 'B');
551
                $this->pTextBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
552
                $aFont = array('font' => $this->fontePadrao, 'size' => 30, 'style' => 'B');
553
                $texto = "devido à problemas técnicos";
554
                $this->pTextBox($x, $yy + 12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
555
            }
556
            $this->pdf->SetTextColor(0, 0, 0);
557
        }
558
        return $y + 8;
559
    }// fim headerMDFe
560
561
    /**
562
     * bodyMDFe
563
     *
564
     * @param float $x
565
     * @param float $y
566
     * @return void
567
     */
568
    private function bodyMDFe($x, $y)
569
    {
570
        if ($this->orientacao == 'P') {
571
            $maxW = $this->wPrint;
572
        } else {
573
            //$maxW = $this->wPrint / 2;
574
            $maxW = $this->wPrint * 0.9;
575
        }
576
        $x2 = ($maxW / 6);
577
        $x1 = $x2;
578
        $this->pTextBox($x, $y, $x2 - 22, 12);
579
        $texto = 'Modelo';
580
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
581
        $this->pTextBox($x, $y, $x2 - 22, 8, $texto, $aFont, 'T', 'C', 0, '', false);
582
        $texto = $this->mod;
583
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
584
        $this->pTextBox($x, $y + 4, $x2 - 22, 8, $texto, $aFont, 'T', 'C', 0, '', false);
585
586
        if ($this->orientacao == 'P') {
587
            $x1 += $x2 - 47.5;
588
        } else {
589
            $x1 += $x2 - 57.5;
590
        }
591
        $this->pTextBox($x1, $y, $x2 - 22, 12);
592
        $texto = 'Série';
593
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
594
        $this->pTextBox($x1, $y, $x2 - 22, 8, $texto, $aFont, 'T', 'C', 0, '', false);
595
        $texto = $this->serie;
596
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
597
        $this->pTextBox($x1, $y + 4, $x2 - 22, 10, $texto, $aFont, 'T', 'C', 0, '', false);
598
599
        $x1 += $x2 - 22;
600
        $this->pTextBox($x1, $y, $x2 - 5, 12);
601
        $texto = 'Número';
602
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
603
        $this->pTextBox($x1, $y, $x2 - 5, 8, $texto, $aFont, 'T', 'C', 0, '', false);
604
        $texto = $this->pFormat(str_pad($this->nMDF, 9, '0', STR_PAD_LEFT), '###.###.###');
605
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
606
        $this->pTextBox($x1, $y + 4, $x2 - 5, 10, $texto, $aFont, 'T', 'C', 0, '', false);
607
        $x1 += $x2 - 5;
608
        $this->pTextBox($x1, $y, $x2 - 22, 12);
609
        $texto = 'FL';
610
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
611
        $this->pTextBox($x1, $y, $x2 - 22, 8, $texto, $aFont, 'T', 'C', 0, '', false);
612
        $texto = '1';
613
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
614
        $this->pTextBox($x1, $y + 4, $x2 - 22, 10, $texto, $aFont, 'T', 'C', 0, '', false);
615
        $x1 += $x2 - 22;
616
        if ($this->orientacao == 'P') {
617
            $x3 = $x2 + 10.5;
618
        } else {
619
            $x3 = $x2 + 3;
620
        }
621
        $this->pTextBox($x1, $y, $x3, 12);
622
        $texto = 'Data e Hora de Emissão';
623
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
624
        $this->pTextBox($x1, $y, $x3, 8, $texto, $aFont, 'T', 'C', 0, '', false);
625
        $data = explode('T', $this->dhEmi);
626
        $texto = $this->pYmd2dmy($data[0]) . ' - ' . $data[1];
627
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B');
628
        $this->pTextBox($x1, $y + 4, $x3, 10, $texto, $aFont, 'T', 'C', 0, '', false);
629
        $x1 += $x3;
630
631
        $this->pTextBox($x1, $y, $x2 - 15, 12);
632
        $texto = 'UF Carreg.';
633
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
634
        $this->pTextBox($x1, $y, $x2 - 15, 8, $texto, $aFont, 'T', 'C', 0, '', false);
635
        $texto = $this->UFIni;
636
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
637
        $this->pTextBox($x1, $y + 4, $x2 - 15, 10, $texto, $aFont, 'T', 'C', 0, '', false);
638
        $maxW = $this->wPrint;
0 ignored issues
show
Unused Code introduced by
$maxW 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...
639
640
        $x1 += $x2 - 15;
641
        $this->pTextBox($x1, $y, $x2 - 16, 12);
642
        $texto = 'UF Descar.';
643
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
644
        $this->pTextBox($x1, $y, $x2 - 16, 8, $texto, $aFont, 'T', 'C', 0, '', false);
645
        $texto = $this->UFFim;
646
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
647
        $this->pTextBox($x1, $y + 4, $x2 - 16, 10, $texto, $aFont, 'T', 'C', 0, '', false);
648
        $maxW = $this->wPrint;
649
650
        $x1 = $x;
651
        $x2 = $maxW;
652
        $y += 14;
653
        $this->pTextBox($x1, $y, $x2, 43);
654
        $texto = 'Modal Rodoviário de Carga';
655
        $aFont = array('font' => $this->fontePadrao, 'size' => 12, 'style' => 'B');
656
        $this->pTextBox($x1, $y + 1, $x2 / 2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
657
        $texto = 'CONTROLE DO FISCO';
658
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
659
        $this->pTextBox($x1 + ($x2 / 2), $y + 1, $x2 / 2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
660
661
        $x1 = $x;
662
        $x2 = ($maxW / 6);
663
        $y += 6;
664
        $this->pTextBox($x1, $y, $x2, 12);
665
        $texto = 'Qtd. CT-e';
666
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
667
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
668
        $texto = str_pad($this->qCTe, 3, '0', STR_PAD_LEFT);
669
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
670
        $this->pTextBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
671
        $x1 += $x2;
672
        $this->pTextBox($x1, $y, $x2, 12);
673
        $texto = 'Qtd. NF-e';
674
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
675
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
676
        $texto = str_pad($this->qNFe, 3, '0', STR_PAD_LEFT);
677
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
678
        $this->pTextBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
679
        $x1 += $x2;
680
        $this->pTextBox($x1, $y, $x2, 12);
681
        $texto = 'Peso Total (Kg)';
682
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
683
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
684
        $texto = number_format($this->qCarga, 4, ',', '.');
685
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
686
        $this->pTextBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
687
688
        // codigo de barras da chave
689
        $x1 += $x2;
690
        //$y = $y + 8;
691
        $this->pTextBox($x1, $y, $maxW / 2, 20);
692
        $bH = 16;
693
        $w = $maxW;
0 ignored issues
show
Unused Code introduced by
$w 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...
694
        $this->pdf->SetFillColor(0, 0, 0);
695
        $this->pdf->Code128($x1 + 5, $y + 2, $this->chMDFe, ($maxW / 2) - 10, $bH);
696
        $this->pdf->SetFillColor(255, 255, 255);
697
698
        // protocolo de autorização
699
        $y = $y + 20;
700
        $this->pTextBox($x, $y, $maxW / 2, 10);
701
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'I');
702
        $texto = 'Protocolo de Autorização';
703
        $this->pTextBox($x, $y, $maxW / 2, 8, $texto, $aFont, 'T', 'L', 0, '');
704
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
705
        if (is_object($this->mdfeProc)) {
706
            $tsHora = $this->pConvertTime($this->dhRecbto);
707
            $texto = $this->nProt . ' - ' . date('d/m/Y   H:i:s', $tsHora);
708
        } else {
709
            $texto = 'DAMDFE impresso em contingência - ' . date('d/m/Y   H:i:s');
710
        }
711
        $this->pTextBox($x, $y + 4, $maxW / 2, 8, $texto, $aFont, 'T', 'C', 0, '');
712
713
        // chave de acesso
714
        $this->pTextBox($x + $maxW / 2, $y, $maxW / 2, 17);
715
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'I');
716
        $tsHora = $this->pConvertTime($this->dhEvento);
0 ignored issues
show
Unused Code introduced by
$tsHora 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...
717
        $texto = 'Chave de Acesso';
718
        $this->pTextBox($x + $maxW / 2, $y, $maxW / 2, 6, $texto, $aFont, 'T', 'L', 0, '');
719
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
720
        $texto = $this->pFormat($this->chMDFe, $this->formatoChave);
721
        $this->pTextBox($x + $maxW / 2, $y + 4, $maxW / 2, 6, $texto, $aFont, 'T', 'C', 0, '');
722
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => 'B');
723
        $texto = 'Consulte em https://dfe-portal.sefazvirtual.rs.gov.br/MDFe/consulta';
724
        $this->pTextBox($x + $maxW / 2, $y + 10, $maxW / 2, 6, $texto, $aFont, 'T', 'C', 0, '');
725
726
        $x1 = $x;
727
        $y += 20;
728
        $yold = $y;
729
        $x2 = round($maxW / 2, 0);
730
        $texto = 'Veículo';
731
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
732
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
733
        $y += 5;
734
        $x2 = round($maxW / 4, 0);
735
        $tamanho = 22;
736
        $this->pTextBox($x1, $y, $x2, $tamanho);
737
        $texto = 'Placa';
738
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
739
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
740
        $texto = $this->veicTracao->getElementsByTagName("placa")->item(0)->nodeValue;
741
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
742
        $this->pTextBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
743
        $altura = $y + 4;
744
        /** @var \DOMNodeList $veicReboque */
745
        $veicReboque = $this->veicReboque;
746
        foreach ($veicReboque as $item) {
747
            /** @var \DOMElement $item */
748
            $altura += 4;
749
            $texto = $item->getElementsByTagName('placa')->item(0)->nodeValue;
750
            $this->pTextBox($x1, $altura, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
751
        }
752
        $x1 += $x2;
753
        $this->pTextBox($x1, $y, $x2, $tamanho);
754
        $texto = 'RNTRC';
755
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
756
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
757
        // RNTRC Não informado
758
        if ($this->rodo->getElementsByTagName("RNTRC")->length > 0) {
759
            $texto = $this->rodo->getElementsByTagName("RNTRC")->item(0)->nodeValue;
760
        } else {
761
            $texto = "";
762
        }
763
        $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
764
        $this->pTextBox($x1, $y + 4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
765
        $altura = $y + 4;
766
        /** @var \DOMNodeList $veicReboque */
767
        $veicReboque = $this->veicReboque;
768
        foreach ($veicReboque as $item) {
769
            /** @var \DOMElement $item */
770
            $DOMNodeList = $item->getElementsByTagName('RNTRC');
771
            if ($DOMNodeList->length > 0) {
772
                $altura += 4;
773
                $texto = $DOMNodeList->item(0)->nodeValue;
774
                $this->pTextBox($x1, $altura, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
775
            }
776
        }
777
        $x1 = $x;
778
        $y += 22;
779
        $x2 = round($maxW / 2, 0);
780
        $valesPedagios = 1;
781
        $temVales = false;
782
        if ($this->valePed != "" && $this->valePed->length > 0) {
783
            $valesPedagios = $this->valePed->length;
784
            $temVales = true;
785
        }
786
        $tamanho = ($valesPedagios * 7.5);
787
        if (!$temVales) {
788
            $valesPedagios = 0;
789
        }
790
        $this->pTextBox($x1, $y, $x2, 11 + $tamanho / 2);
791
        $texto = 'Vale Pedágio';
792
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
793
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
794
        $y += 5;
795
        $x2 = ($x2 / 3);
796
        $this->pTextBox($x1, $y, $x2 - 3, 6 + ($tamanho / 2));
797
        $texto = 'Responsável CNPJ';
798
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
799
        $this->pTextBox($x1, $y, $x2 - 4, 8, $texto, $aFont, 'T', 'L', 0, '', false);
800
        $altura = $y;
801
        for ($i = 0; $i < $valesPedagios; $i++) {
802
            $altura += 4;
803
            $texto = $this->valePed->item($i)->getElementsByTagName('CNPJForn')->item(0)->nodeValue;
804
            $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
805
            $this->pTextBox($x1 + 1, $altura, $x2 - 5, 10, $texto, $aFont, 'T', 'L', 0, '', false);
806
        }
807
        $x1 += $x2 - 3;
808
        $this->pTextBox($x1, $y, $x2 - 3, 6 + ($tamanho / 2));
809
        $texto = 'Fornecedora CNPJ';
810
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
811
        $this->pTextBox($x1, $y, $x2 - 4, 8, $texto, $aFont, 'T', 'L', 0, '', false);
812
        $altura = $y;
813
        for ($i = 0; $i < $valesPedagios; $i++) {
814
            $altura += 4;
815
            $texto = $this->valePed->item($i)->getElementsByTagName('CNPJPg')->item(0)->nodeValue;
816
            $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
817
            $this->pTextBox($x1 + 1, $altura, $x2 - 5, 10, $texto, $aFont, 'T', 'L', 0, '', false);
818
        }
819
        $x1 += $x2 - 3;
820
        $this->pTextBox($x1, $y, $x2 + 6, 6 + ($tamanho / 2));
821
        $texto = 'Nº Comprovante';
822
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
823
        $this->pTextBox($x1, $y, $x2 + 6, 8, $texto, $aFont, 'T', 'L', 0, '', false);
824
        $altura = $y;
825
        for ($i = 0; $i < $valesPedagios; $i++) {
826
            $altura += 4;
827
            $texto = $this->valePed->item($i)->getElementsByTagName('nCompra')->item(0)->nodeValue;
828
            $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
829
            $this->pTextBox($x1 + 1, $altura, $x2 + 5, 10, $texto, $aFont, 'T', 'L', 0, '', false);
830
        }
831
        if (!$temVales) {
832
            $altura += 4;
833
        }
834
        $this->condutor = $this->veicTracao->getElementsByTagName('condutor');
0 ignored issues
show
Bug introduced by
The property condutor does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
835
        $x1 = round($maxW / 2, 0) + 7;
836
        $y = $yold;
837
        $x2 = round($maxW / 2, 0);
838
        $texto = 'Condutor';
839
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
840
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
841
        $y += 5;
842
        $x2 = ($maxW / 6);
843
        $this->pTextBox($x1, $y, $x2, 33 + ($tamanho / 2));
844
        $texto = 'CPF';
845
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
846
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
847
        $yold = $y;
848
        for ($i = 0; $i < $this->condutor->length; $i++) {
849
            $y += 4;
850
            $texto = $this->condutor->item($i)->getElementsByTagName('CPF')->item(0)->nodeValue;
851
            $aFont = array('font' => $this->fontePadrao, 'size' => 10, 'style' => '');
852
            $this->pTextBox($x1 + 1, $y, $x2 - 1, 10, $texto, $aFont, 'T', 'L', 0, '', false);
853
        }
854
        $y = $yold;
855
        $x1 += $x2;
856
        $x2 = $x2*2;
857
        $this->pTextBox($x1, $y, $x2, 33 + ($tamanho / 2));
858
        $texto = 'Nome';
859
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
860
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
861
        for ($i = 0; $i < $this->condutor->length; $i++) {
862
            $y += 4;
863
            $texto = $this->condutor->item($i)->getElementsByTagName('xNome')->item(0)->nodeValue;
864
            $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
865
            $this->pTextBox($x1 + 1, $y, $x2 - 1, 8, $texto, $aFont, 'T', 'L', 0, '', false);
866
        }
867
        return $altura + 7;
868
    }
869
870
871
    protected function pQRDAMDFE($y = 0)
872
    {
873
        $margemInterna = $this->margemInterna;
874
        $barcode = new Barcode();
875
        $bobj = $barcode->getBarcodeObj(
876
            'QRCODE,M',
877
            $this->qrCodMDFe,
878
            -4,
879
            -4,
880
            'black',
881
            array(-2, -2, -2, -2)
882
        )->setBackgroundColor('white');
883
        $qrcode = $bobj->getPngData();
884
        $wQr = 35;
885
        $hQr = 35;
886
        $yQr = ($y + $margemInterna);
887
        if ($this->orientacao == 'P') {
888
            $xQr = 160;
889
        } else {
890
            $xQr = 235;
891
        }
892
        // prepare a base64 encoded "data url"
893
        $pic = 'data://text/plain;base64,' . base64_encode($qrcode);
894
        $this->pdf->image($pic, $xQr, $yQr, $wQr, $hQr, 'PNG');
895
    }
896
897
898
    /**
899
     * footerMDFe
900
     *
901
     * @param float $x
902
     * @param float $y
903
     */
904
    private function footerMDFe($x, $y)
905
    {
906
        $maxW = $this->wPrint;
907
        $x2 = $maxW;
908
        $this->pTextBox($x, $y, $x2, 30);
909
        $texto = 'Observação
910
        ' . $this->infCpl;
911
        $aFont = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
912
        $this->pTextBox($x, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
913
        $y = $this->hPrint - 4;
914
        $texto = "Impresso em  " . date('d/m/Y   H:i:s');
915
        $w = $this->wPrint - 4;
916
        $aFont = array('font' => $this->fontePadrao, 'size' => 6, 'style' => 'I');
917
        $this->pTextBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, '');
918
    }//fim footerCCe
919
920
    /**
921
     * printMDFe
922
     *
923
     * @param string $nome
924
     * @param string $destino
925
     * @param string $printer
926
     * @return string
927
     */
928
    public function printMDFe($nome = '', $destino = 'I', $printer = '')
929
    {
930
        //monta
931
        $command = '';
932
        if ($nome == '') {
933
            $file = $this->pdfDir . 'mdfe.pdf';
934
        } else {
935
            $file = $this->pdfDir . $nome;
936
        }
937
        if ($destino != 'I' && $destino != 'S' && $destino != 'F') {
938
            $destino = 'I';
939
        }
940
        if ($printer != '') {
941
            $command = "-P $printer";
942
        }
943
944
        $this->buildMDFe();
945
        $arq = $this->pdf->Output($file, $destino);
946
        if ($destino == 'S' && $command != '') {
947
            //aqui pode entrar a rotina de impressão direta
948
            $command = "lpr $command $file";
949
            system($command, $retorno);
950
        }
951
952
        return $arq;
953
    }//fim printMDFe
954
955
    /**
956
     * Dados brutos do PDF
957
     * @return string
958
     */
959
    public function render()
960
    {
961
        return $this->pdf->getPdf();
962
    }
963
}
964