Completed
Push — master ( 638629...0d992c )
by Roberto
30:19 queued 15:21
created

DanfcePos::parteI()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 18
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 24
ccs 0
cts 21
cp 0
crap 6
rs 8.9713
1
<?php
2
3
namespace NFePHP\DA\NFe;
4
5
/**
6
 * Classe para a impressão do Documento Auxiliar de NFe Consumidor
7
 * em impressoras térmicas ESCPOS
8
 *
9
 * @category  Library
10
 * @package   nfephp-org/sped-da
11
 * @name      DanfcePos.php
12
 * @copyright 2009-2016 NFePHP
13
 * @license   http://www.gnu.org/licenses/lesser.html LGPL v3
14
 * @link      http://github.com/nfephp-org/sped-da for the canonical source repository
15
 * @author    Roberto L. Machado <linux dot rlm at gmail dot com>
16
 */
17
18
use Posprint\Printers\PrinterInterface;
19
use InvalidArgumentException;
20
21
class DanfcePos
22
{
23
    /**
24
     * NFCe
25
     * @var SimpleXMLElement
26
     */
27
    protected $nfce = '';
28
    /**
29
     * protNFe
30
     * @var SimpleXMLElement
31
     */
32
    protected $protNFe = '';
33
    /**
34
     * Printer
35
     * @var PrinterInterface
36
     */
37
    protected $printer;
38
    /**
39
     * Documento montado
40
     * @var array
41
     */
42
    protected $da = array();
43
    /**
44
     * Total de itens da NFCe
45
     * @var integer
46
     */
47
    protected $totItens = 0;
48
    
49
    /**
50
     * URI referente a pagina de consulta da NFCe pela chave de acesso
51
     * @var string
52
     */
53
    protected $uri = '';
54
    
55
    protected $aURI = [
56
      'AC' => 'http://sefaznet.ac.gov.br/nfce/consulta.xhtml',
57
      'AM' => 'http://sistemas.sefaz.am.gov.br/nfceweb/formConsulta.do',
58
      'BA' => 'http://nfe.sefaz.ba.gov.br/servicos/nfce/Modulos/Geral/NFCEC_consulta_chave_acesso.aspx',
59
      'MT' => 'https://www.sefaz.mt.gov.br/nfce/consultanfce',
60
      'MA' => 'http://www.nfce.sefaz.ma.gov.br/portal/consultaNFe.do?method=preFilterCupom&',
61
      'PA' => 'https://appnfc.sefa.pa.gov.br/portal/view/consultas/nfce/consultanfce.seam',
62
      'PB' => 'https://www.receita.pb.gov.br/ser/servirtual/documentos-fiscais/nfc-e/consultar-nfc-e',
63
      'PR' => 'http://www.sped.fazenda.pr.gov.br/modules/conteudo/conteudo.php?conteudo=100',
64
      'RJ' => 'http://www4.fazenda.rj.gov.br/consultaDFe/paginas/consultaChaveAcesso.faces',
65
      'RS' => 'https://www.sefaz.rs.gov.br/NFE/NFE-COM.aspx',
66
      'RO' => 'http://www.nfce.sefin.ro.gov.br/home.jsp',
67
      'RR' => 'https://www.sefaz.rr.gov.br/nfce/servlet/wp_consulta_nfce',
68
      'SE' => 'http://www.nfce.se.gov.br/portal/portalNoticias.jsp?jsp=barra-menu/servicos/consultaDANFENFCe.htm',
69
      'SP' => 'https://www.nfce.fazenda.sp.gov.br/NFCeConsultaPublica/Paginas/ConsultaPublica.aspx'
70
    ];
71
72
    /**
73
     * Carrega a impressora a ser usada
74
     * a mesma deverá já ter sido pré definida inclusive seu
75
     * conector
76
     *
77
     * @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...
78
     */
79
    public function __construct(PrinterInterface $printer)
80
    {
81
        $this->printer = $printer;
82
    }
83
    
84
    /**
85
     * Carrega a NFCe
86
     * @param string $nfcexml
87
     */
88
    public function loadNFCe($nfcexml)
89
    {
90
        $xml = $nfcexml;
91
        if (is_file($nfcexml)) {
92
            $xml = @file_get_contents($nfcexml);
93
        }
94
        if (empty($xml)) {
95
            throw new InvalidArgumentException('Não foi possivel ler o documento.');
96
        }
97
        $nfe = simplexml_load_string($xml, null, LIBXML_NOCDATA);
98
        $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...
99
        $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...
100
        if (empty($this->protNFe)) {
101
            //NFe sem protocolo
102
            $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<NFePHP\DA\NFe\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...
103
        }
104
    }
105
    
106
    /**
107
     * Monta a DANFCE para uso de impressoras POS
108
     */
109
    public function monta()
110
    {
111
        $this->parteI();
112
        $this->parteII();
113
        $this->parteIII();
114
        $this->parteIV();
115
        $this->parteV();
116
        $this->parteVI();
117
        $this->parteVII();
118
        $this->parteVIII();
119
        $this->parteIX();
120
    }
121
    
122
    /**
123
     * Manda os dados para a impressora ou
124
     * retorna os comandos em ordem e legiveis
125
     * para a tela
126
     */
127
    public function printDanfe()
128
    {
129
        $resp = $this->printer->send();
130
        if (!empty($resp)) {
131
            echo str_replace("\n", "<br>", $resp);
132
        }
133
    }
134
    
135
    /**
136
     * Recupera a sequiencia de comandos para envio
137
     * posterior para a impressora por outro
138
     * meio como o QZ.io (tray)
139
     *
140
     * @return string
141
     */
142
    public function getCommands()
143
    {
144
        $aCmds = $this->printer->getBuffer('binA');
145
        return implode("\n", $aCmds);
146
    }
147
    
148
    /**
149
     * Parte I - Emitente
150
     * Dados do emitente
151
     * Campo Obrigatório
152
     */
153
    protected function parteI()
154
    {
155
        $razao = (string) $this->nfce->infNFe->emit->xNome;
156
        $cnpj = (string) $this->nfce->infNFe->emit->CNPJ;
157
        $ie = (string) $this->nfce->infNFe->emit->IE;
158
        $im = (string) $this->nfce->infNFe->emit->IM;
159
        $log = (string) $this->nfce->infNFe->emit->enderEmit->xLgr;
160
        $nro = (string) $this->nfce->infNFe->emit->enderEmit->nro;
161
        $bairro = (string) $this->nfce->infNFe->emit->enderEmit->xBairro;
162
        $mun = (string) $this->nfce->infNFe->emit->enderEmit->xMun;
163
        $uf = (string) $this->nfce->infNFe->emit->enderEmit->UF;
164
        if (array_key_exists($uf, $this->aURI)) {
165
            $this->uri = $this->aURI[$uf];
166
        }
167
        $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...
168
        $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...
169
        $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...
170
        $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...
171
        $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...
172
        //o que acontece quando o texto é maior que o numero de carecteres
173
        //da linha ??
174
        $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...
175
        //linha divisória ??
176
    }
177
    
178
    /**
179
     * Parte II - Informações Gerais
180
     * Campo Obrigatório
181
     */
182
    protected function parteII()
183
    {
184
        $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...
185
        $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...
186
        $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...
187
        $this->printer->setBold();
188
        $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...
189
        $this->printer->setBold();
190
        //linha divisória ??
191
    }
192
    
193
    /**
194
     * Parte III - Detalhes da Venda
195
     * Campo Opcional
196
     */
197
    protected function parteIII()
198
    {
199
        $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...
200
        $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...
201
        //obter dados dos itens da NFCe
202
        $det = $this->nfce->infNFe->det;
203
        $this->totItens = $det->count();
204
        for ($x=0; $x<=$this->totItens-1; $x++) {
205
            $nItem = (int) $det[$x]->attributes()->{'nItem'};
206
            $cProd = (string) $det[$x]->prod->cProd;
207
            $xProd = (string) $det[$x]->prod->xProd;
208
            $qCom = (float) $det[$x]->prod->qCom;
209
            $uCom = (string) $det[$x]->prod->uCom;
210
            $vUnCom = (float) $det[$x]->prod->vUnCom;
211
            $vProd = (float) $det[$x]->prod->vProd;
212
            //falta formatar os campos e o espaçamento entre eles
213
            $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...
214
        }
215
        //linha divisória ??
216
    }
217
    
218
    /**
219
     * Parte V - Informação de tributos
220
     * Campo Obrigatório
221
     */
222
    protected function parteIV()
223
    {
224
        $vTotTrib = (float) $this->nfce->infNFe->total->ICMSTot->vTotTrib;
225
        $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...
226
        $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...
227
        $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...
228
        //linha divisória ??
229
    }
230
    
231
    /**
232
     * Parte IV - Totais da Venda
233
     * Campo Obrigatório
234
     */
235
    protected function parteV()
236
    {
237
        $vNF = (float) $this->nfce->infNFe->total->ICMSTot->vNF;
238
        $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...
239
        $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...
240
        $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...
241
        $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...
242
        $pag = $this->nfce->infNFe->pag;
243
        $tot = $pag->count();
244
        for ($x=0; $x<=$tot-1; $x++) {
245
            $tPag = (string) $this->tipoPag($pag[0]->tPag);
246
            $vPag = (float) $pag[0]->vPag;
247
            $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...
248
        }
249
        //linha divisória ??
250
    }
251
    
252
    /**
253
     * Parte VI - Mensagem de Interesse do Contribuinte
254
     * conteudo de infCpl
255
     * Campo Opcional
256
     */
257
    protected function parteVI()
258
    {
259
        $infCpl = (string) $this->nfce->infNFe->infAdic->infCpl;
260
        $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...
261
        $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...
262
        $this->printer->lineFeed();
263
        //linha divisória ??
264
    }
265
    
266
    /**
267
     * Parte VII - Mensagem Fiscal e Informações da Consulta via Chave de Acesso
268
     * Campo Obrigatório
269
     */
270
    protected function parteVII()
271
    {
272
        $tpAmb = (int) $this->nfce->infNFe->ide->tpAmb;
273
        if ($tpAmb == 2) {
274
            $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...
275
            $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...
276
        }
277
        $tpEmis = (int) $this->nfce->infNFe->ide->tpEmis;
278
        if ($tpEmis != 1) {
279
            $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...
280
            $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...
281
        }
282
        $nNF = (float) $this->nfce->infNFe->ide->nNF;
283
        $serie = (int) $this->nfce->infNFe->ide->serie;
284
        $dhEmi = (string) $this->nfce->infNFe->ide->dhEmi;
285
        $Id = (string) $this->nfce->infNFe->attributes()->{'Id'};
286
        $chave = substr($Id, 3, strlen($Id)-3);
287
        $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...
288
        $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...
289
        $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...
290
        $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...
291
        $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...
292
        $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...
293
        $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...
294
        //linha divisória ??
295
    }
296
    
297
    /**
298
     * Parte VIII - Informações sobre o Consumidor
299
     * Campo Opcional
300
     */
301
    protected function parteVIII()
302
    {
303
        $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...
304
        $dest = $this->nfce->infNFe->dest;
305
        if (empty($dest)) {
306
            $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...
307
            return;
308
        }
309
        $xNome = (string) $this->nfce->infNFe->dest->xNome;
310
        $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...
311
        $cnpj = (string) $this->nfce->infNFe->dest->CNPJ;
312
        $cpf = (string) $this->nfce->infNFe->dest->CPF;
313
        $idEstrangeiro = (string) $this->nfce->infNFe->dest->idEstrangeiro;
314
        $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...
315
        if (!empty($cnpj)) {
316
            $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...
317
        }
318
        if (!empty($cpf)) {
319
            $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...
320
        }
321
        if (!empty($idEstrangeiro)) {
322
            $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...
323
        }
324
        $xLgr = (string) $this->nfce->infNFe->dest->enderDest->xLgr;
325
        $nro = (string) $this->nfce->infNFe->dest->enderDest->nro;
326
        $xCpl = (string) $this->nfce->infNFe->dest->enderDest->xCpl;
327
        $xBairro = (string) $this->nfce->infNFe->dest->enderDest->xBairro;
328
        $xMun = (string) $this->nfce->infNFe->dest->enderDest->xMun;
329
        $uf = (string) $this->nfce->infNFe->dest->enderDest->UF;
330
        $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...
331
        $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...
332
        //linha divisória ??
333
    }
334
    
335
    /**
336
     * Parte IX - QRCode
337
     * Consulte via Leitor de QRCode
338
     * Protocolo de autorização 1234567891234567 22/06/2016 14:43:51
339
     * Campo Obrigatório
340
     */
341
    protected function parteIX()
342
    {
343
        $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...
344
        $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...
345
        $qr = (string) $this->nfce->infNFeSupl->qrCode;
346
        $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...
347
        if (!empty($this->protNFe)) {
348
            $nProt = (string) $this->protNFe->infProt->nProt;
349
            $dhRecbto = (string) $this->protNFe->infProt->dhRecbto;
350
            $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...
351
        } else {
352
            $this->printer->setBold();
353
            $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...
354
            $this->printer->lineFeed();
355
        }
356
    }
357
    
358
    /**
359
     * Retorna o texto referente ao tipo de pagamento efetuado
360
     * @param int $tPag
361
     * @return string
362
     */
363
    private function tipoPag($tPag)
364
    {
365
        $aPag = [
366
            '01' => 'Dinheiro',
367
            '02' => 'Cheque',
368
            '03' => 'Cartao de Credito',
369
            '04' => 'Cartao de Debito',
370
            '05' => 'Credito Loja',
371
            '10' => 'Vale Alimentacao',
372
            '11' => 'Vale Refeicao',
373
            '12' => 'Vale Presente',
374
            '13' => 'Vale Combustivel',
375
            '99' => 'Outros'
376
        ];
377
        if (array_key_exists($tPag, $aPag)) {
378
            return $aPag[$tPag];
379
        }
380
        return '';
381
    }
382
}
383