Passed
Push — master ( e4694f...d048fd )
by Roberto
03:55
created

Danfce   D

Complexity

Total Complexity 112

Size/Duplication

Total Lines 1170
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 1170
ccs 0
cts 903
cp 0
rs 4.4102
c 0
b 0
f 0
wmc 112
lcom 1
cbo 4

22 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 57 7
A getPapel() 0 4 1
A setPapel() 0 4 1
A monta() 0 9 1
B pCabecalhoDANFE() 0 56 5
D montaDANFE() 0 134 9
A pCabecalhoSecundarioDANFE() 0 15 1
B pProdutosDANFE() 0 154 3
A pTotalDANFE() 0 48 1
B pPagamentosDANFE() 0 61 4
B pFiscalDANFE() 0 34 1
C pConsumidorDANFE() 0 70 10
B pQRDANFE() 0 30 2
A pInfAdic() 0 21 1
A printDANFE() 0 8 2
A render() 0 4 1
F pAnfavea() 0 137 36
A str2Hex() 0 13 3
B getCardName() 0 20 6
C tipoPag() 0 35 11
A hex2Str() 0 13 3
B makeQRCode() 0 37 3

How to fix   Complexity   

Complex Class

Complex classes like Danfce often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Danfce, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace NFePHP\DA\NFe;
4
5
/**
6
 * Classe para a impressão em PDF do Documento Auxiliar de NFe Consumidor
7
 * NOTA: Esta classe não é a indicada para quem faz uso de impressoras térmicas ESCPOS
8
 *
9
 * @category  Library
10
 * @package   nfephp-org/sped-da
11
 * @copyright 2009-2016 NFePHP
12
 * @license   http://www.gnu.org/licenses/lesser.html LGPL v3
13
 * @link      http://github.com/nfephp-org/sped-da for the canonical source repository
14
 * @author    Roberto Spadim <roberto at spadim dot com dot br>
15
 */
16
17
use Exception;
18
use NFePHP\DA\Legacy\Dom;
19
use NFePHP\DA\Legacy\Pdf;
20
use NFePHP\DA\Legacy\Common;
21
use Endroid\QrCode\QrCode;
22
use DateTime;
23
24
class Danfce extends Common
25
{
26
    protected $papel;
27
    protected $xml; // string XML NFe
28
    protected $logomarca=''; // path para logomarca em jpg
29
    protected $formatoChave="#### #### #### #### #### #### #### #### #### #### ####";
30
    protected $debugMode=0; //ativa ou desativa o modo de debug
31
    protected $tpImp; //ambiente
32
    protected $fontePadrao='Times';
33
    protected $nfeProc;
34
    protected $nfe;
35
    protected $infNFe;
36
    protected $ide;
37
    protected $enderDest;
38
    protected $ICMSTot;
39
    protected $imposto;
40
    protected $emit;
41
    protected $enderEmit;
42
    protected $qrCode;
43
    protected $det;
44
    protected $infAdic;
45
    protected $textoAdic;
46
    protected $pag;
47
    protected $dest;
48
    protected $imgQRCode;
49
    protected $urlQR = '';
50
    protected $pdf;
51
    protected $margemInterna = 2;
52
    protected $hMaxLinha = 9;
53
    protected $hBoxLinha = 6;
54
    protected $hLinha = 3;
55
56
    /*
57
     * Retorna a sigla da UF
58
     * @var string
59
     */
60
    protected $UFSigla = [
61
        '12' => 'AC',
62
        '27' => 'AL',
63
        '13' => 'AM',
64
        '16' => 'AP',
65
        '29' => 'BA',
66
        '23' => 'CE',
67
        '53' => 'DF',
68
        '32' => 'ES',
69
        '52' => 'GO',
70
        '31' => 'MG',
71
        '50' => 'MS',
72
        '51' => 'MT',
73
        '21' => 'MA',
74
        '15' => 'PA',
75
        '25' => 'PB',
76
        '26' => 'PE',
77
        '22' => 'PI',
78
        '41' => 'PR',
79
        '33' => 'RJ',
80
        '11' => 'RO',
81
        '24' => 'RN',
82
        '14' => 'RR',
83
        '43' => 'RS',
84
        '42' => 'SC',
85
        '28' => 'SE',
86
        '35' => 'SP',
87
        '17' => 'TO'
88
    ];
89
90
    /*
91
     * Fonte: http://nfce.encat.org/consumidor/consulte-sua-nota/
92
     * URL referente a pagina de consulta da NFCe pela chave de acesso
93
     * @var string
94
     */
95
    protected $urlConsulta = [
96
        '1' => [
97
            'AC' => 'www.sefaznet.ac.gov.br/nfce/consulta',
98
            'AL' => 'http://nfce.sefaz.al.gov.br/consultaNFCe.htm',
99
            'AP' => 'https://www.sefaz.ap.gov.br/sate/seg/SEGf_AcessarFuncao.jsp?cdFuncao=FIS_1261',
100
            'AM' => 'sistemas.sefaz.am.gov.br/nfceweb/formConsulta.do',
101
            'BA' => 'nfe.sefaz.ba.gov.br/servicos/nfce/default.aspx',
102
            'CE' => '',
103
            'DF' => 'http://dec.fazenda.df.gov.br/NFCE/',
104
            'ES' => 'http://app.sefaz.es.gov.br/ConsultaNFCe',
105
            'GO' => '',
106
            'MA' => 'http://www.nfce.sefaz.ma.gov.br/portal/consultaNFe.do?method=preFilterCupom&',
107
            'MT' => 'http://www.sefaz.mt.gov.br/nfce/consultanfce',
108
            'MS' => 'http://www.dfe.ms.gov.br/nfce',
109
            'MG' => '',
110
            'PA' => 'https://appnfc.sefa.pa.gov.br/portal/view/consultas/nfce/consultanfce.seam',
111
            'PB' => 'www.receita.pb.gov.br/nfce',
112
            'PR' => 'http://www.fazenda.pr.gov.br',
113
            'PE' => '',
114
            'PI' => 'http://webas.sefaz.pi.gov.br/nfceweb/consultarNFCe.jsf',
115
            'RJ' => 'www.nfce.fazenda.rj.gov.br/consulta',
116
            'RN' => 'http://nfce.set.rn.gov.br/consultarNFCe.aspx',
117
            'RS' => 'https://www.sefaz.rs.gov.br/NFCE/NFCE-COM.aspx',
118
            'RO' => 'http://www.nfce.sefin.ro.gov.br',
119
            'RR' => 'https://www.sefaz.rr.gov.br/nfce/servlet/wp_consulta_nfce',
120
            'SC' => '',
121
            'SP' => 'https://www.nfce.fazenda.sp.gov.br/NFCeConsultaPublica/Paginas/ConsultaPublica.aspx',
122
            'SE' => 'http://www.nfce.se.gov.br/portal/portalNoticias.jsp',
123
            'TO' => ''
124
        ],
125
        '2' => [
126
            'AC' => 'http://hml.sefaznet.ac.gov.br/nfce/consulta',
127
            'AL' => 'http://nfce.sefaz.al.gov.br/consultaNFCe.htm',
128
            'AP' => 'https://www.sefaz.ap.gov.br/sate1/seg/SEGf_AcessarFuncao.jsp?cdFuncao=FIS_1261',
129
            'AM' => 'homnfce.sefaz.am.gov.br/nfceweb/formConsulta.do',
130
            'BA' => 'http://hnfe.sefaz.ba.gov.br/servicos/nfce/default.aspx',
131
            'CE' => 'http://nfceh.sefaz.ce.gov.br/pages/consultaNota.jsf',
132
            'DF' => 'http://dec.fazenda.df.gov.br/NFCE/',
133
            'ES' => 'http://homologacao.sefaz.es.gov.br/ConsultaNFCe',
134
            'GO' => '',
135
            'MA' => 'http://www.hom.nfce.sefaz.ma.gov.br/portal/consultarNFCe.jsp',
136
            'MT' => 'http://homologacao.sefaz.mt.gov.br/nfce/consultanfce',
137
            'MS' => 'http://www.dfe.ms.gov.br/nfce',
138
            'MG' => '',
139
            'PA' => 'https://appnfc.sefa.pa.gov.br/portal-homologacao/view/consultas/nfce/consultanfce.seam',
140
            'PB' => '',
141
            'PR' => 'http://www.fazenda.pr.gov.br',
142
            'PE' => '',
143
            'PI' => 'http://webas.sefaz.pi.gov.br/nfceweb-homologacao/consultarNFCe.jsf',
144
            'RJ' => 'www.nfce.fazenda.rj.gov.br/consulta',
145
            'RN' => 'http://nfce.set.rn.gov.br/consultarNFCe.aspx',
146
            'RS' => 'https://www.sefaz.rs.gov.br/NFCE/NFCE-COM.aspx',
147
            'RO' => 'http://www.nfce.sefin.ro.gov.br',
148
            'RR' => 'http://200.174.88.103:8080/nfce/servlet/wp_consulta_nfce',
149
            'SC' => '',
150
            'SP' => 'https://www.homologacao.nfce.fazenda.sp.gov.br/NFCeConsultaPublica/Paginas/ConsultaPublica.aspx',
151
            'SE' => 'http://www.hom.nfe.se.gov.br/portal/portalNoticias.jsp',
152
            'TO' => ''
153
        ],
154
    ];
155
156
    /**
157
     * __contruct
158
     *
159
     * @param string $docXML
160
     * @param string $sPathLogo
161
     * @param string $mododebug
162
     * @param string $idToken
163
     * @param string $Token
0 ignored issues
show
Bug introduced by
There is no parameter named $Token. 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...
164
     */
165
    public function __construct(
166
        $docXML = '',
167
        $sPathLogo = '',
168
        $mododebug = 0,
169
        // habilita os erros do sistema
170
        $idToken = '',
0 ignored issues
show
Unused Code introduced by
The parameter $idToken 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...
171
        $emitToken = '',
0 ignored issues
show
Unused Code introduced by
The parameter $emitToken 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...
172
        $urlQR = ''
0 ignored issues
show
Unused Code introduced by
The parameter $urlQR 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...
173
    ) {
174
        if (is_numeric($mododebug)) {
175
            $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...
176
        }
177
        if ($this->debugMode) {
178
            //ativar modo debug
179
            error_reporting(E_ALL);
180
            ini_set('display_errors', 'On');
181
        } else {
182
            //desativar modo debug
183
            error_reporting(0);
184
            ini_set('display_errors', 'Off');
185
        }
186
        $this->xml = $docXML;
187
        $this->logomarca = $sPathLogo;
188
        if (empty($fonteDANFE)) {
0 ignored issues
show
Bug introduced by
The variable $fonteDANFE seems to never exist, and therefore empty should always return true. Did you maybe rename this variable?

This check looks for calls to isset(...) or empty() on variables that are yet undefined. These calls will always produce the same result and can be removed.

This is most likely caused by the renaming of a variable or the removal of a function/method parameter.

Loading history...
189
            $this->fontePadrao = 'Times';
190
        } else {
191
            $this->fontePadrao = $fonteDANFE;
192
        }
193
        if (!empty($this->xml)) {
194
            $this->dom = new Dom();
0 ignored issues
show
Bug introduced by
The property dom 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...
195
            $this->dom->loadXML($this->xml);
196
            $this->nfeProc    = $this->dom->getElementsByTagName("nfeProc")->item(0);
197
            $this->nfe        = $this->dom->getElementsByTagName("NFe")->item(0);
198
            $this->infNFe     = $this->dom->getElementsByTagName("infNFe")->item(0);
199
            $this->ide        = $this->dom->getElementsByTagName("ide")->item(0);
200
            $this->emit       = $this->dom->getElementsByTagName("emit")->item(0);
201
            $this->enderEmit  = $this->dom->getElementsByTagName("enderEmit")->item(0);
202
            $this->det        = $this->dom->getElementsByTagName("det");
203
            $this->dest       = $this->dom->getElementsByTagName("dest")->item(0);
204
            $this->imposto    = $this->dom->getElementsByTagName("imposto")->item(0);
205
            $this->ICMSTot    = $this->dom->getElementsByTagName("ICMSTot")->item(0);
206
            $this->tpImp      = $this->ide->getElementsByTagName("tpImp")->item(0)->nodeValue;
207
            $this->infAdic    = $this->dom->getElementsByTagName("infAdic")->item(0);
208
            
209
            //se for o layout 4.0 busca pelas tags de detalhe do pagamento
210
            //senao, busca pelas tags de pagamento principal
211
            if ($this->infNFe->getAttribute("versao") == "4.00") {
212
                $this->pag = $this->dom->getElementsByTagName("detPag");
213
            } else {
214
                $this->pag = $this->dom->getElementsByTagName("pag");
215
            }
216
        }
217
        $this->qrCode = $this->dom->getElementsByTagName('qrCode')->item(0)->nodeValue;
218
        if ($this->pSimpleGetValue($this->ide, "mod") != '65') {
219
            throw new nfephpException("O xml do DANFE deve ser uma NFC-e modelo 65");
220
        }
221
    }
222
    
223
    public function getPapel()
224
    {
225
        return $this->papel;
226
    }
227
    
228
    public function setPapel($aPap)
229
    {
230
        $this->papel = $aPap;
231
    }
232
    
233
    public function monta(
234
        $orientacao = 'P',
235
        $papel = '',
236
        $logoAlign = 'C',
237
        $classPdf = false,
238
        $depecNumReg = ''
239
    ) {
240
        $this->montaDANFE($orientacao, $papel, $logoAlign, $classPdf, $depecNumReg);
241
    }
242
    
243
    public function montaDANFE(
244
        $orientacao = 'P',
245
        $papel = '',
0 ignored issues
show
Unused Code introduced by
The parameter $papel 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...
246
        $logoAlign = 'C',
247
        $classPdf = false,
248
        $depecNumReg = ''
249
    ) {
250
        $qtdItens = $this->det->length;
251
        $qtdPgto = $this->pag->length;
252
        $hMaxLinha = $this->hMaxLinha;
253
        $hBoxLinha = $this->hBoxLinha;
0 ignored issues
show
Unused Code introduced by
$hBoxLinha 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...
254
        $hLinha = $this->hLinha;
255
        $tamPapelVert = 160 + 16 + (($qtdItens - 1) * $hMaxLinha) + ($qtdPgto * $hLinha);
256
        // verifica se existe informações adicionais
257
        $this->textoAdic = '';
258
        if (isset($this->infAdic)) {
259
            $this->textoAdic .= !empty($this->infAdic->getElementsByTagName('infCpl')->item(0)->nodeValue) ?
260
            'Inf. Contribuinte: '.
261
            trim($this->pAnfavea($this->infAdic->getElementsByTagName('infCpl')->item(0)->nodeValue)) : '';
262
            if (!empty($this->textoAdic)) {
263
                $tempPDF = new Pdf(); // cria uma instancia temporaria da class pdf
264
                $tempPDF->SetFont('Times', '', '8'); // seta a font do PDF
265
                $linhasCount = $tempPDF->WordWrap($this->textoAdic, 76);
0 ignored issues
show
Documentation introduced by
$this->textoAdic is of type string, but the function expects a object<NFePHP\DA\Legacy\type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
76 is of type integer, but the function expects a object<NFePHP\DA\Legacy\type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
266
                //seta a quantidade de linhas que o texto vai ocupar
267
                //e deixa uma folga para a margem bottom
268
                $tamPapelVert += $linhasCount + ceil(2.9 * $linhasCount);
269
            }
270
        }
271
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
272
        if ($orientacao == '') {
273
            $orientacao = 'P';
274
        }
275
        $this->orientacao = $orientacao;
0 ignored issues
show
Bug introduced by
The property orientacao 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...
276
        $this->papel = array(80,$tamPapelVert);
277
        $this->logoAlign = $logoAlign;
0 ignored issues
show
Bug introduced by
The property logoAlign 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...
278
        //$this->situacao_externa = $situacaoExterna;
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
279
        $this->numero_registro_dpec = $depecNumReg;
0 ignored issues
show
Bug introduced by
The property numero_registro_dpec 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...
280
        //instancia a classe pdf
281
        if ($classPdf) {
282
            $this->pdf = $classPdf;
283
        } else {
284
            $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
0 ignored issues
show
Documentation introduced by
$this->papel is of type array<integer,integer|do...,"1":"double|integer"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
285
        }
286
        //margens do PDF, em milímetros. Obs.: a margem direita é sempre igual à
287
        //margem esquerda. A margem inferior *não* existe na FPDF, é definida aqui
288
        //apenas para controle se necessário ser maior do que a margem superior
289
        $margSup = 2;
290
        $margEsq = 2;
291
        $margInf = 2;
292
        // posição inicial do conteúdo, a partir do canto superior esquerdo da página
293
        $xInic = $margEsq;
294
        $yInic = $margSup;
295
        $maxW = 80;
296
        $maxH = $tamPapelVert;
297
        //total inicial de paginas
298
        $totPag = 1;
0 ignored issues
show
Unused Code introduced by
$totPag 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...
299
        //largura imprimivel em mm: largura da folha menos as margens esq/direita
300
        $this->wPrint = $maxW-($margEsq*2);
0 ignored issues
show
Bug introduced by
The property wPrint 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...
301
        //comprimento (altura) imprimivel em mm: altura da folha menos as margens
302
        //superior e inferior
303
        $this->hPrint = $maxH-$margSup-$margInf;
0 ignored issues
show
Bug introduced by
The property hPrint 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...
304
        // estabelece contagem de paginas
305
        $this->pdf->aliasNbPages();
306
        $this->pdf->setMargins($margEsq, $margSup); // fixa as margens
307
        $this->pdf->setDrawColor(0, 0, 0);
308
        $this->pdf->setFillColor(255, 255, 255);
309
        $this->pdf->open(); // inicia o documento
310
        $this->pdf->addPage($this->orientacao, $this->papel); // adiciona a primeira página
0 ignored issues
show
Documentation introduced by
$this->papel is of type array<integer,integer|do...,"1":"double|integer"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
311
        $this->pdf->setLineWidth(0.1); // define a largura da linha
312
        $this->pdf->setTextColor(0, 0, 0);
313
        $this->pTextBox(0, 0, $maxW, $maxH); // POR QUE PRECISO DESA LINHA?
314
        $hcabecalho = 27;//para cabeçalho (dados emitente mais logomarca)  (FIXO)
315
        $hcabecalhoSecundario = 10;//para cabeçalho secundário (cabeçalho sefaz) (FIXO)
316
        $hprodutos = $hLinha + ($qtdItens*$hMaxLinha) ;//box poduto
317
        $hTotal = 12; //box total (FIXO)
318
        $hpagamentos = $hLinha + ($qtdPgto*$hLinha);//para pagamentos
319
        $hmsgfiscal = 21;// para imposto (FIXO)
320
        if (!isset($this->dest)) {
321
            $hcliente = 6;// para cliente (FIXO)
322
        } else {
323
            $hcliente = 12;
324
        }// para cliente (FIXO)};
0 ignored issues
show
Unused Code Comprehensibility introduced by
40% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
325
        $hQRCode = 50;// para qrcode (FIXO)
326
        $hCabecItens = 4;//cabeçalho dos itens
327
        
328
        $hUsado = $hCabecItens;
0 ignored issues
show
Unused Code introduced by
$hUsado 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...
329
        $w2 = round($this->wPrint*0.31, 0);
0 ignored issues
show
Unused Code introduced by
$w2 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...
330
        $totPag = 1;
331
        $pag = 1;
332
        $x = $xInic;
333
        //COLOCA CABEÇALHO
334
        $y = $yInic;
335
        $y = $this->pCabecalhoDANFE($x, $y, $hcabecalho, $pag, $totPag);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pCabecalhoDANFE($...becalho, $pag, $totPag) (which targets NFePHP\DA\NFe\Danfce::pCabecalhoDANFE()) 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...
336
        //COLOCA CABEÇALHO SECUNDÁRIO
337
        $y = $hcabecalho;
338
        $y = $this->pCabecalhoSecundarioDANFE($x, $y, $hcabecalhoSecundario);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pCabecalhoSecunda... $hcabecalhoSecundario) (which targets NFePHP\DA\NFe\Danfce::pCabecalhoSecundarioDANFE()) 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...
339
        //COLOCA PRODUTOS
340
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario;
341
        $y = $this->pProdutosDANFE($x, $y, $hprodutos);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pProdutosDANFE($x, $y, $hprodutos) (which targets NFePHP\DA\NFe\Danfce::pProdutosDANFE()) 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...
342
        //COLOCA TOTAL
343
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos;
344
        $y = $this->pTotalDANFE($x, $y, $hTotal);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pTotalDANFE($x, $y, $hTotal) (which targets NFePHP\DA\NFe\Danfce::pTotalDANFE()) 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...
345
        //COLOCA PAGAMENTOS
346
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos + $hTotal;
347
        $y = $this->pPagamentosDANFE($x, $y, $hpagamentos);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pPagamentosDANFE($x, $y, $hpagamentos) (which targets NFePHP\DA\NFe\Danfce::pPagamentosDANFE()) 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...
348
        //COLOCA MENSAGEM FISCAL
349
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos + $hTotal+ $hpagamentos;
350
        $y = $this->pFiscalDANFE($x, $y, $hmsgfiscal);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pFiscalDANFE($x, $y, $hmsgfiscal) (which targets NFePHP\DA\NFe\Danfce::pFiscalDANFE()) 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...
351
        //COLOCA CONSUMIDOR
352
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos + $hTotal + $hpagamentos + $hmsgfiscal;
353
        $y = $this->pConsumidorDANFE($x, $y, $hcliente);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pConsumidorDANFE($x, $y, $hcliente) (which targets NFePHP\DA\NFe\Danfce::pConsumidorDANFE()) 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...
354
        //COLOCA QRCODE
355
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos
356
            + $hTotal + $hpagamentos + $hmsgfiscal + $hcliente;
357
        $y = $this->pQRDANFE($x, $y, $hQRCode);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pQRDANFE($x, $y, $hQRCode) (which targets NFePHP\DA\NFe\Danfce::pQRDANFE()) 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...
358
        
359
        //adiciona as informações opcionais
360
        if (!empty($this->textoAdic)) {
361
            $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos
362
            + $hTotal + $hpagamentos + $hmsgfiscal + $hcliente + $hQRCode;
363
            $y = $this->pInfAdic($x, $y, $hInfAdic);
0 ignored issues
show
Bug introduced by
The variable $hInfAdic does not exist. Did you forget to declare it?

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

Loading history...
Bug introduced by
Are you sure the assignment to $y is correct as $this->pInfAdic($x, $y, $hInfAdic) (which targets NFePHP\DA\NFe\Danfce::pInfAdic()) 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...
364
        }
365
        
366
        //retorna o ID na NFe
367
        if ($classPdf!==false) {
368
            $aR = [
369
             'id'=>str_replace('NFe', '', $this->infNFe->getAttribute("Id")),
370
             'classe_PDF'=>$this->pdf
371
            ];
372
            return $aR;
373
        } else {
374
            return str_replace('NFe', '', $this->infNFe->getAttribute("Id"));
375
        }
376
    }
377
    
378
    protected function pCabecalhoDANFE($x = 0, $y = 0, $h = 0, $pag = '1', $totPag = '1')
0 ignored issues
show
Unused Code introduced by
The parameter $x 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...
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...
Unused Code introduced by
The parameter $totPag 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...
379
    {
380
        $emitRazao  = $this->pSimpleGetValue($this->emit, "xNome");
381
        $emitCnpj   = $this->pSimpleGetValue($this->emit, "CNPJ");
382
        $emitCnpj   = $this->pFormat($emitCnpj, "##.###.###/####-##");
383
        $emitIE     = $this->pSimpleGetValue($this->emit, "IE");
384
        $emitIM     = $this->pSimpleGetValue($this->emit, "IM");
385
        $emitFone = $this->pSimpleGetValue($this->enderEmit, "fone");
386
        $foneLen = strlen($emitFone);
387
        if ($foneLen>0) {
388
            $ddd = substr($emitFone, 0, 2);
389
            $fone1 = substr($emitFone, -8);
390
            $digito9 = ' ';
391
            if ($foneLen == 11) {
392
                $digito9 = substr($emitFone, 2, 1);
393
            }
394
            $emitFone = ' - ('.$ddd.') '.$digito9. ' ' . substr($fone1, 0, 4) . '-' . substr($fone1, -4);
395
        } else {
396
            $emitFone = '';
397
        }
398
        $emitLgr = $this->pSimpleGetValue($this->enderEmit, "xLgr");
399
        $emitNro = $this->pSimpleGetValue($this->enderEmit, "nro");
400
        $emitCpl = $this->pSimpleGetValue($this->enderEmit, "xCpl", "");
401
        $emitBairro = $this->pSimpleGetValue($this->enderEmit, "xBairro");
402
        $emitCEP = $this->pFormat($this->pSimpleGetValue($this->enderEmit, "CEP"), "#####-###");
403
        $emitMun = $this->pSimpleGetValue($this->enderEmit, "xMun");
404
        $emitUF = $this->pSimpleGetValue($this->enderEmit, "UF");
405
        // CONFIGURAÇÃO DE POSIÇÃO
406
        $margemInterna = $this->margemInterna;
407
        $maxW = $this->wPrint;
408
        $h = $h-($margemInterna);
409
        //COLOCA LOGOMARCA
410
        if (is_file($this->logomarca)) {
411
            $xImg = $margemInterna;
412
            $yImg = $margemInterna + 1;
413
            $this->pdf->Image($this->logomarca, $xImg, $yImg, 30, 22.5);
414
            $xRs = ($maxW*0.4) + $margemInterna;
415
            $wRs = ($maxW*0.6);
416
            $alignEmit = 'L';
417
        } else {
418
            $xRs = $margemInterna;
419
            $wRs = ($maxW*1);
420
            $alignEmit = 'L';
421
        }
422
        //COLOCA RAZÃO SOCIAL
423
        $texto = $emitRazao;
424
        $texto = $texto . "\nCNPJ:" . $emitCnpj;
425
        $texto = $texto . "\nIE:" . $emitIE;
426
        if (!empty($emitIM)) {
427
            $texto = $texto . " - IM:" . $emitIM;
428
        }
429
        $texto = $texto . "\n" . $emitLgr . "," . $emitNro . " " . $emitCpl . "," . $emitBairro
430
                . ". CEP:" . $emitCEP . ". " . $emitMun . "-" . $emitUF . $emitFone;
431
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
432
        $this->pTextBox($xRs, $y, $wRs, $h, $texto, $aFont, 'C', $alignEmit, 0, '', false);
433
    }
434
    
435
    protected function pCabecalhoSecundarioDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h 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...
436
    {
437
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna 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...
438
        $maxW = $this->wPrint;
439
        $w = ($maxW*1);
440
        $hBox1 = 7;
441
        $texto = "DANFE NFC-e\nDocumento Auxiliar da Nota Fiscal de Consumidor Eletrônica";
442
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
443
        $this->pTextBox($x, $y, $w, $hBox1, $texto, $aFont, 'C', 'C', 0, '', false);
444
        $hBox2 = 4;
445
        $yBox2 = $y + $hBox1;
446
        $texto = "\nNFC-e não permite aproveitamento de crédito de ICMS";
447
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'');
448
        $this->pTextBox($x, $yBox2, $w, $hBox2, $texto, $aFont, 'C', 'C', 0, '', false);
449
    }
450
    
451
    protected function pProdutosDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h 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...
452
    {
453
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna 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...
454
        $maxW = $this->wPrint;
455
        $qtdItens = $this->det->length;
456
        $w = ($maxW*1);
457
        $hLinha = $this->hLinha;
458
        $aFontCabProdutos = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
459
        $wBoxCod = $w*0.17;
460
        $texto = "CÓDIGO";
461
        $this->pTextBox($x, $y, $wBoxCod, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
462
        $wBoxDescricao = $w*0.43;
463
        $xBoxDescricao = $wBoxCod + $x;
464
        $texto = "DESCRICÃO";
465
        $this->pTextBox(
466
            $xBoxDescricao,
467
            $y,
468
            $wBoxDescricao,
469
            $hLinha,
470
            $texto,
471
            $aFontCabProdutos,
472
            'T',
473
            'L',
474
            0,
475
            '',
476
            false
477
        );
478
        $wBoxQt = $w*0.08;
479
        $xBoxQt = $wBoxDescricao + $xBoxDescricao;
480
        $texto = "QT";
481
        $this->pTextBox($xBoxQt, $y, $wBoxQt, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
482
        $wBoxUn = $w*0.06;
483
        $xBoxUn = $wBoxQt + $xBoxQt;
484
        $texto = "UN";
485
        $this->pTextBox($xBoxUn, $y, $wBoxUn, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
486
        $wBoxVl = $w*0.13;
487
        $xBoxVl = $wBoxUn + $xBoxUn;
488
        $texto = "VALOR";
489
        $this->pTextBox($xBoxVl, $y, $wBoxVl, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
490
        $wBoxTotal = $w*0.13;
491
        $xBoxTotal = $wBoxVl + $xBoxVl;
492
        $texto = "TOTAL";
493
        $this->pTextBox($xBoxTotal, $y, $wBoxTotal, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
494
        $hBoxLinha = $this->hBoxLinha;
0 ignored issues
show
Unused Code introduced by
$hBoxLinha 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...
495
        $hMaxLinha = $this->hMaxLinha;
496
        $cont = 0;
497
        $aFontProdutos = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'');
498
        if ($qtdItens > 0) {
499
            foreach ($this->det as $detI) {
500
                $thisItem   = $detI;
501
                $prod       = $thisItem->getElementsByTagName("prod")->item(0);
502
                $nitem      = $thisItem->getAttribute("nItem");
0 ignored issues
show
Unused Code introduced by
$nitem 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...
503
                $cProd      = $this->pSimpleGetValue($prod, "cProd");
504
                $xProd      = $this->pSimpleGetValue($prod, "xProd");
505
                $qCom       = number_format($this->pSimpleGetValue($prod, "qCom"), 2, ",", ".");
506
                $uCom       = $this->pSimpleGetValue($prod, "uCom");
507
                $vUnCom     = number_format($this->pSimpleGetValue($prod, "vUnCom"), 2, ",", ".");
508
                $vProd      = number_format($this->pSimpleGetValue($prod, "vProd"), 2, ",", ".");
509
                //COLOCA PRODUTO
510
                $yBoxProd = $y + $hLinha + ($cont*$hMaxLinha);
511
                //COLOCA PRODUTO CÓDIGO
512
                $wBoxCod = $w*0.17;
513
                $texto = $cProd;
514
                $this->pTextBox($x, $yBoxProd, $wBoxCod, $hMaxLinha, $texto, $aFontProdutos, 'C', 'C', 0, '', false);
515
                //COLOCA PRODUTO DESCRIÇÃO
516
                $wBoxDescricao = $w*0.43;
517
                $xBoxDescricao = $wBoxCod + $x;
518
                $texto = $xProd;
519
                $this->pTextBox(
520
                    $xBoxDescricao,
521
                    $yBoxProd,
522
                    $wBoxDescricao,
523
                    $hMaxLinha,
524
                    $texto,
525
                    $aFontProdutos,
526
                    'C',
527
                    'L',
528
                    0,
529
                    '',
530
                    false
531
                );
532
                //COLOCA PRODUTO QUANTIDADE
533
                $wBoxQt = $w*0.08;
534
                $xBoxQt = $wBoxDescricao + $xBoxDescricao;
535
                $texto = $qCom;
536
                $this->pTextBox(
537
                    $xBoxQt,
538
                    $yBoxProd,
539
                    $wBoxQt,
540
                    $hMaxLinha,
541
                    $texto,
542
                    $aFontProdutos,
543
                    'C',
544
                    'C',
545
                    0,
546
                    '',
547
                    false
548
                );
549
                //COLOCA PRODUTO UNIDADE
550
                $wBoxUn = $w*0.06;
551
                $xBoxUn = $wBoxQt + $xBoxQt;
552
                $texto = $uCom;
553
                $this->pTextBox(
554
                    $xBoxUn,
555
                    $yBoxProd,
556
                    $wBoxUn,
557
                    $hMaxLinha,
558
                    $texto,
559
                    $aFontProdutos,
560
                    'C',
561
                    'C',
562
                    0,
563
                    '',
564
                    false
565
                );
566
                //COLOCA PRODUTO VL UNITÁRIO
567
                $wBoxVl = $w*0.13;
568
                $xBoxVl = $wBoxUn + $xBoxUn;
569
                $texto = $vUnCom;
570
                $this->pTextBox(
571
                    $xBoxVl,
572
                    $yBoxProd,
573
                    $wBoxVl,
574
                    $hMaxLinha,
575
                    $texto,
576
                    $aFontProdutos,
577
                    'C',
578
                    'R',
579
                    0,
580
                    '',
581
                    false
582
                );
583
                //COLOCA PRODUTO VL TOTAL
584
                $wBoxTotal = $w*0.13;
585
                $xBoxTotal = $wBoxVl + $xBoxVl;
586
                $texto = $vProd;
587
                $this->pTextBox(
588
                    $xBoxTotal,
589
                    $yBoxProd,
590
                    $wBoxTotal,
591
                    $hMaxLinha,
592
                    $texto,
593
                    $aFontProdutos,
594
                    'C',
595
                    'R',
596
                    0,
597
                    '',
598
                    false
599
                );
600
                
601
                $cont++;
602
            }
603
        }
604
    }
605
    
606
    protected function pTotalDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h 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...
607
    {
608
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna 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...
609
        $maxW = $this->wPrint;
610
        $hLinha = 3;
611
        $wColEsq = ($maxW*0.7);
612
        $wColDir = ($maxW*0.3);
613
        $xValor = $x + $wColEsq;
614
        $qtdItens = $this->det->length;
615
        $vProd = $this->pSimpleGetValue($this->ICMSTot, "vProd");
616
        $vNF = $this->pSimpleGetValue($this->ICMSTot, "vNF");
617
        $vDesc  = $this->pSimpleGetValue($this->ICMSTot, "vDesc");
618
        $vTotTrib = $this->pSimpleGetValue($this->ICMSTot, "vTotTrib");
619
        $texto = "Qtd. Total de Itens";
620
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
621
        $this->pTextBox($x, $y, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
622
        $texto = $qtdItens;
623
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
624
        $this->pTextBox($xValor, $y, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
625
        $yTotal = $y + ($hLinha);
626
        $texto = "Total de Produtos";
627
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
628
        $this->pTextBox($x, $yTotal, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
629
        $texto = "R$ " . number_format($vProd, 2, ",", ".");
630
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
631
        $this->pTextBox($xValor, $yTotal, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
632
        $yDesconto = $y + ($hLinha*2);
633
        $texto = "Descontos";
634
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
635
        $this->pTextBox($x, $yDesconto, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
636
        $texto = "R$ " . $vDesc;
637
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
638
        $this->pTextBox($xValor, $yDesconto, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
639
        $yTotalFinal = $y + ($hLinha*3);
640
        $texto = "Total";
641
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
642
        $this->pTextBox($x, $yTotalFinal, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
643
        $texto = "R$ " . $vNF;
644
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
645
        $this->pTextBox($xValor, $yTotalFinal, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
646
        $yTotalFinal = $y + ($hLinha*4);
647
        $texto = "Informação dos Tributos Totais Incidentes";
648
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'');
649
        $this->pTextBox($x, $yTotalFinal, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
650
        $texto = "R$ " . $vTotTrib;
651
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
652
        $this->pTextBox($xValor, $yTotalFinal, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
653
    }
654
    
655
    protected function pPagamentosDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h 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...
656
    {
657
        $y += 4;
658
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna 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...
659
        $maxW = $this->wPrint;
660
        $qtdPgto = $this->pag->length;
661
        $w = ($maxW*1);
662
        $hLinha = $this->hLinha;
663
        $wColEsq = ($maxW*0.7);
664
        $wColDir = ($maxW*0.3);
0 ignored issues
show
Unused Code introduced by
$wColDir 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...
665
        $xValor = $x + $wColEsq;
0 ignored issues
show
Unused Code introduced by
$xValor 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...
666
        $aFontPgto = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
667
        $wBoxEsq = $w*0.7;
668
        $texto = "FORMA DE PAGAMENTO";
669
        $this->pTextBox($x, $y, $wBoxEsq, $hLinha, $texto, $aFontPgto, 'T', 'L', 0, '', false);
670
        $wBoxDir = $w*0.3;
671
        $xBoxDescricao = $x + $wBoxEsq;
672
        $texto = "VALOR PAGO";
673
        $this->pTextBox($xBoxDescricao, $y, $wBoxDir, $hLinha, $texto, $aFontPgto, 'T', 'R', 0, '', false);
674
        $cont = 0;
675
        if ($qtdPgto > 0) {
676
            foreach ($this->pag as $pagI) {
677
                $tPag = $this->pSimpleGetValue($pagI, "tPag");
678
                $tPagNome = $this->tipoPag($tPag);
679
                $tPnome = $tPagNome;
0 ignored issues
show
Unused Code introduced by
$tPnome 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...
680
                $vPag = number_format($this->pSimpleGetValue($pagI, "vPag"), 2, ",", ".");
681
                $card = $pagI->getElementsByTagName("card")->item(0);
682
                $cardCNPJ = '';
0 ignored issues
show
Unused Code introduced by
$cardCNPJ 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...
683
                $tBand = '';
0 ignored issues
show
Unused Code introduced by
$tBand 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...
684
                $tBandNome = '';
0 ignored issues
show
Unused Code introduced by
$tBandNome 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...
685
                if (isset($card)) {
686
                    $cardCNPJ = $this->pSimpleGetValue($card, "CNPJ");
0 ignored issues
show
Unused Code introduced by
$cardCNPJ 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...
687
                    $tBand    = $this->pSimpleGetValue($card, "tBand");
688
                    $cAut = $this->pSimpleGetValue($card, "cAut");
0 ignored issues
show
Unused Code introduced by
$cAut 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...
689
                    $tBandNome = self::getCardName($tBand);
0 ignored issues
show
Unused Code introduced by
$tBandNome 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...
690
                }
691
                //COLOCA PRODUTO
692
                $yBoxProd = $y + $hLinha + ($cont*$hLinha);
693
                //COLOCA PRODUTO CÓDIGO
694
                $texto = $tPagNome;
695
                $this->pTextBox($x, $yBoxProd, $wBoxEsq, $hLinha, $texto, $aFontPgto, 'T', 'L', 0, '', false);
696
                //COLOCA PRODUTO DESCRIÇÃO
697
                $xBoxDescricao = $wBoxEsq + $x;
698
                $texto = "R$ " . $vPag;
699
                $this->pTextBox(
700
                    $xBoxDescricao,
701
                    $yBoxProd,
702
                    $wBoxDir,
703
                    $hLinha,
704
                    $texto,
705
                    $aFontPgto,
706
                    'C',
707
                    'R',
708
                    0,
709
                    '',
710
                    false
711
                );
712
                $cont++;
713
            }
714
        }
715
    }
716
    
717
    protected function pFiscalDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h 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...
718
    {
719
        $y += 4;
720
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna 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...
721
        $maxW = $this->wPrint;
722
        $w = ($maxW*1);
723
        $hLinha = $this->hLinha;
724
        $aFontTit = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
725
        $aFontTex = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
726
        $digVal = $this->pSimpleGetValue($this->nfe, "DigestValue");
0 ignored issues
show
Unused Code introduced by
$digVal 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...
727
        $chNFe = str_replace('NFe', '', $this->infNFe->getAttribute("Id"));
728
        $tpAmb = $this->pSimpleGetValue($this->ide, 'tpAmb');
729
        $cUF = $this->pSimpleGetValue($this->ide, 'cUF');
730
        $nNF = $this->pSimpleGetValue($this->ide, 'nNF');
731
        $serieNF = str_pad($this->pSimpleGetValue($this->ide, "serie"), 3, "0", STR_PAD_LEFT);
732
        $dhEmi = $this->pSimpleGetValue($this->ide, "dhEmi");
733
        $urlChave = $this->urlConsulta[$tpAmb][$this->UFSigla[$cUF]];
734
        $texto = "ÁREA DE MENSAGEM FISCAL";
735
        $this->pTextBox($x, $y, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 0, '', false);
736
        $yTex1 = $y + ($hLinha*1);
737
        $hTex1 = $hLinha*2;
738
        $texto = "Número " . $nNF . " Série " . $serieNF . " " .$dhEmi . " - Via Consumidor";
739
        $this->pTextBox($x, $yTex1, $w, $hTex1, $texto, $aFontTex, 'C', 'C', 0, '', false);
740
        $yTex2 = $y + ($hLinha*3);
741
        $hTex2 = $hLinha*2;
742
        $texto = "Consulte pela Chave de Acesso em " . $urlChave;
743
        $this->pTextBox($x, $yTex2, $w, $hTex2, $texto, $aFontTex, 'C', 'C', 0, '', false);
744
        $texto = "CHAVE DE ACESSO";
745
        $yTit2 = $y + ($hLinha*5);
746
        $this->pTextBox($x, $yTit2, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 0, '', false);
747
        $yTex3 = $y + ($hLinha*6);
748
        $texto = $chNFe;
749
        $this->pTextBox($x, $yTex3, $w, $hLinha, $texto, $aFontTex, 'C', 'C', 0, '', false);
750
    }
751
    
752
    protected function pConsumidorDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h 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...
753
    {
754
        $y += 4;
755
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna 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...
756
        $maxW = $this->wPrint;
757
        $w = ($maxW*1);
758
        $hLinha = $this->hLinha;
759
        $aFontTit = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
760
        $aFontTex = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
761
        $texto = "CONSUMIDOR";
762
        $this->pTextBox($x, $y, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 0, '', false);
763
        if (isset($this->dest)) {
764
            $considEstrangeiro = !empty($this->dest->getElementsByTagName("idEstrangeiro")->item(0)->nodeValue)
765
                    ? $this->dest->getElementsByTagName("idEstrangeiro")->item(0)->nodeValue
766
                    : '';
767
            $consCPF = !empty($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue)
768
                    ? $this->dest->getElementsByTagName("CPF")->item(0)->nodeValue
769
                    : '';
770
            $consCNPJ = !empty($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue)
771
                    ? $this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue
772
                    : '';
773
            $cDest = $consCPF.$consCNPJ.$considEstrangeiro; //documentos do consumidor
0 ignored issues
show
Unused Code introduced by
$cDest 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...
774
            $enderDest = $this->dest->getElementsByTagName("enderDest")->item(0);
775
            $consNome = $this->pSimpleGetValue($this->dest, "xNome");
776
            $consLgr = $this->pSimpleGetValue($enderDest, "xLgr");
777
            $consNro = $this->pSimpleGetValue($enderDest, "nro");
778
            $consCpl = $this->pSimpleGetValue($enderDest, "xCpl", " - ");
779
            $consBairro = $this->pSimpleGetValue($enderDest, "xBairro");
780
            $consCEP = $this->pFormat($this->pSimpleGetValue($enderDest, "CEP"));
781
            $consMun = $this->pSimpleGetValue($enderDest, "xMun");
782
            $consUF = $this->pSimpleGetValue($enderDest, "UF");
783
            $considEstrangeiro = $this->pSimpleGetValue($this->dest, "idEstrangeiro");
784
            $consCPF = $this->pSimpleGetValue($this->dest, "CPF");
785
            $consCNPJ = $this->pSimpleGetValue($this->dest, "CNPJ");
786
            $consDoc = "";
787
            if (!empty($consCNPJ)) {
788
                $consDoc = "CNPJ: $consCNPJ";
789
            } elseif (!empty($consCPF)) {
790
                $consDoc = "CPF: $consCPF";
791
            } elseif (!empty($considEstrangeiro)) {
792
                $consDoc = "id: $considEstrangeiro";
793
            }
794
            $consEnd = "";
795
            if (!empty($consLgr)) {
796
                $consEnd = $consLgr
797
                    . ","
798
                    . $consNro
799
                    . " "
800
                    . $consCpl
801
                    . ","
802
                    . $consBairro
803
                    . ". CEP:"
804
                    . $consCEP
805
                    . ". "
806
                    . $consMun
807
                    . "-"
808
                    . $consUF;
809
            }
810
            $yTex1 = $y + $hLinha;
811
            $texto = $consNome;
812
            if (!empty($consDoc)) {
813
                $texto .= " - ". $consDoc . "\n" . $consEnd;
814
                $this->pTextBox($x, $yTex1, $w, $hLinha*3, $texto, $aFontTex, 'C', 'C', 0, '', false);
815
            }
816
        } else {
817
            $yTex1 = $y + $hLinha;
818
            $texto = "Consumidor não identificado";
819
            $this->pTextBox($x, $yTex1, $w, $hLinha, $texto, $aFontTex, 'C', 'C', 0, '', false);
820
        }
821
    }
822
    
823
    protected function pQRDANFE($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h 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...
824
    {
825
        $y += 4;
826
        $margemInterna = $this->margemInterna;
827
        $maxW = $this->wPrint;
828
        $w = ($maxW*1);
829
        $hLinha = $this->hLinha;
0 ignored issues
show
Unused Code introduced by
$hLinha 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...
830
        $hBoxLinha = $this->hBoxLinha;
831
        $aFontTit = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
0 ignored issues
show
Unused Code introduced by
$aFontTit 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...
832
        $aFontTex = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
833
        $dhRecbto = '';
834
        $nProt = '';
835
        if (isset($this->nfeProc)) {
836
            $nProt = $this->pSimpleGetValue($this->nfeProc, "nProt");
837
            $dhRecbto  = $this->pSimpleGetValue($this->nfeProc, "dhRecbto");
838
        }
839
        $qrcode = new QRcode($this->qrCode, 'M');
0 ignored issues
show
Unused Code introduced by
The call to QrCode::__construct() has too many arguments starting with 'M'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
840
        $wQr = 50;
841
        $hQr = 50;
842
        $yQr = ($y+$margemInterna);
843
        $xQr = ($w/2) - ($wQr/2);
844
        // prepare a base64 encoded "data url"
845
        $pic = 'data://text/plain;base64,' . base64_encode($qrcode->writeString());
846
        $info = getimagesize($pic);
0 ignored issues
show
Unused Code introduced by
$info 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...
847
        $this->pdf->image($pic, $xQr, $yQr, $wQr, $hQr, 'PNG');
848
        $dt = new DateTime($dhRecbto);
849
        $yQr = ($yQr+$hQr+$margemInterna);
850
        $this->pTextBox($x, $yQr, $w, $hBoxLinha, "Protocolo de Autorização: " . $nProt . "\n"
851
            . $dt->format('d/m/Y H:i:s'), $aFontTex, 'C', 'C', 0, '', false);
852
    }
853
   
854
    protected function pInfAdic($x = 0, $y = 0, $h = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $h 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...
855
    {
856
        $y += 17;
857
        $margemInterna = $this->margemInterna;
0 ignored issues
show
Unused Code introduced by
$margemInterna 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...
858
        $maxW = $this->wPrint;
859
        $w = ($maxW * 1);
860
        $hLinha = $this->hLinha;
861
        $aFontTit = array('font' => $this->fontePadrao, 'size' => 8, 'style' => 'B');
862
        $aFontTex = array('font' => $this->fontePadrao, 'size' => 8, 'style' => '');
863
        // seta o textbox do titulo
864
        $texto = "INFORMAÇÃO ADICIONAL";
865
        $heigthText = $this->pTextBox($x, $y, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 0, '', false);
866
        // atribui o text adicional
867
        $texto = $this->textoAdic;
868
        // seta a quantidade de linhas que o texto vai ocupar
869
        $linhasCount = $this->pdf->WordWrap($texto, $w) + 1;
0 ignored issues
show
Documentation introduced by
$texto is of type string, but the function expects a object<NFePHP\DA\Legacy\type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$w is of type integer|double, but the function expects a object<NFePHP\DA\Legacy\type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
870
        // atribui a quantidade de linhas do texto adicional conforme o tamanho do texto
871
        $y += $heigthText + $linhasCount + floor($linhasCount * 0.3);
872
        // seta o textbox do texto adicional
873
        $this->pTextBox($x, $y, $w, $hLinha, $texto, $aFontTex, 'C', 'L', 0, '', false);
874
    }
875
    
876
    /**
877
     * printDANFE
878
     * Esta função envia a DANFE em PDF criada para o dispositivo informado.
879
     * O destino da impressão pode ser :
880
     * I-browser
881
     * D-browser com download
882
     * F-salva em um arquivo local com o nome informado
883
     * S-retorna o documento como uma string e o nome é ignorado.
884
     * Para enviar o pdf diretamente para uma impressora indique o
885
     * nome da impressora e o destino deve ser 'S'.
886
     *
887
     * @param  string $nome    Path completo com o nome do arquivo pdf
888
     * @param  string $destino Direção do envio do PDF
889
     * @param  string $printer Identificação da impressora no sistema
890
     * @return string Caso o destino seja S o pdf é retornado como uma string
891
     * @todo   Rotina de impressão direta do arquivo pdf criado
892
     */
893
    public function printDANFE($nome = '', $destino = 'I', $printer = '')
0 ignored issues
show
Unused Code introduced by
The parameter $printer 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...
894
    {
895
        $arq = $this->pdf->Output($nome, $destino);
896
        if ($destino == 'S') {
0 ignored issues
show
Unused Code introduced by
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
897
            //aqui pode entrar a rotina de impressão direta
898
        }
899
        return $arq;
900
    }
901
902
    /**
903
     * Dados brutos do PDF
904
     * @return string
905
     */
906
    public function render()
907
    {
908
        return $this->pdf->getPdf();
909
    }
910
    
911
    /**
912
     * anfavea
913
     * Função para transformar o campo cdata do padrão ANFAVEA para
914
     * texto imprimível
915
     *
916
     * @param  string $cdata campo CDATA
917
     * @return string conteúdo do campo CDATA como string
918
     */
919
    protected function pAnfavea($cdata = '')
920
    {
921
        if ($cdata == '') {
922
            return '';
923
        }
924
        //remove qualquer texto antes ou depois da tag CDATA
925
        $cdata = str_replace('<![CDATA[', '<CDATA>', $cdata);
926
        $cdata = str_replace(']]>', '</CDATA>', $cdata);
927
        $cdata = preg_replace('/\s\s+/', ' ', $cdata);
928
        $cdata = str_replace("> <", "><", $cdata);
929
        $len = strlen($cdata);
930
        $startPos = strpos($cdata, '<');
931
        if ($startPos === false) {
932
            return $cdata;
933
        }
934
        for ($x=$len; $x>0; $x--) {
935
            if (substr($cdata, $x, 1) == '>') {
936
                $endPos = $x;
937
                break;
938
            }
939
        }
940
        if ($startPos > 0) {
941
            $parte1 = substr($cdata, 0, $startPos);
942
        } else {
943
            $parte1 = '';
944
        }
945
        $parte2 = substr($cdata, $startPos, $endPos-$startPos+1);
0 ignored issues
show
Bug introduced by
The variable $endPos 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...
946
        if ($endPos < $len) {
947
            $parte3 = substr($cdata, $endPos + 1, $len - $endPos - 1);
948
        } else {
949
            $parte3 = '';
950
        }
951
        $texto = trim($parte1).' '.trim($parte3);
952
        if (strpos($parte2, '<CDATA>') === false) {
953
            $cdata = '<CDATA>'.$parte2.'</CDATA>';
954
        } else {
955
            $cdata = $parte2;
956
        }
957
        //carrega o xml CDATA em um objeto DOM
958
        $dom = new Dom();
959
        $dom->loadXML($cdata, LIBXML_NOBLANKS | LIBXML_NOEMPTYTAG);
960
        //$xml = $dom->saveXML();
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
961
        //grupo CDATA infADprod
962
        $id = $dom->getElementsByTagName('id')->item(0);
963
        $div = $dom->getElementsByTagName('div')->item(0);
964
        $entg = $dom->getElementsByTagName('entg')->item(0);
965
        $dest = $dom->getElementsByTagName('dest')->item(0);
966
        $ctl = $dom->getElementsByTagName('ctl')->item(0);
967
        $ref = $dom->getElementsByTagName('ref')->item(0);
968
        if (isset($id)) {
969
            if ($id->hasAttributes()) {
970
                foreach ($id->attributes as $attr) {
971
                    $name = $attr->nodeName;
972
                    $value = $attr->nodeValue;
973
                    $texto .= " $name : $value";
974
                }
975
            }
976
        }
977
        if (isset($div)) {
978
            if ($div->hasAttributes()) {
979
                foreach ($div->attributes as $attr) {
980
                    $name = $attr->nodeName;
981
                    $value = $attr->nodeValue;
982
                    $texto .= " $name : $value";
983
                }
984
            }
985
        }
986
        if (isset($entg)) {
987
            if ($entg->hasAttributes()) {
988
                foreach ($entg->attributes as $attr) {
989
                    $name = $attr->nodeName;
990
                    $value = $attr->nodeValue;
991
                    $texto .= " $name : $value";
992
                }
993
            }
994
        }
995
        if (isset($dest)) {
996
            if ($dest->hasAttributes()) {
997
                foreach ($dest->attributes as $attr) {
998
                    $name = $attr->nodeName;
999
                    $value = $attr->nodeValue;
1000
                    $texto .= " $name : $value";
1001
                }
1002
            }
1003
        }
1004
        if (isset($ctl)) {
1005
            if ($ctl->hasAttributes()) {
1006
                foreach ($ctl->attributes as $attr) {
1007
                    $name = $attr->nodeName;
1008
                    $value = $attr->nodeValue;
1009
                    $texto .= " $name : $value";
1010
                }
1011
            }
1012
        }
1013
        if (isset($ref)) {
1014
            if ($ref->hasAttributes()) {
1015
                foreach ($ref->attributes as $attr) {
1016
                    $name = $attr->nodeName;
1017
                    $value = $attr->nodeValue;
1018
                    $texto .= " $name : $value";
1019
                }
1020
            }
1021
        }
1022
        //grupo CADATA infCpl
1023
        $t = $dom->getElementsByTagName('transmissor')->item(0);
1024
        $r = $dom->getElementsByTagName('receptor')->item(0);
1025
        $versao = ! empty($dom->getElementsByTagName('versao')->item(0)->nodeValue) ?
1026
        'Versao:'.$dom->getElementsByTagName('versao')->item(0)->nodeValue.' ' : '';
1027
        $especieNF = ! empty($dom->getElementsByTagName('especieNF')->item(0)->nodeValue) ?
1028
        'Especie:'.$dom->getElementsByTagName('especieNF')->item(0)->nodeValue.' ' : '';
1029
        $fabEntrega = ! empty($dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue) ?
1030
        'Entrega:'.$dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue.' ' : '';
1031
        $dca = ! empty($dom->getElementsByTagName('dca')->item(0)->nodeValue) ?
1032
        'dca:'.$dom->getElementsByTagName('dca')->item(0)->nodeValue.' ' : '';
1033
        $texto .= "".$versao.$especieNF.$fabEntrega.$dca;
1034
        if (isset($t)) {
1035
            if ($t->hasAttributes()) {
1036
                $texto .= " Transmissor ";
1037
                foreach ($t->attributes as $attr) {
1038
                    $name = $attr->nodeName;
1039
                    $value = $attr->nodeValue;
1040
                    $texto .= " $name : $value";
1041
                }
1042
            }
1043
        }
1044
        if (isset($r)) {
1045
            if ($r->hasAttributes()) {
1046
                $texto .= " Receptor ";
1047
                foreach ($r->attributes as $attr) {
1048
                    $name = $attr->nodeName;
1049
                    $value = $attr->nodeValue;
1050
                    $texto .= " $name : $value";
1051
                }
1052
            }
1053
        }
1054
        return $texto;
1055
    }
1056
    
1057
    /**
1058
     * str2Hex
1059
     * Converte string para haxadecimal ASCII
1060
     *
1061
     * @param  string $str
1062
     * @return string
1063
     */
1064
    protected static function str2Hex($str)
1065
    {
1066
        if ($str == '') {
1067
            return '';
1068
        }
1069
        $hex = "";
1070
        $iCount = 0;
1071
        do {
1072
            $hex .= sprintf("%02x", ord($str{$iCount}));
1073
            $iCount++;
1074
        } while ($iCount < strlen($str));
1075
        return $hex;
1076
    }//fim str2Hex
1077
    
1078
    protected static function getCardName($tBand)
1079
    {
1080
        switch ($tBand) {
1081
            case '01':
1082
                $tBandNome = 'VISA';
1083
                break;
1084
            case '02':
1085
                $tBandNome = 'MASTERCARD';
1086
                break;
1087
            case '03':
1088
                $tBandNome = 'AMERICAM EXPRESS';
1089
                break;
1090
            case '04':
1091
                $tBandNome = 'SOROCRED';
1092
                break;
1093
            case '99':
1094
                $tBandNome = 'OUTROS';
1095
        }
1096
        return $tBandNome;
0 ignored issues
show
Bug introduced by
The variable $tBandNome 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...
1097
    }
1098
    
1099
    protected function tipoPag($tPag)
1100
    {
1101
        switch ($tPag) {
1102
            case '01':
1103
                $tPagNome = 'Dinheiro';
1104
                break;
1105
            case '02':
1106
                $tPagNome = 'Cheque';
1107
                break;
1108
            case '03':
1109
                $tPagNome = 'Cartão de Crédito';
1110
                break;
1111
            case '04':
1112
                $tPagNome = 'Cartão de Débito';
1113
                break;
1114
            case '05':
1115
                $tPagNome = 'Crédito Loja';
1116
                break;
1117
            case '10':
1118
                $tPagNome = 'Vale Alimentação';
1119
                break;
1120
            case '11':
1121
                $tPagNome = 'Vale Refeição';
1122
                break;
1123
            case '12':
1124
                $tPagNome = 'Vale Presente';
1125
                break;
1126
            case '13':
1127
                $tPagNome = 'Vale Combustível';
1128
                break;
1129
            case '99':
1130
                $tPagNome = 'Outros';
1131
        }
1132
        return $tPagNome;
0 ignored issues
show
Bug introduced by
The variable $tPagNome 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...
1133
    }
1134
    
1135
    /**
1136
     * hex2Str
1137
     * Converte hexadecimal ASCII para string
1138
     *
1139
     * @param  string $str
1140
     * @return string
1141
     */
1142
    protected static function hex2Str($str)
1143
    {
1144
        if ($str == '') {
1145
            return '';
1146
        }
1147
        $bin = "";
1148
        $iCount = 0;
1149
        do {
1150
            $bin .= chr(hexdec($str{$iCount}.$str{($iCount + 1)}));
1151
            $iCount += 2;
1152
        } while ($iCount < strlen($str));
1153
        return $bin;
1154
    }
1155
    
1156
    protected function makeQRCode(
1157
        $chNFe,
1158
        $url,
1159
        $tpAmb,
1160
        $cDest = '',
1161
        $dhEmi = '',
1162
        $vNF = '',
1163
        $vICMS = '',
1164
        $digVal = '',
1165
        $idToken = '000001',
1166
        $token = ''
1167
    ) {
1168
        $nVersao = '100';
1169
        $dhHex = self::str2Hex($dhEmi);
1170
        $digHex = self::str2Hex($digVal);
1171
        $seq = '';
1172
        $seq .= 'chNFe=' . $chNFe;
1173
        $seq .= '&nVersao=' . $nVersao;
1174
        $seq .= '&tpAmb=' . $tpAmb;
1175
        if ($cDest != '') {
1176
            $seq .= '&cDest=' . $cDest;
1177
        }
1178
        $seq .= '&dhEmi=' . strtolower($dhHex);
1179
        $seq .= '&vNF=' . $vNF;
1180
        $seq .= '&vICMS=' . $vICMS;
1181
        $seq .= '&digVal=' . strtolower($digHex);
1182
        $seq .= '&cIdToken=' . $idToken;
1183
        //o hash code é calculado com o Token incluso
1184
        $hash = sha1($seq.$token);
1185
        $seq .= '&cHashQRCode='. strtoupper($hash);
1186
        if (strpos($url, '?') === false) {
1187
            $seq = $url.'?'.$seq;
1188
        } else {
1189
            $seq = $url.''.$seq;
1190
        }
1191
        return $seq;
1192
    }
1193
}
1194