Completed
Push — master ( 3fba58...416ed3 )
by Roberto
04:47
created

DanfcePos::tipoPag()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 19
ccs 0
cts 19
cp 0
rs 9.4285
cc 2
eloc 15
nc 2
nop 1
crap 6
1
<?php
2
3
namespace Posprint;
4
5
/**
6
 * Esta classe foi colocada aqui apneas para facilitar o desenvolvimento, seu local correto
7
 * é no repositório sped-da
8
 *
9
 * em caso de contingência criar duas vias consumidor e estabelecimento
10
 */
11
12
use Posprint\Printers\PrinterInterface;
13
use InvalidArgumentException;
14
15
class DanfcePos
16
{
17
    /**
18
     * NFCe
19
     * @var SimpleXMLElement
20
     */
21
    protected $nfce = '';
22
    /**
23
     * protNFe
24
     * @var SimpleXMLElement
25
     */
26
    protected $protNFe = '';
27
    /**
28
     * Printer
29
     * @var PrinterInterface
30
     */
31
    protected $printer;
32
    /**
33
     * Documento montado
34
     * @var array
35
     */
36
    protected $da = array();
37
    /**
38
     * Total de itens da NFCe
39
     * @var integer
40
     */
41
    protected $totItens = 0;
42
    
43
    /**
44
     * URI referente a pagina de consulta da NFCe pela chave de acesso
45
     * @var string
46
     */
47
    protected $uri = '';
48
    
49
    protected $aURI = [
50
      'AC' => 'http://sefaznet.ac.gov.br/nfce/consulta.xhtml',
51
      'AM' => 'http://sistemas.sefaz.am.gov.br/nfceweb/formConsulta.do',
52
      'BA' => 'http://nfe.sefaz.ba.gov.br/servicos/nfce/Modulos/Geral/NFCEC_consulta_chave_acesso.aspx',
53
      'MT' => 'https://www.sefaz.mt.gov.br/nfce/consultanfce',
54
      'MA' => 'http://www.nfce.sefaz.ma.gov.br/portal/consultaNFe.do?method=preFilterCupom&',
55
      'PA' => 'https://appnfc.sefa.pa.gov.br/portal/view/consultas/nfce/consultanfce.seam',
56
      'PB' => 'https://www.receita.pb.gov.br/ser/servirtual/documentos-fiscais/nfc-e/consultar-nfc-e',
57
      'PR' => 'http://www.sped.fazenda.pr.gov.br/modules/conteudo/conteudo.php?conteudo=100',
58
      'RJ' => 'http://www4.fazenda.rj.gov.br/consultaDFe/paginas/consultaChaveAcesso.faces',
59
      'RS' => 'https://www.sefaz.rs.gov.br/NFE/NFE-COM.aspx',
60
      'RO' => 'http://www.nfce.sefin.ro.gov.br/home.jsp',
61
      'RR' => 'https://www.sefaz.rr.gov.br/nfce/servlet/wp_consulta_nfce',
62
      'SE' => 'http://www.nfce.se.gov.br/portal/portalNoticias.jsp?jsp=barra-menu/servicos/consultaDANFENFCe.htm',
63
      'SP' => 'https://www.nfce.fazenda.sp.gov.br/NFCeConsultaPublica/Paginas/ConsultaPublica.aspx'
64
    ];
65
66
    /**
67
     * Carrega a impressora a ser usada
68
     * a mesma deverá já ter sido pré definida inclusive seu
69
     * conector
70
     *
71
     * @param PrinterInterface $this->printer
0 ignored issues
show
Documentation introduced by
There is no parameter named $this->printer. Did you maybe mean $printer?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

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

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

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

Loading history...
72
     */
73
    public function __construct(PrinterInterface $printer)
74
    {
75
        $this->printer = $printer;
76
    }
77
    
78
    /**
79
     * Carrega a NFCe
80
     * @param string $nfcexml
81
     */
82
    public function loadNFCe($nfcexml)
83
    {
84
        $xml = $nfcexml;
85
        if (is_file($nfcexml)) {
86
            $xml = @file_get_contents($nfcexml);
87
        }
88
        if (empty($xml)) {
89
            throw new InvalidArgumentException('Não foi possivel ler o documento.');
90
        }
91
        $nfe = simplexml_load_string($xml, null, LIBXML_NOCDATA);
92
        $this->protNFe = $nfe->protNFe;
0 ignored issues
show
Bug introduced by
The property protNFe does not seem to exist in SimpleXMLElement.

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

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

Loading history...
93
        $this->nfce = $nfe->NFe;
0 ignored issues
show
Bug introduced by
The property NFe does not seem to exist in SimpleXMLElement.

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

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

Loading history...
94
        if (empty($this->protNFe)) {
95
            //NFe sem protocolo
96
            $this->nfce = $nfe;
0 ignored issues
show
Documentation Bug introduced by
It seems like $nfe of type object<SimpleXMLElement> is incompatible with the declared type object<Posprint\SimpleXMLElement> of property $nfce.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
97
        }
98
    }
99
    
100
    /**
101
     * Monta a DANFCE para uso de impressoras POS
102
     */
103
    public function monta()
104
    {
105
        $this->parteI();
106
        $this->parteII();
107
        $this->parteIII();
108
        $this->parteIV();
109
        $this->parteV();
110
        $this->parteVI();
111
        $this->parteVII();
112
        $this->parteVIII();
113
        $this->parteIX();
114
    }
115
    
116
    /**
117
     * Manda os dados para a impressora ou
118
     * retorna os comandos em ordem e legiveis
119
     * para a tela
120
     */
121
    public function printDanfe()
122
    {
123
        $resp = $this->printer->send();
124
        if (!empty($resp)) {
125
            echo str_replace("\n", "<br>", $resp);
126
        }
127
    }
128
    
129
    /**
130
     * Recupera a sequiencia de comandos para envio
131
     * posterior para a impressora por outro
132
     * meio como o QZ.io (tray)
133
     *
134
     * @return string
135
     */
136
    public function getCommands()
137
    {
138
        $aCmds = $this->printer->getBuffer('binA');
139
        return implode("\n", $aCmds);
140
    }
141
    
142
    /**
143
     * Parte I - Emitente
144
     * Dados do emitente
145
     * Campo Obrigatório
146
     */
147
    protected function parteI()
148
    {
149
        $razao = (string) $this->nfce->infNFe->emit->xNome;
150
        $cnpj = (string) $this->nfce->infNFe->emit->CNPJ;
151
        $ie = (string) $this->nfce->infNFe->emit->IE;
152
        $im = (string) $this->nfce->infNFe->emit->IM;
153
        $log = (string) $this->nfce->infNFe->emit->enderEmit->xLgr;
154
        $nro = (string) $this->nfce->infNFe->emit->enderEmit->nro;
155
        $bairro = (string) $this->nfce->infNFe->emit->enderEmit->xBairro;
156
        $mun = (string) $this->nfce->infNFe->emit->enderEmit->xMun;
157
        $uf = (string) $this->nfce->infNFe->emit->enderEmit->UF;
158
        if (array_key_exists($uf, $this->aURI)) {
159
            $this->uri = $this->aURI[$uf];
160
        }
161
        $this->printer->setAlign('C');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::setAlign() has too many arguments starting with 'C'.

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...
162
        $this->printer->text($razao);
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with $razao.

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...
163
        $this->printer->text('CNPJ: '.$cnpj.'     '.'IE: ' . $ie);
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with 'CNPJ: ' . $cnpj . ' ' . 'IE: ' . $ie.

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...
164
        $this->printer->text('IM: '.$im);
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with 'IM: ' . $im.

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...
165
        $this->printer->setAlign('L');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::setAlign() has too many arguments starting with 'L'.

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...
166
        //o que acontece quando o texto é maior que o numero de carecteres da linha ??
167
        $this->printer->text($log . ', ' . $nro . ' ' . $bairro . ' ' . $mun . ' ' . $uf);
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with $log . ', ' . $nro . ' '... ' ' . $mun . ' ' . $uf.

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...
168
        //linha divisória ??
169
    }
170
    
171
    /**
172
     * Parte II - Informações Gerais
173
     * Campo Obrigatório
174
     */
175
    protected function parteII()
176
    {
177
        $this->printer->setAlign('C');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::setAlign() has too many arguments starting with 'C'.

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...
178
        $this->printer->text('DANFE NFC-e Documento Auxiliar');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with 'DANFE NFC-e Documento Auxiliar'.

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...
179
        $this->printer->text('da Nota Fiscal eletrônica para consumidor final');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with 'da Nota Fiscal eletrôn... para consumidor final'.

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...
180
        $this->printer->setBold();
181
        $this->printer->text('Não permite aproveitamento de crédito de ICMS');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with 'Não permite aproveitamento de crédito de ICMS'.

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...
182
        $this->printer->setBold();
183
        //linha divisória ??
184
    }
185
    
186
    /**
187
     * Parte III - Detalhes da Venda
188
     * Campo Opcional
189
     */
190
    protected function parteIII()
191
    {
192
        $this->printer->setAlign('L');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::setAlign() has too many arguments starting with 'L'.

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...
193
        $this->printer->text('Item Cod   Desc         Qtd    V.Unit  V.Total');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with 'Item Cod Desc Qtd V.Unit V.Total'.

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...
194
        //obter dados dos itens da NFCe
195
        $det = $this->nfce->infNFe->det;
196
        $this->totItens = $det->count();
197
        for ($x=0; $x<=$this->totItens-1; $x++) {
198
            $nItem = (int) $det[$x]->attributes()->{'nItem'};
199
            $cProd = (string) $det[$x]->prod->cProd;
200
            $xProd = (string) $det[$x]->prod->xProd;
201
            $qCom = (float) $det[$x]->prod->qCom;
202
            $uCom = (string) $det[$x]->prod->uCom;
203
            $vUnCom = (float) $det[$x]->prod->vUnCom;
204
            $vProd = (float) $det[$x]->prod->vProd;
205
            //falta formatar os campos e o espaçamento entre eles
206
            $this->printer->text($nItem .  $cProd. $xProd . $qCom . $uCom . $vUnCom . $vProd);
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with $nItem . $cProd . $xProd...uCom . $vUnCom . $vProd.

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...
207
        }
208
        //linha divisória ??
209
    }
210
    
211
    /**
212
     * Parte V - Informação de tributos
213
     * Campo Obrigatório
214
     */
215
    protected function parteIV()
216
    {
217
        $vTotTrib = (float) $this->nfce->infNFe->total->ICMSTot->vTotTrib;
218
        $this->printer->setAlign('L');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::setAlign() has too many arguments starting with 'L'.

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...
219
        $this->printer->text('Informação dos Tributos Totais:' . '' . 'R$ ' .  $vTotTrib);
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with 'Informação dos Tribut... '' . 'R$ ' . $vTotTrib.

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...
220
        $this->printer->text('Incidentes (Lei Federal 12.741 /2012) - Fonte IBPT');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with 'Incidentes (Lei Federal...41 /2012) - Fonte IBPT'.

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...
221
        //linha divisória ??
222
    }
223
    
224
    /**
225
     * Parte IV - Totais da Venda
226
     * Campo Obrigatório
227
     */
228
    protected function parteV()
229
    {
230
        $vNF = (float) $this->nfce->infNFe->total->ICMSTot->vNF;
231
        $this->printer->setAlign('L');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::setAlign() has too many arguments starting with 'L'.

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...
232
        $this->printer->text('QTD. TOTAL DE ITENS' . ' ' . $this->totItens);
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with 'QTD. TOTAL DE ITENS' . ' ' . $this->totItens.

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...
233
        $this->printer->text('VALOR TOTAL            R$ ' . $vNF);
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with 'VALOR TOTAL R$ ' . $vNF.

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...
234
        $this->printer->text('FORMA PAGAMENTO          VALOR PAGO');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with 'FORMA PAGAMENTO VALOR PAGO'.

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...
235
        $pag = $this->nfce->infNFe->pag;
236
        $tot = $pag->count();
237
        for ($x=0; $x<=$tot-1; $x++) {
238
            $tPag = (string) $this->tipoPag($pag[0]->tPag);
239
            $vPag = (float) $pag[0]->vPag;
240
            $this->printer->text($tPag . '                  R$ '. $vPag);
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with $tPag . ' R$ ' . $vPag.

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...
241
        }
242
        //linha divisória ??
243
    }
244
    
245
    /**
246
     * Parte VI - Mensagem de Interesse do Contribuinte
247
     * conteudo de infCpl
248
     * Campo Opcional
249
     */
250
    protected function parteVI()
251
    {
252
        $infCpl = (string) $this->nfce->infNFe->infAdic->infCpl;
253
        $this->printer->setAlign('L');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::setAlign() has too many arguments starting with 'L'.

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...
254
        $this->printer->text($infCpl);
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with $infCpl.

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...
255
        $this->printer->lineFeed();
256
        //linha divisória ??
257
    }
258
    
259
    /**
260
     * Parte VII - Mensagem Fiscal e Informações da Consulta via Chave de Acesso
261
     * Campo Obrigatório
262
     */
263
    protected function parteVII()
264
    {
265
        $tpAmb = (int) $this->nfce->infNFe->ide->tpAmb;
266
        if ($tpAmb == 2) {
267
            $this->printer->setAlign('C');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::setAlign() has too many arguments starting with 'C'.

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...
268
            $this->printer->text('EMITIDA EM AMBIENTE DE HOMOLOGAÇÃO - SEM VALOR FISCAL');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with 'EMITIDA EM AMBIENTE DE ...ÃO - SEM VALOR FISCAL'.

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...
269
        }
270
        $tpEmis = (int) $this->nfce->infNFe->ide->tpEmis;
271
        if ($tpEmis != 1) {
272
            $this->printer->setAlign('C');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::setAlign() has too many arguments starting with 'C'.

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...
273
            $this->printer->text('EMITIDA EM AMBIENTE DE CONTINGẼNCIA');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with 'EMITIDA EM AMBIENTE DE CONTINGẼNCIA'.

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...
274
        }
275
        $nNF = (float) $this->nfce->infNFe->ide->nNF;
276
        $serie = (int) $this->nfce->infNFe->ide->serie;
277
        $dhEmi = (string) $this->nfce->infNFe->ide->dhEmi;
278
        $Id = (string) $this->nfce->infNFe->attributes()->{'Id'};
279
        $chave = substr($Id, 3, strlen($Id)-3);
280
        $this->printer->setAlign('L');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::setAlign() has too many arguments starting with 'L'.

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...
281
        $this->printer->text('Nr. ' . $nNF. ' Serie ' .$serie . ' Emissão ' .$dhEmi . ' via Consumidor');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with 'Nr. ' . $nNF . ' Serie ...Emi . ' via Consumidor'.

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...
282
        $this->printer->setAlign('C');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::setAlign() has too many arguments starting with 'C'.

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...
283
        $this->printer->text('Consulte pela chave de acesso em');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with 'Consulte pela chave de acesso em'.

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...
284
        $this->printer->text($this->uri);
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with $this->uri.

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...
285
        $this->printer->text('CHAVE DE ACESSO');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with 'CHAVE DE ACESSO'.

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...
286
        $this->printer->text($chave);
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with $chave.

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...
287
        //linha divisória ??
288
    }
289
    
290
    /**
291
     * Parte VIII - Informações sobre o Consumidor
292
     * Campo Opcional
293
     */
294
    protected function parteVIII()
295
    {
296
        $this->printer->setAlign('C');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::setAlign() has too many arguments starting with 'C'.

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...
297
        $dest = $this->nfce->infNFe->dest;
298
        if (empty($dest)) {
299
            $this->printer->text('CONSUMIDOR NÃO IDENTIFICADO');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with 'CONSUMIDOR NÃO IDENTIFICADO'.

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...
300
            return;
301
        }
302
        $xNome = (string) $this->nfce->infNFe->dest->xNome;
303
        $this->printer->text($xNome);
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with $xNome.

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...
304
        $cnpj = (string) $this->nfce->infNFe->dest->CNPJ;
305
        $cpf = (string) $this->nfce->infNFe->dest->CPF;
306
        $idEstrangeiro = (string) $this->nfce->infNFe->dest->idEstrangeiro;
307
        $this->printer->setAlign('L');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::setAlign() has too many arguments starting with 'L'.

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...
308
        if (!empty($cnpj)) {
309
            $this->printer->text('CNPJ ' . $cnpj);
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with 'CNPJ ' . $cnpj.

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...
310
        }
311
        if (!empty($cpf)) {
312
            $this->printer->text('CPF ' . $cpf);
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with 'CPF ' . $cpf.

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...
313
        }
314
        if (!empty($idEstrangeiro)) {
315
            $this->printer->text('Extrangeiro ' . $idEstrangeiro);
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with 'Extrangeiro ' . $idEstrangeiro.

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...
316
        }
317
        $xLgr = (string) $this->nfce->infNFe->dest->enderDest->xLgr;
318
        $nro = (string) $this->nfce->infNFe->dest->enderDest->nro;
319
        $xCpl = (string) $this->nfce->infNFe->dest->enderDest->xCpl;
320
        $xBairro = (string) $this->nfce->infNFe->dest->enderDest->xBairro;
321
        $xMun = (string) $this->nfce->infNFe->dest->enderDest->xMun;
322
        $uf = (string) $this->nfce->infNFe->dest->enderDest->UF;
323
        $cep = (string) $this->nfce->infNFe->dest->enderDest->CEP;
0 ignored issues
show
Unused Code introduced by
$cep 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...
324
        $this->printer->text($xLgr . '' . $nro . '' . $xCpl . '' . $xBairro . '' . $xMun . '' . $uf);
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with $xLgr . '' . $nro . '' ..... '' . $xMun . '' . $uf.

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...
325
        //linha divisória ??
326
    }
327
    
328
    /**
329
     * Parte IX - QRCode
330
     * Consulte via Leitor de QRCode
331
     * Protocolo de autorização 1234567891234567 22/06/2016 14:43:51
332
     * Campo Obrigatório
333
     */
334
    protected function parteIX()
335
    {
336
        $this->printer->setAlign('C');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::setAlign() has too many arguments starting with 'C'.

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...
337
        $this->printer->text('Consulte via Leitor de QRCode');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with 'Consulte via Leitor de QRCode'.

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...
338
        $qr = (string) $this->nfce->infNFeSupl->qrCode;
339
        $this->printer->barcodeQRCode($qr);
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::barcodeQRCode() has too many arguments starting with $qr.

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...
340
        if (!empty($this->protNFe)) {
341
            $nProt = (string) $this->protNFe->infProt->nProt;
342
            $dhRecbto = (string) $this->protNFe->infProt->dhRecbto;
343
            $this->printer->text('Protocolo de autorização ' . $nProt . $dhRecbto);
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with 'Protocolo de autorizaç... ' . $nProt . $dhRecbto.

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...
344
        } else {
345
            $this->printer->setBold();
346
            $this->printer->text('NOTA FISCAL INVÁLIDA - SEM PROTOCOLO DE AUTORIZAÇÃO');
0 ignored issues
show
Unused Code introduced by
The call to PrinterInterface::text() has too many arguments starting with 'NOTA FISCAL INVÁLIDA -...OCOLO DE AUTORIZAÇÃO'.

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...
347
            $this->printer->lineFeed();
348
        }
349
    }
350
    
351
    /**
352
     * Retorna o texto referente ao tipo de pagamento efetuado
353
     * @param int $tPag
354
     * @return string
355
     */
356
    private function tipoPag($tPag)
357
    {
358
        $aPag = [
359
            '01' => 'Dinheiro',
360
            '02' => 'Cheque',
361
            '03' => 'Cartao de Credito',
362
            '04' => 'Cartao de Debito',
363
            '05' => 'Credito Loja',
364
            '10' => 'Vale Alimentacao',
365
            '11' => 'Vale Refeicao',
366
            '12' => 'Vale Presente',
367
            '13' => 'Vale Combustivel',
368
            '99' => 'Outros'
369
        ];
370
        if (array_key_exists($tPag, $aPag)) {
371
            return $aPag[$tPag];
372
        }
373
        return '';
374
    }
375
}
376