Passed
Push — master ( e6289d...84d27f )
by Roberto
02:51 queued 10s
created

Danfce::fiscalDANFE()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 53

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
cc 4
nc 8
nop 3
dl 0
loc 53
ccs 0
cts 47
cp 0
crap 20
rs 9.0254
c 0
b 0
f 0

How to fix   Long Method   

Long Method

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

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

Commonly applied refactorings include:

1
<?php
2
3
namespace NFePHP\DA\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
use Exception;
17
use InvalidArgumentException;
18
use NFePHP\DA\Legacy\Dom;
19
use NFePHP\DA\Legacy\Pdf;
20
use NFePHP\DA\Legacy\Common;
21
use Com\Tecnick\Barcode\Barcode;
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 $urlChave;
44
    protected $det;
45
    protected $infAdic;
46
    protected $textoAdic;
47
    protected $pag;
48
    protected $vTroco;
49
    protected $dest;
50
    protected $imgQRCode;
51
    protected $urlQR = '';
52
    protected $pdf;
53
    protected $margemInterna = 2;
54
    protected $hMaxLinha = 9;
55
    protected $hBoxLinha = 6;
56
    protected $hLinha = 3;
57
    
58
    /*
59
     * Retorna a sigla da UF
60
     * @var string
61
     */
62
    protected $UFSigla = [
63
        '12' => 'AC',
64
        '27' => 'AL',
65
        '13' => 'AM',
66
        '16' => 'AP',
67
        '29' => 'BA',
68
        '23' => 'CE',
69
        '53' => 'DF',
70
        '32' => 'ES',
71
        '52' => 'GO',
72
        '31' => 'MG',
73
        '50' => 'MS',
74
        '51' => 'MT',
75
        '21' => 'MA',
76
        '15' => 'PA',
77
        '25' => 'PB',
78
        '26' => 'PE',
79
        '22' => 'PI',
80
        '41' => 'PR',
81
        '33' => 'RJ',
82
        '11' => 'RO',
83
        '24' => 'RN',
84
        '14' => 'RR',
85
        '43' => 'RS',
86
        '42' => 'SC',
87
        '28' => 'SE',
88
        '35' => 'SP',
89
        '17' => 'TO'
90
    ];
91
    
92
    /**
93
     * __contruct
94
     *
95
     * @param string $docXML
96
     * @param string $sPathLogo
97
     * @param string $mododebug
98
     * @param string $idToken
99
     * @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...
100
     */
101
    public function __construct(
102
        $docXML = '',
103
        $sPathLogo = '',
104
        $mododebug = 0,
105
        // habilita os erros do sistema
106
        $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...
107
        $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...
108
        $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...
109
    ) {
110
        if (is_numeric($mododebug)) {
111
            $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...
112
        }
113
        if ($this->debugMode) {
114
            //ativar modo debug
115
            error_reporting(E_ALL);
116
            ini_set('display_errors', 'On');
117
        } else {
118
            //desativar modo debug
119
            error_reporting(0);
120
            ini_set('display_errors', 'Off');
121
        }
122
        $this->xml = $docXML;
123
        $this->logomarca = $sPathLogo;
124
        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...
125
            $this->fontePadrao = 'Times';
126
        } else {
127
            $this->fontePadrao = $fonteDANFE;
128
        }
129
        if (!empty($this->xml)) {
130
            $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...
131
            $this->dom->loadXML($this->xml);
132
            $this->nfeProc    = $this->dom->getElementsByTagName("nfeProc")->item(0);
133
            $this->nfe        = $this->dom->getElementsByTagName("NFe")->item(0);
134
            $this->infNFe     = $this->dom->getElementsByTagName("infNFe")->item(0);
135
            $this->ide        = $this->dom->getElementsByTagName("ide")->item(0);
136
            $this->emit       = $this->dom->getElementsByTagName("emit")->item(0);
137
            $this->enderEmit  = $this->dom->getElementsByTagName("enderEmit")->item(0);
138
            $this->det        = $this->dom->getElementsByTagName("det");
139
            $this->dest       = $this->dom->getElementsByTagName("dest")->item(0);
140
            $this->imposto    = $this->dom->getElementsByTagName("imposto")->item(0);
141
            $this->ICMSTot    = $this->dom->getElementsByTagName("ICMSTot")->item(0);
142
            $this->tpImp      = $this->ide->getElementsByTagName("tpImp")->item(0)->nodeValue;
143
            $this->infAdic    = $this->dom->getElementsByTagName("infAdic")->item(0);
144
            
145
            //se for o layout 4.0 busca pelas tags de detalhe do pagamento
146
            //senao, busca pelas tags de pagamento principal
147
            if ($this->infNFe->getAttribute("versao") == "4.00") {
148
                $this->pag = $this->dom->getElementsByTagName("detPag");
149
                
150
                $tagPag = $this->dom->getElementsByTagName("pag")->item(0);
151
                $this->vTroco = $this->getTagValue($tagPag, "vTroco");
152
            } else {
153
                $this->pag = $this->dom->getElementsByTagName("pag");
154
            }
155
        }
156
        $this->qrCode = !empty($this->dom->getElementsByTagName('qrCode')->item(0)->nodeValue)
157
            ? $this->dom->getElementsByTagName('qrCode')->item(0)->nodeValue : null;
158
        $this->urlChave = !empty($this->dom->getElementsByTagName('urlChave')->item(0)->nodeValue)
159
            ? $this->dom->getElementsByTagName('urlChave')->item(0)->nodeValue : null;
160
        if ($this->getTagValue($this->ide, "mod") != '65') {
161
            throw new InvalidArgumentException("O xml do DANFE deve ser uma NFC-e modelo 65");
162
        }
163
    }
164
    
165
    public function getPapel()
166
    {
167
        return $this->papel;
168
    }
169
    
170
    public function setPapel($aPap)
171
    {
172
        $this->papel = $aPap;
173
    }
174
    
175
    public function monta(
176
        $orientacao = 'P',
177
        $papel = '',
178
        $logoAlign = 'C',
179
        $classPdf = false,
180
        $depecNumReg = ''
181
    ) {
182
        $this->montaDANFE($orientacao, $papel, $logoAlign, $classPdf, $depecNumReg);
183
    }
184
    
185
    public function montaDANFE(
186
        $orientacao = 'P',
187
        $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...
188
        $logoAlign = 'C',
189
        $classPdf = false,
190
        $depecNumReg = ''
191
    ) {
192
        $qtdItens = $this->det->length;
193
        $qtdPgto = $this->pag->length;
194
        $hMaxLinha = $this->hMaxLinha;
195
        $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...
196
        $hLinha = $this->hLinha;
197
        $tamPapelVert = 160 + 16 + (($qtdItens - 1) * $hMaxLinha) + ($qtdPgto * $hLinha);
198
        // verifica se existe informações adicionais
199
        $this->textoAdic = '';
200
        if (isset($this->infAdic)) {
201
            $this->textoAdic .= !empty($this->infAdic->getElementsByTagName('infCpl')->item(0)->nodeValue) ?
202
            'Inf. Contribuinte: '.
203
            trim($this->anfaveaDANFE($this->infAdic->getElementsByTagName('infCpl')->item(0)->nodeValue)) : '';
204
            if (!empty($this->textoAdic)) {
205
                $this->textoAdic = str_replace(";", "\n", $this->textoAdic);
206
                $alinhas = explode("\n", $this->textoAdic);
207
                $numlinhasdados = 0;
208
                $tempPDF = new Pdf(); // cria uma instancia temporaria da class pdf
209
                $tempPDF->setFont('Times', '', '8'); // seta a font do PDF
210
                foreach ($alinhas as $linha) {
211
                    $linha = trim($linha);
212
                    $numlinhasdados += $tempPDF->wordWrap($linha, 76 - 0.2);
0 ignored issues
show
Documentation introduced by
$linha 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 - 0.2 is of type 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...
213
                }
214
                $hdadosadic = round(($numlinhasdados + 1) * $tempPDF->fontSize, 0);
215
                if ($hdadosadic < 5) {
216
                    $hdadosadic = 5;
217
                }
218
                // seta o tamanho do papel
219
                $tamPapelVert += $hdadosadic;
220
            }
221
        }
222
        //se a orientação estiver em branco utilizar o padrão estabelecido na NF
223
        if ($orientacao == '') {
224
            $orientacao = 'P';
225
        }
226
        $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...
227
        $this->papel = [80, $tamPapelVert];
228
        $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...
229
        //$this->situacao_externa = $situacaoExterna;
230
        $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...
231
        //instancia a classe pdf
232
        if ($classPdf) {
233
            $this->pdf = $classPdf;
234
        } else {
235
            $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...
236
        }
237
        //margens do PDF, em milímetros. Obs.: a margem direita é sempre igual à
238
        //margem esquerda. A margem inferior *não* existe na FPDF, é definida aqui
239
        //apenas para controle se necessário ser maior do que a margem superior
240
        $margSup = 2;
241
        $margEsq = 2;
242
        $margInf = 2;
243
        // posição inicial do conteúdo, a partir do canto superior esquerdo da página
244
        $xInic = $margEsq;
245
        $yInic = $margSup;
246
        $maxW = 80;
247
        $maxH = $tamPapelVert;
248
        //total inicial de paginas
249
        $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...
250
        //largura imprimivel em mm: largura da folha menos as margens esq/direita
251
        $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...
252
        //comprimento (altura) imprimivel em mm: altura da folha menos as margens
253
        //superior e inferior
254
        $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...
255
        // estabelece contagem de paginas
256
        $this->pdf->aliasNbPages();
257
        $this->pdf->setMargins($margEsq, $margSup); // fixa as margens
258
        $this->pdf->setDrawColor(0, 0, 0);
259
        $this->pdf->setFillColor(255, 255, 255);
260
        $this->pdf->open(); // inicia o documento
261
        $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...
262
        $this->pdf->setLineWidth(0.1); // define a largura da linha
263
        $this->pdf->setTextColor(0, 0, 0);
264
        $this->pdf->textBox(0, 0, $maxW, $maxH); // POR QUE PRECISO DESA LINHA?
265
        $hcabecalho = 27;//para cabeçalho (dados emitente mais logomarca)  (FIXO)
266
        $hcabecalhoSecundario = 10;//para cabeçalho secundário (cabeçalho sefaz) (FIXO)
267
        $hprodutos = $hLinha + ($qtdItens*$hMaxLinha) ;//box poduto
268
        $hTotal = 12; //box total (FIXO)
269
        $hpagamentos = $hLinha + ($qtdPgto*$hLinha);//para pagamentos
270
        if (!empty($this->vTroco)) {
271
            $hpagamentos += $hLinha;
272
        }
273
        $hmsgfiscal = 21;// para imposto (FIXO)
274
        if (!isset($this->dest)) {
275
            $hcliente = 6;// para cliente (FIXO)
276
        } else {
277
            $hcliente = 12;
278
        }// para cliente (FIXO)};
279
        $hQRCode = 50;// para qrcode (FIXO)
280
        $hCabecItens = 4;//cabeçalho dos itens
281
        
282
        $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...
283
        $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...
284
        $totPag = 1;
285
        $pag = 1;
286
        $x = $xInic;
287
        //COLOCA CABEÇALHO
288
        $y = $yInic;
289
        $y = $this->cabecalhoDANFE($x, $y, $hcabecalho, $pag, $totPag);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->cabecalhoDANFE($x...becalho, $pag, $totPag) (which targets NFePHP\DA\NFe\Danfce::cabecalhoDANFE()) 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...
290
        //COLOCA CABEÇALHO SECUNDÁRIO
291
        $y = $hcabecalho;
292
        $y = $this->cabecalhoSecundarioDANFE($x, $y, $hcabecalhoSecundario);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->cabecalhoSecundar... $hcabecalhoSecundario) (which targets NFePHP\DA\NFe\Danfce::cabecalhoSecundarioDANFE()) 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...
293
        //COLOCA PRODUTOS
294
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario;
295
        $y = $this->produtosDANFE($x, $y, $hprodutos);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->produtosDANFE($x, $y, $hprodutos) (which targets NFePHP\DA\NFe\Danfce::produtosDANFE()) 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...
296
        //COLOCA TOTAL
297
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos;
298
        $y = $this->totalDANFE($x, $y, $hTotal);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->totalDANFE($x, $y, $hTotal) (which targets NFePHP\DA\NFe\Danfce::totalDANFE()) 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...
299
        //COLOCA PAGAMENTOS
300
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos + $hTotal;
301
        $y = $this->pagamentosDANFE($x, $y, $hpagamentos);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->pagamentosDANFE($x, $y, $hpagamentos) (which targets NFePHP\DA\NFe\Danfce::pagamentosDANFE()) 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...
302
        //COLOCA MENSAGEM FISCAL
303
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos + $hTotal+ $hpagamentos;
304
        $y = $this->fiscalDANFE($x, $y, $hmsgfiscal);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->fiscalDANFE($x, $y, $hmsgfiscal) (which targets NFePHP\DA\NFe\Danfce::fiscalDANFE()) 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...
305
        //COLOCA CONSUMIDOR
306
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos + $hTotal + $hpagamentos + $hmsgfiscal;
307
        $y = $this->consumidorDANFE($x, $y, $hcliente);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->consumidorDANFE($x, $y, $hcliente) (which targets NFePHP\DA\NFe\Danfce::consumidorDANFE()) 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...
308
        //COLOCA QRCODE
309
        $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos
310
            + $hTotal + $hpagamentos + $hmsgfiscal + $hcliente;
311
        $y = $this->qrCodeDANFE($x, $y, $hQRCode);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->qrCodeDANFE($x, $y, $hQRCode) (which targets NFePHP\DA\NFe\Danfce::qrCodeDANFE()) 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...
312
        
313
        //adiciona as informações opcionais
314
        if (!empty($this->textoAdic)) {
315
            $y = $xInic + $hcabecalho + $hcabecalhoSecundario + $hprodutos
316
            + $hTotal + $hpagamentos + $hmsgfiscal + $hcliente + $hQRCode;
317
            $hInfAdic = 0;
318
            $y = $this->infAdic($x, $y, $hInfAdic);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $y is correct as $this->infAdic($x, $y, $hInfAdic) (which targets NFePHP\DA\NFe\Danfce::infAdic()) 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...
319
        }
320
        
321
        //retorna o ID na NFe
322
        if ($classPdf!==false) {
323
            $aR = [
324
             'id'=>str_replace('NFe', '', $this->infNFe->getAttribute("Id")),
325
             'classe_PDF'=>$this->pdf
326
            ];
327
            return $aR;
328
        } else {
329
            return str_replace('NFe', '', $this->infNFe->getAttribute("Id"));
330
        }
331
    }
332
    
333
    protected function cabecalhoDANFE($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...
334
    {
335
        $emitRazao  = $this->getTagValue($this->emit, "xNome");
336
        $emitCnpj   = $this->getTagValue($this->emit, "CNPJ");
337
        $emitCnpj   = $this->formatField($emitCnpj, "##.###.###/####-##");
338
        $emitIE     = $this->getTagValue($this->emit, "IE");
339
        $emitIM     = $this->getTagValue($this->emit, "IM");
340
        $emitFone = $this->getTagValue($this->enderEmit, "fone");
341
        $foneLen = strlen($emitFone);
342
        if ($foneLen>0) {
343
            $ddd = substr($emitFone, 0, 2);
344
            $fone1 = substr($emitFone, -8);
345
            $digito9 = ' ';
346
            if ($foneLen == 11) {
347
                $digito9 = substr($emitFone, 2, 1);
348
            }
349
            $emitFone = ' - ('.$ddd.') '.$digito9. ' ' . substr($fone1, 0, 4) . '-' . substr($fone1, -4);
350
        } else {
351
            $emitFone = '';
352
        }
353
        $emitLgr = $this->getTagValue($this->enderEmit, "xLgr");
354
        $emitNro = $this->getTagValue($this->enderEmit, "nro");
355
        $emitCpl = $this->getTagValue($this->enderEmit, "xCpl", "");
356
        $emitBairro = $this->getTagValue($this->enderEmit, "xBairro");
357
        $emitCEP = $this->formatField($this->getTagValue($this->enderEmit, "CEP"), "#####-###");
358
        $emitMun = $this->getTagValue($this->enderEmit, "xMun");
359
        $emitUF = $this->getTagValue($this->enderEmit, "UF");
360
        // CONFIGURAÇÃO DE POSIÇÃO
361
        $margemInterna = $this->margemInterna;
362
        $maxW = $this->wPrint;
363
        $h = $h-($margemInterna);
364
        //COLOCA LOGOMARCA
365
        if (is_file($this->logomarca)) {
366
            $xImg = $margemInterna;
367
            $yImg = $margemInterna + 1;
368
            $this->pdf->image($this->logomarca, $xImg, $yImg, 30, 22.5);
369
            $xRs = ($maxW*0.4) + $margemInterna;
370
            $wRs = ($maxW*0.6);
371
            $alignEmit = 'L';
372
        } else {
373
            $xRs = $margemInterna;
374
            $wRs = ($maxW*1);
375
            $alignEmit = 'L';
376
        }
377
        //COLOCA RAZÃO SOCIAL
378
        $texto = $emitRazao;
379
        $texto = $texto . "\nCNPJ:" . $emitCnpj;
380
        $texto = $texto . "\nIE:" . $emitIE;
381
        if (!empty($emitIM)) {
382
            $texto = $texto . " - IM:" . $emitIM;
383
        }
384
        $texto = $texto . "\n" . $emitLgr . "," . $emitNro . " " . $emitCpl . "," . $emitBairro
385
                . ". CEP:" . $emitCEP . ". " . $emitMun . "-" . $emitUF . $emitFone;
386
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
387
        $this->pdf->textBox($xRs, $y, $wRs, $h, $texto, $aFont, 'C', $alignEmit, 0, '', false);
388
    }
389
    
390
    protected function cabecalhoSecundarioDANFE($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...
391
    {
392
        $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...
393
        $maxW = $this->wPrint;
394
        $w = ($maxW*1);
395
        $hBox1 = 7;
396
        $texto = "DANFE NFC-e\nDocumento Auxiliar da Nota Fiscal de Consumidor Eletrônica";
397
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
398
        $this->pdf->textBox($x, $y, $w, $hBox1, $texto, $aFont, 'C', 'C', 0, '', false);
399
        $hBox2 = 4;
400
        $yBox2 = $y + $hBox1;
401
        $texto = "\nNFC-e não permite aproveitamento de crédito de ICMS";
402
        $aFont = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'');
403
        $this->pdf->textBox($x, $yBox2, $w, $hBox2, $texto, $aFont, 'C', 'C', 0, '', false);
404
    }
405
    
406
    protected function produtosDANFE($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...
407
    {
408
        $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...
409
        $maxW = $this->wPrint;
410
        $qtdItens = $this->det->length;
411
        $w = ($maxW*1);
412
        $hLinha = $this->hLinha;
413
        $aFontCabProdutos = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
414
        $wBoxCod = $w*0.17;
415
        $texto = "CÓDIGO";
416
        $this->pdf->textBox($x, $y, $wBoxCod, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
417
        $wBoxDescricao = $w*0.43;
418
        $xBoxDescricao = $wBoxCod + $x;
419
        $texto = "DESCRICÃO";
420
        $this->pdf->textBox(
421
            $xBoxDescricao,
422
            $y,
423
            $wBoxDescricao,
424
            $hLinha,
425
            $texto,
426
            $aFontCabProdutos,
427
            'T',
428
            'L',
429
            0,
430
            '',
431
            false
432
        );
433
        $wBoxQt = $w*0.08;
434
        $xBoxQt = $wBoxDescricao + $xBoxDescricao;
435
        $texto = "QT";
436
        $this->pdf->textBox($xBoxQt, $y, $wBoxQt, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
437
        $wBoxUn = $w*0.06;
438
        $xBoxUn = $wBoxQt + $xBoxQt;
439
        $texto = "UN";
440
        $this->pdf->textBox($xBoxUn, $y, $wBoxUn, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
441
        $wBoxVl = $w*0.13;
442
        $xBoxVl = $wBoxUn + $xBoxUn;
443
        $texto = "VALOR";
444
        $this->pdf->textBox($xBoxVl, $y, $wBoxVl, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
445
        $wBoxTotal = $w*0.13;
446
        $xBoxTotal = $wBoxVl + $xBoxVl;
447
        $texto = "TOTAL";
448
        $this->pdf->textBox($xBoxTotal, $y, $wBoxTotal, $hLinha, $texto, $aFontCabProdutos, 'T', 'L', 0, '', false);
449
        $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...
450
        $hMaxLinha = $this->hMaxLinha;
451
        $cont = 0;
452
        $aFontProdutos = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'');
453
        if ($qtdItens > 0) {
454
            foreach ($this->det as $detI) {
455
                $thisItem   = $detI;
456
                $prod       = $thisItem->getElementsByTagName("prod")->item(0);
457
                $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...
458
                $cProd      = $this->getTagValue($prod, "cProd");
459
                $xProd      = $this->getTagValue($prod, "xProd");
460
                $qCom       = number_format($this->getTagValue($prod, "qCom"), 2, ",", ".");
461
                $uCom       = $this->getTagValue($prod, "uCom");
462
                $vUnCom     = number_format($this->getTagValue($prod, "vUnCom"), 2, ",", ".");
463
                $vProd      = number_format($this->getTagValue($prod, "vProd"), 2, ",", ".");
464
                //COLOCA PRODUTO
465
                $yBoxProd = $y + $hLinha + ($cont*$hMaxLinha);
466
                //COLOCA PRODUTO CÓDIGO
467
                $wBoxCod = $w*0.17;
468
                $texto = $cProd;
469
                $this->pdf->textBox(
470
                    $x,
471
                    $yBoxProd,
472
                    $wBoxCod,
473
                    $hMaxLinha,
474
                    $texto,
475
                    $aFontProdutos,
476
                    'C',
477
                    'C',
478
                    0,
479
                    '',
480
                    false
481
                );
482
                //COLOCA PRODUTO DESCRIÇÃO
483
                $wBoxDescricao = $w*0.43;
484
                $xBoxDescricao = $wBoxCod + $x;
485
                $texto = $xProd;
486
                $this->pdf->textBox(
487
                    $xBoxDescricao,
488
                    $yBoxProd,
489
                    $wBoxDescricao,
490
                    $hMaxLinha,
491
                    $texto,
492
                    $aFontProdutos,
493
                    'C',
494
                    'L',
495
                    0,
496
                    '',
497
                    false
498
                );
499
                //COLOCA PRODUTO QUANTIDADE
500
                $wBoxQt = $w*0.08;
501
                $xBoxQt = $wBoxDescricao + $xBoxDescricao;
502
                $texto = $qCom;
503
                $this->pdf->textBox(
504
                    $xBoxQt,
505
                    $yBoxProd,
506
                    $wBoxQt,
507
                    $hMaxLinha,
508
                    $texto,
509
                    $aFontProdutos,
510
                    'C',
511
                    'C',
512
                    0,
513
                    '',
514
                    false
515
                );
516
                //COLOCA PRODUTO UNIDADE
517
                $wBoxUn = $w*0.06;
518
                $xBoxUn = $wBoxQt + $xBoxQt;
519
                $texto = $uCom;
520
                $this->pdf->textBox(
521
                    $xBoxUn,
522
                    $yBoxProd,
523
                    $wBoxUn,
524
                    $hMaxLinha,
525
                    $texto,
526
                    $aFontProdutos,
527
                    'C',
528
                    'C',
529
                    0,
530
                    '',
531
                    false
532
                );
533
                //COLOCA PRODUTO VL UNITÁRIO
534
                $wBoxVl = $w*0.13;
535
                $xBoxVl = $wBoxUn + $xBoxUn;
536
                $texto = $vUnCom;
537
                $this->pdf->textBox(
538
                    $xBoxVl,
539
                    $yBoxProd,
540
                    $wBoxVl,
541
                    $hMaxLinha,
542
                    $texto,
543
                    $aFontProdutos,
544
                    'C',
545
                    'R',
546
                    0,
547
                    '',
548
                    false
549
                );
550
                //COLOCA PRODUTO VL TOTAL
551
                $wBoxTotal = $w*0.13;
552
                $xBoxTotal = $wBoxVl + $xBoxVl;
553
                $texto = $vProd;
554
                $this->pdf->textBox(
555
                    $xBoxTotal,
556
                    $yBoxProd,
557
                    $wBoxTotal,
558
                    $hMaxLinha,
559
                    $texto,
560
                    $aFontProdutos,
561
                    'C',
562
                    'R',
563
                    0,
564
                    '',
565
                    false
566
                );
567
                
568
                $cont++;
569
            }
570
        }
571
    }
572
    
573
    protected function totalDANFE($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...
574
    {
575
        $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...
576
        $maxW = $this->wPrint;
577
        $hLinha = 3;
578
        $wColEsq = ($maxW*0.7);
579
        $wColDir = ($maxW*0.3);
580
        $xValor = $x + $wColEsq;
581
        $qtdItens = $this->det->length;
582
        $vProd = $this->getTagValue($this->ICMSTot, "vProd");
583
        $vNF = $this->getTagValue($this->ICMSTot, "vNF");
584
        $vDesc  = $this->getTagValue($this->ICMSTot, "vDesc");
585
        $vFrete = $this->getTagValue($this->ICMSTot, "vFrete");
586
        $vTotTrib = $this->getTagValue($this->ICMSTot, "vTotTrib");
587
        $texto = "Qtd. Total de Itens";
588
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
589
        $this->pdf->textBox($x, $y, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
590
        $texto = $qtdItens;
591
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
592
        $this->pdf->textBox($xValor, $y, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
593
        $yTotal = $y + ($hLinha);
594
        $texto = "Total de Produtos";
595
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
596
        $this->pdf->textBox($x, $yTotal, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
597
        $texto = "R$ " . number_format($vProd, 2, ",", ".");
598
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
599
        $this->pdf->textBox($xValor, $yTotal, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
600
        $yDesconto = $y + ($hLinha*2);
601
        $texto = "Descontos";
602
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
603
        $this->pdf->textBox($x, $yDesconto, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
604
        $texto = "R$ " . $vDesc;
605
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
606
        $this->pdf->textBox($xValor, $yDesconto, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
607
        $yFrete= $y + ($hLinha*3);
608
        $texto = "Frete";
609
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
610
        $this->pdf->textBox($x, $yFrete, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
611
        $texto = "R$ " . $vFrete;
612
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
613
        $this->pdf->textBox($xValor, $yFrete, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
614
        $yTotalFinal = $y + ($hLinha*4);
615
        $texto = "Total";
616
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
617
        $this->pdf->textBox($x, $yTotalFinal, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
618
        $texto = "R$ " . $vNF;
619
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
620
        $this->pdf->textBox($xValor, $yTotalFinal, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
621
        $yTotalFinal = $y + ($hLinha*5);
622
        $texto = "Informação dos Tributos Totais Incidentes";
623
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>''];
624
        $this->pdf->textBox($x, $yTotalFinal, $wColEsq, $hLinha, $texto, $aFont, 'T', 'L', 0, '', false);
625
        $texto = "R$ " . $vTotTrib;
626
        $aFont = ['font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B'];
627
        $this->pdf->textBox($xValor, $yTotalFinal, $wColDir, $hLinha, $texto, $aFont, 'T', 'R', 0, '', false);
628
    }
629
    
630
    protected function pagamentosDANFE($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...
631
    {
632
        $y += 6;
633
        $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...
634
        $maxW = $this->wPrint;
635
        $qtdPgto = $this->pag->length;
636
        $w = ($maxW*1);
637
        $hLinha = $this->hLinha;
638
        $wColEsq = ($maxW*0.7);
639
        $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...
640
        $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...
641
        $aFontPgto = array('font'=>$this->fontePadrao, 'size'=>7, 'style'=>'B');
642
        $wBoxEsq = $w*0.7;
643
        $texto = "FORMA DE PAGAMENTO";
644
        $this->pdf->textBox($x, $y, $wBoxEsq, $hLinha, $texto, $aFontPgto, 'T', 'L', 0, '', false);
645
        $wBoxDir = $w*0.3;
646
        $xBoxDescricao = $x + $wBoxEsq;
647
        $texto = "VALOR PAGO";
648
        $this->pdf->textBox($xBoxDescricao, $y, $wBoxDir, $hLinha, $texto, $aFontPgto, 'T', 'R', 0, '', false);
649
        $cont = 0;
650
        if ($qtdPgto > 0) {
651
            foreach ($this->pag as $pagI) {
652
                $tPag = $this->getTagValue($pagI, "tPag");
653
                $tPagNome = $this->tipoPag($tPag);
654
                $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...
655
                $vPag = number_format($this->getTagValue($pagI, "vPag"), 2, ",", ".");
656
                $card = $pagI->getElementsByTagName("card")->item(0);
657
                $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...
658
                $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...
659
                $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...
660
                if (isset($card)) {
661
                    $cardCNPJ = $this->getTagValue($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...
662
                    $tBand    = $this->getTagValue($card, "tBand");
663
                    $cAut = $this->getTagValue($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...
664
                    $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...
665
                }
666
                //COLOCA PRODUTO
667
                $yBoxProd = $y + $hLinha + ($cont*$hLinha);
668
                //COLOCA PRODUTO CÓDIGO
669
                $texto = $tPagNome;
670
                $this->pdf->textBox($x, $yBoxProd, $wBoxEsq, $hLinha, $texto, $aFontPgto, 'T', 'L', 0, '', false);
671
                //COLOCA PRODUTO DESCRIÇÃO
672
                $xBoxDescricao = $wBoxEsq + $x;
673
                $texto = "R$ " . $vPag;
674
                $this->pdf->textBox(
675
                    $xBoxDescricao,
676
                    $yBoxProd,
677
                    $wBoxDir,
678
                    $hLinha,
679
                    $texto,
680
                    $aFontPgto,
681
                    'C',
682
                    'R',
683
                    0,
684
                    '',
685
                    false
686
                );
687
                $cont++;
688
            }
689
            
690
            if (!empty($this->vTroco)) {
691
                $yBoxProd = $y + $hLinha + ($cont*$hLinha);
692
                //COLOCA PRODUTO CÓDIGO
693
                $texto = 'Troco';
694
                $this->pdf->textBox($x, $yBoxProd, $wBoxEsq, $hLinha, $texto, $aFontPgto, 'T', 'L', 0, '', false);
695
                //COLOCA PRODUTO DESCRIÇÃO
696
                $xBoxDescricao = $wBoxEsq + $x;
697
                $texto = "R$ " . number_format($this->vTroco, 2, ",", ".");
698
                $this->pdf->textBox(
699
                    $xBoxDescricao,
700
                    $yBoxProd,
701
                    $wBoxDir,
702
                    $hLinha,
703
                    $texto,
704
                    $aFontPgto,
705
                    'C',
706
                    'R',
707
                    0,
708
                    '',
709
                    false
710
                );
711
            }
712
        }
713
    }
714
    
715
    protected function fiscalDANFE($x = 0, $y = 0, $h = 0)
716
    {
717
        $y += 6;
718
        $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...
719
        $maxW = $this->wPrint;
720
        $w = ($maxW*1);
721
        $hLinha = $this->hLinha;
722
        $aFontTit = ['font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B'];
723
        $aFontTex = ['font'=>$this->fontePadrao, 'size'=>8, 'style'=>''];
724
        $digVal = $this->getTagValue($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...
725
        $chNFe = str_replace('NFe', '', $this->infNFe->getAttribute("Id"));
726
        $tpAmb = $this->getTagValue($this->ide, 'tpAmb');
0 ignored issues
show
Unused Code introduced by
$tpAmb 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
        
728
        if ($this->checkCancelada()) {
729
            //101 Cancelamento
730
            $this->pdf->setTextColor(255, 0, 0);
731
            $texto = "NFCe CANCELADA";
732
            $this->pdf->textBox($x, $y - 25, $w, $h, $texto, $aFontTit, 'C', 'C', 0, '');
733
            $this->pdf->setTextColor(0, 0, 0);
734
        }
735
        
736
        if ($this->checkDenegada()) {
737
            //uso denegado
738
            $this->pdf->setTextColor(255, 0, 0);
739
            $texto = "NFCe CANCELADA";
740
            $this->pdf->textBox($x, $y - 25, $w, $h, $texto, $aFontTit, 'C', 'C', 0, '');
741
            $this->pdf->SetTextColor(0, 0, 0);
742
        }
743
        
744
        $cUF = $this->getTagValue($this->ide, 'cUF');
0 ignored issues
show
Unused Code introduced by
$cUF 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...
745
        $nNF = $this->getTagValue($this->ide, 'nNF');
746
        $serieNF = str_pad($this->getTagValue($this->ide, "serie"), 3, "0", STR_PAD_LEFT);
747
        $dhEmi = $this->getTagValue($this->ide, "dhEmi");
748
        $dhEmilocal = new \DateTime($dhEmi);
749
        $dhEmiLocalFormat = $dhEmilocal->format('d/m/Y H:i:s');
750
        $texto = "ÁREA DE MENSAGEM FISCAL";
751
        $this->pdf->textBox($x, $y, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 0, '', false);
752
        $yTex1 = $y + ($hLinha*1);
753
        $hTex1 = $hLinha*2;
754
        $texto = "Número " . $nNF . " Série " . $serieNF . " " .$dhEmiLocalFormat . " - Via Consumidor";
755
        $this->pdf->textBox($x, $yTex1, $w, $hTex1, $texto, $aFontTex, 'C', 'C', 0, '', false);
756
        $yTex2 = $y + ($hLinha*3);
757
        $hTex2 = $hLinha*2;
758
        
759
        $texto = !empty($this->urlChave) ? "Consulte pela Chave de Acesso em " . $this->urlChave : '';
760
        $this->pdf->textBox($x, $yTex2, $w, $hTex2, $texto, $aFontTex, 'C', 'C', 0, '', false);
761
        $texto = "CHAVE DE ACESSO";
762
        $yTit2 = $y + ($hLinha*5);
763
        $this->pdf->textBox($x, $yTit2, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 0, '', false);
764
        $yTex3 = $y + ($hLinha*6);
765
        $texto = $chNFe;
766
        $this->pdf->textBox($x, $yTex3, $w, $hLinha, $texto, $aFontTex, 'C', 'C', 0, '', false);
767
    }
768
    
769
    protected function consumidorDANFE($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...
770
    {
771
        $y += 6;
772
        $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...
773
        $maxW = $this->wPrint;
774
        $w = ($maxW*1);
775
        $hLinha = $this->hLinha;
776
        $aFontTit = ['font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B'];
777
        $aFontTex = ['font'=>$this->fontePadrao, 'size'=>8, 'style'=>''];
778
        $texto = "CONSUMIDOR";
779
        $this->pdf->textBox($x, $y, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 0, '', false);
780
        if (isset($this->dest)) {
781
            $considEstrangeiro = !empty($this->dest->getElementsByTagName("idEstrangeiro")->item(0)->nodeValue)
782
                    ? $this->dest->getElementsByTagName("idEstrangeiro")->item(0)->nodeValue
783
                    : '';
784
            $consCPF = !empty($this->dest->getElementsByTagName("CPF")->item(0)->nodeValue)
785
                    ? $this->dest->getElementsByTagName("CPF")->item(0)->nodeValue
786
                    : '';
787
            $consCNPJ = !empty($this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue)
788
                    ? $this->dest->getElementsByTagName("CNPJ")->item(0)->nodeValue
789
                    : '';
790
            $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...
791
            $enderDest = $this->dest->getElementsByTagName("enderDest")->item(0);
792
            $consNome = $this->getTagValue($this->dest, "xNome");
793
            $consLgr = $this->getTagValue($enderDest, "xLgr");
794
            $consNro = $this->getTagValue($enderDest, "nro");
795
            $consCpl = $this->getTagValue($enderDest, "xCpl", " - ");
796
            $consBairro = $this->getTagValue($enderDest, "xBairro");
797
            $consCEP = $this->formatField($this->getTagValue($enderDest, "CEP"));
798
            $consMun = $this->getTagValue($enderDest, "xMun");
799
            $consUF = $this->getTagValue($enderDest, "UF");
800
            $considEstrangeiro = $this->getTagValue($this->dest, "idEstrangeiro");
801
            $consCPF = $this->getTagValue($this->dest, "CPF");
802
            $consCNPJ = $this->getTagValue($this->dest, "CNPJ");
803
            $consDoc = "";
804
            if (!empty($consCNPJ)) {
805
                $consDoc = "CNPJ: $consCNPJ";
806
            } elseif (!empty($consCPF)) {
807
                $consDoc = "CPF: $consCPF";
808
            } elseif (!empty($considEstrangeiro)) {
809
                $consDoc = "id: $considEstrangeiro";
810
            }
811
            $consEnd = "";
812
            if (!empty($consLgr)) {
813
                $consEnd = $consLgr
814
                    . ","
815
                    . $consNro
816
                    . " "
817
                    . $consCpl
818
                    . ","
819
                    . $consBairro
820
                    . ". CEP:"
821
                    . $consCEP
822
                    . ". "
823
                    . $consMun
824
                    . "-"
825
                    . $consUF;
826
            }
827
            $yTex1 = $y + $hLinha;
828
            $texto = $consNome;
829
            if (!empty($consDoc)) {
830
                $texto .= " - ". $consDoc . "\n" . $consEnd;
831
                $this->pdf->textBox($x, $yTex1, $w, $hLinha*3, $texto, $aFontTex, 'C', 'C', 0, '', false);
832
            }
833
        } else {
834
            $yTex1 = $y + $hLinha;
835
            $texto = "Consumidor não identificado";
836
            $this->pdf->textBox($x, $yTex1, $w, $hLinha, $texto, $aFontTex, 'C', 'C', 0, '', false);
837
        }
838
    }
839
    
840
    protected function qrCodeDANFE($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...
841
    {
842
        $y += 6;
843
        $margemInterna = $this->margemInterna;
844
        $maxW = $this->wPrint;
845
        $w = ($maxW*1)+4;
846
        $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...
847
        $hBoxLinha = $this->hBoxLinha;
848
        $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...
849
        $aFontTex = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
850
        $dhRecbto = '';
851
        $nProt = '';
852
        if (isset($this->nfeProc)) {
853
            $nProt = $this->getTagValue($this->nfeProc, "nProt");
854
            $dhRecbto  = $this->getTagValue($this->nfeProc, "dhRecbto");
855
        }
856
        $barcode = new Barcode();
857
        $bobj = $barcode->getBarcodeObj(
858
            'QRCODE,M',
859
            $this->qrCode,
860
            -4,
861
            -4,
862
            'black',
863
            array(-2, -2, -2, -2)
864
        )->setBackgroundColor('white');
865
        $qrcode = $bobj->getPngData();
866
        $wQr = 50;
867
        $hQr = 50;
868
        $yQr = ($y+$margemInterna);
869
        $xQr = ($w/2) - ($wQr/2);
870
        // prepare a base64 encoded "data url"
871
        $pic = 'data://text/plain;base64,' . base64_encode($qrcode);
872
        $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...
873
        $this->pdf->image($pic, $xQr, $yQr, $wQr, $hQr, 'PNG');
874
        $dt = new DateTime($dhRecbto);
875
        $yQr = ($yQr+$hQr+$margemInterna);
876
        $this->pdf->textBox($x, $yQr, $w-4, $hBoxLinha, "Protocolo de Autorização: " . $nProt . "\n"
877
            . $dt->format('d/m/Y H:i:s'), $aFontTex, 'C', 'C', 0, '', false);
878
    }
879
   
880
    protected function infAdic($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...
881
    {
882
        $y += 17;
883
        $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...
884
        $maxW = $this->wPrint;
885
        $w = ($maxW * 1);
886
        $hLinha = $this->hLinha;
887
        $aFontTit = ['font' => $this->fontePadrao, 'size' => 8, 'style' => 'B'];
888
        $aFontTex = ['font' => $this->fontePadrao, 'size' => 8, 'style' => ''];
889
        // seta o textbox do titulo
890
        $texto = "INFORMAÇÃO ADICIONAL";
891
        $heigthText = $this->pdf->textBox($x, $y, $w, $hLinha, $texto, $aFontTit, 'C', 'C', 0, '', false);
0 ignored issues
show
Unused Code introduced by
$heigthText 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...
892
                
893
        // seta o textbox do texto adicional
894
        $this->pdf->textBox($x, $y+3, $w-2, $hLinha-3, $this->textoAdic, $aFontTex, 'T', 'L', 0, '', false);
895
    }
896
    
897
    /**
898
     * printDANFE
899
     * Esta função envia a DANFE em PDF criada para o dispositivo informado.
900
     * O destino da impressão pode ser :
901
     * I-browser
902
     * D-browser com download
903
     * F-salva em um arquivo local com o nome informado
904
     * S-retorna o documento como uma string e o nome é ignorado.
905
     * Para enviar o pdf diretamente para uma impressora indique o
906
     * nome da impressora e o destino deve ser 'S'.
907
     *
908
     * @param  string $nome    Path completo com o nome do arquivo pdf
909
     * @param  string $destino Direção do envio do PDF
910
     * @param  string $printer Identificação da impressora no sistema
911
     * @return string Caso o destino seja S o pdf é retornado como uma string
912
     * @todo   Rotina de impressão direta do arquivo pdf criado
913
     */
914
    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...
915
    {
916
        $arq = $this->pdf->Output($nome, $destino);
917
        if ($destino == 'S') {
918
            //aqui pode entrar a rotina de impressão direta
919
        }
920
        return $arq;
921
    }
922
    /**
923
     * Dados brutos do PDF
924
     * @return string
925
     */
926
    public function render()
927
    {
928
        return $this->pdf->getPdf();
929
    }
930
    
931
    /**
932
     * anfavea
933
     * Função para transformar o campo cdata do padrão ANFAVEA para
934
     * texto imprimível
935
     *
936
     * @param  string $cdata campo CDATA
937
     * @return string conteúdo do campo CDATA como string
938
     */
939
    protected function anfaveaDANFE($cdata = '')
940
    {
941
        if ($cdata == '') {
942
            return '';
943
        }
944
        //remove qualquer texto antes ou depois da tag CDATA
945
        $cdata = str_replace('<![CDATA[', '<CDATA>', $cdata);
946
        $cdata = str_replace(']]>', '</CDATA>', $cdata);
947
        $cdata = preg_replace('/\s\s+/', ' ', $cdata);
948
        $cdata = str_replace("> <", "><", $cdata);
949
        $len = strlen($cdata);
950
        $startPos = strpos($cdata, '<');
951
        if ($startPos === false) {
952
            return $cdata;
953
        }
954
        for ($x=$len; $x>0; $x--) {
955
            if (substr($cdata, $x, 1) == '>') {
956
                $endPos = $x;
957
                break;
958
            }
959
        }
960
        if ($startPos > 0) {
961
            $parte1 = substr($cdata, 0, $startPos);
962
        } else {
963
            $parte1 = '';
964
        }
965
        $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...
966
        if ($endPos < $len) {
967
            $parte3 = substr($cdata, $endPos + 1, $len - $endPos - 1);
968
        } else {
969
            $parte3 = '';
970
        }
971
        $texto = trim($parte1).' '.trim($parte3);
972
        if (strpos($parte2, '<CDATA>') === false) {
973
            $cdata = '<CDATA>'.$parte2.'</CDATA>';
974
        } else {
975
            $cdata = $parte2;
976
        }
977
        //carrega o xml CDATA em um objeto DOM
978
        $dom = new Dom();
979
        $dom->loadXML($cdata, LIBXML_NOBLANKS | LIBXML_NOEMPTYTAG);
980
        //$xml = $dom->saveXML();
981
        //grupo CDATA infADprod
982
        $id = $dom->getElementsByTagName('id')->item(0);
983
        $div = $dom->getElementsByTagName('div')->item(0);
984
        $entg = $dom->getElementsByTagName('entg')->item(0);
985
        $dest = $dom->getElementsByTagName('dest')->item(0);
986
        $ctl = $dom->getElementsByTagName('ctl')->item(0);
987
        $ref = $dom->getElementsByTagName('ref')->item(0);
988
        if (isset($id)) {
989
            if ($id->hasAttributes()) {
990
                foreach ($id->attributes as $attr) {
991
                    $name = $attr->nodeName;
992
                    $value = $attr->nodeValue;
993
                    $texto .= " $name : $value";
994
                }
995
            }
996
        }
997
        if (isset($div)) {
998
            if ($div->hasAttributes()) {
999
                foreach ($div->attributes as $attr) {
1000
                    $name = $attr->nodeName;
1001
                    $value = $attr->nodeValue;
1002
                    $texto .= " $name : $value";
1003
                }
1004
            }
1005
        }
1006
        if (isset($entg)) {
1007
            if ($entg->hasAttributes()) {
1008
                foreach ($entg->attributes as $attr) {
1009
                    $name = $attr->nodeName;
1010
                    $value = $attr->nodeValue;
1011
                    $texto .= " $name : $value";
1012
                }
1013
            }
1014
        }
1015
        if (isset($dest)) {
1016
            if ($dest->hasAttributes()) {
1017
                foreach ($dest->attributes as $attr) {
1018
                    $name = $attr->nodeName;
1019
                    $value = $attr->nodeValue;
1020
                    $texto .= " $name : $value";
1021
                }
1022
            }
1023
        }
1024
        if (isset($ctl)) {
1025
            if ($ctl->hasAttributes()) {
1026
                foreach ($ctl->attributes as $attr) {
1027
                    $name = $attr->nodeName;
1028
                    $value = $attr->nodeValue;
1029
                    $texto .= " $name : $value";
1030
                }
1031
            }
1032
        }
1033
        if (isset($ref)) {
1034
            if ($ref->hasAttributes()) {
1035
                foreach ($ref->attributes as $attr) {
1036
                    $name = $attr->nodeName;
1037
                    $value = $attr->nodeValue;
1038
                    $texto .= " $name : $value";
1039
                }
1040
            }
1041
        }
1042
        //grupo CADATA infCpl
1043
        $t = $dom->getElementsByTagName('transmissor')->item(0);
1044
        $r = $dom->getElementsByTagName('receptor')->item(0);
1045
        $versao = ! empty($dom->getElementsByTagName('versao')->item(0)->nodeValue) ?
1046
        'Versao:'.$dom->getElementsByTagName('versao')->item(0)->nodeValue.' ' : '';
1047
        $especieNF = ! empty($dom->getElementsByTagName('especieNF')->item(0)->nodeValue) ?
1048
        'Especie:'.$dom->getElementsByTagName('especieNF')->item(0)->nodeValue.' ' : '';
1049
        $fabEntrega = ! empty($dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue) ?
1050
        'Entrega:'.$dom->getElementsByTagName('fabEntrega')->item(0)->nodeValue.' ' : '';
1051
        $dca = ! empty($dom->getElementsByTagName('dca')->item(0)->nodeValue) ?
1052
        'dca:'.$dom->getElementsByTagName('dca')->item(0)->nodeValue.' ' : '';
1053
        $texto .= "".$versao.$especieNF.$fabEntrega.$dca;
1054
        if (isset($t)) {
1055
            if ($t->hasAttributes()) {
1056
                $texto .= " Transmissor ";
1057
                foreach ($t->attributes as $attr) {
1058
                    $name = $attr->nodeName;
1059
                    $value = $attr->nodeValue;
1060
                    $texto .= " $name : $value";
1061
                }
1062
            }
1063
        }
1064
        if (isset($r)) {
1065
            if ($r->hasAttributes()) {
1066
                $texto .= " Receptor ";
1067
                foreach ($r->attributes as $attr) {
1068
                    $name = $attr->nodeName;
1069
                    $value = $attr->nodeValue;
1070
                    $texto .= " $name : $value";
1071
                }
1072
            }
1073
        }
1074
        return $texto;
1075
    }
1076
    
1077
    protected static function getCardName($tBand)
1078
    {
1079
        switch ($tBand) {
1080
            case '01':
1081
                $tBandNome = 'VISA';
1082
                break;
1083
            case '02':
1084
                $tBandNome = 'MASTERCARD';
1085
                break;
1086
            case '03':
1087
                $tBandNome = 'AMERICAM EXPRESS';
1088
                break;
1089
            case '04':
1090
                $tBandNome = 'SOROCRED';
1091
                break;
1092
            case '99':
1093
                $tBandNome = 'OUTROS';
1094
                break;
1095
            default:
1096
                $tBandNome = '';
1097
        }
1098
        return $tBandNome;
1099
    }
1100
      
1101
    protected function checkCancelada()
1102
    {
1103
        if (!isset($this->nfeProc)) {
1104
            return false;
1105
        }
1106
        $cStat = $this->getTagValue($this->nfeProc, "cStat");
1107
        return $cStat == '101' ||
1108
                $cStat == '151' ||
1109
                $cStat == '135' ||
1110
                $cStat == '155';
1111
    }
1112
1113
    protected function checkDenegada()
1114
    {
1115
        if (!isset($this->nfeProc)) {
1116
            return false;
1117
        }
1118
        //NÃO ERA NECESSÁRIO ESSA FUNÇÃO POIS SÓ SE USA
1119
        //1 VEZ NO ARQUIVO INTEIRO
1120
        $cStat = $this->getTagValue($this->nfeProc, "cStat");
1121
        return $cStat == '110' ||
1122
               $cStat == '301' ||
1123
               $cStat == '302';
1124
    }
1125
}
1126