Completed
Push — master ( a0ced1...0c034e )
by Roberto
123:33 queued 74:20
created

Damdfe::bodyMDFe()   F

Complexity

Conditions 15
Paths 6144

Size

Total Lines 246

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 202
CRAP Score 15.1231

Importance

Changes 0
Metric Value
cc 15
nc 6144
nop 2
dl 0
loc 246
ccs 202
cts 220
cp 0.9182
crap 15.1231
rs 1.3999
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

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

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

Commonly applied refactorings include:

1
<?php
2
3
namespace NFePHP\DA\MDFe;
4
5
/**
6
 * Esta classe gera do PDF do MDFDe, conforme regras e estruturas
7
 * estabelecidas pela SEFAZ.
8
 *
9
 * @category  Library
10
 * @package   nfephp-org/sped-da
11
 * @name      Damdfe.php
12
 * @copyright 2009-2016 NFePHP
13
 * @license   http://www.gnu.org/licenses/lesser.html LGPL v3
14
 * @link      http://github.com/nfephp-org/sped-da for the canonical source repository
15
 * @author    Leandro C. Lopez <leandro dot castoldi at gmail dot com>
16
 */
17
18
use NFePHP\DA\Legacy\Dom;
19
use NFePHP\DA\Legacy\Common;
20
use NFePHP\DA\Legacy\Pdf;
21
22
class Damdfe extends Common
23
{
24
    //publicas
25
    public $logoAlign='L'; //alinhamento do logo
26
    public $yDados=0;
27
    public $debugMode=0; //ativa ou desativa o modo de debug
28
    //privadas
29
    protected $pdf; // objeto fpdf()
30
    protected $xml; // string XML NFe
31
    protected $logomarca=''; // path para logomarca em jpg
32
    protected $errMsg=''; // mesagens de erro
33
    protected $errStatus=false;// status de erro TRUE um erro ocorreu false sem erros
34
    protected $orientacao='P'; //orientação da DANFE P-Retrato ou L-Paisagem
35
    protected $papel='A4'; //formato do papel
36
    //destivo do arquivo pdf I-borwser, S-retorna o arquivo, D-força download, F-salva em arquivo local
37
    protected $destino = 'I';
38
    protected $pdfDir=''; //diretorio para salvar o pdf com a opção de destino = F
39
    protected $fontePadrao='Times'; //Nome da Fonte para gerar o DANFE
40
    protected $version = '1.0.0';
41
    protected $wPrint; //largura imprimivel
42
    protected $hPrint; //comprimento imprimivel
43
    protected $formatoChave="#### #### #### #### #### #### #### #### #### #### ####";
44
    //variaveis da carta de correção
45
    protected $id;
46
    protected $chMDFe;
47
    protected $tpAmb;
48
    protected $cOrgao;
49
    protected $xCondUso;
50
    protected $dhEvento;
51
    protected $cStat;
52
    protected $xMotivo;
53
    protected $CNPJDest = '';
54
    protected $dhRegEvento;
55
    protected $nProt;
56
    protected $tpEmis;
57
    //objetos
58
    private $dom;
59
    private $procEventoNFe;
0 ignored issues
show
Unused Code introduced by
The property $procEventoNFe is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
60
    private $evento;
0 ignored issues
show
Unused Code introduced by
The property $evento is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
61
    private $infEvento;
0 ignored issues
show
Unused Code introduced by
The property $infEvento is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
62
    private $retEvento;
0 ignored issues
show
Unused Code introduced by
The property $retEvento is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
63
    private $rinfEvento;
0 ignored issues
show
Unused Code introduced by
The property $rinfEvento is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
64
    /**
65
     * __construct
66
     *
67
     * @param string $xmlfile Arquivo XML da MDFe
68
     * @param string $sOrientacao (Opcional) Orientação da impressão P-retrato L-Paisagem
69
     * @param string $sPapel Tamanho do papel (Ex. A4)
70
     * @param string $sPathLogo Caminho para o arquivo do logo
71
     * @param string $sDestino Estabelece a direção do envio do documento PDF I-browser D-browser com download S-
72
     * @param string $sDirPDF Caminho para o diretorio de armazenamento dos arquivos PDF
73
     * @param string $fonteDAMDFE Nome da fonte alternativa do DAnfe
0 ignored issues
show
Bug introduced by
There is no parameter named $fonteDAMDFE. Was it maybe removed?

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

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

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

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

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

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

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

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

class Id
{
    public $id;

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

}

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

$account_id = false;

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

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
99
        }
100 1
        if ($this->debugMode) {
101
            //ativar modo debug
102
            error_reporting(E_ALL);
103
            ini_set('display_errors', 'On');
104
        } else {
105
            //desativar modo debug
106 1
            error_reporting(0);
107 1
            ini_set('display_errors', 'Off');
108
        }
109 1
        $this->orientacao   = $sOrientacao;
110 1
        $this->papel        = $sPapel;
111 1
        $this->pdf          = '';
112 1
        $this->xml          = $xmlfile;
113 1
        $this->logomarca    = $sPathLogo;
114 1
        $this->destino      = $sDestino;
115 1
        $this->pdfDir       = $sDirPDF;
116
        // verifica se foi passa a fonte a ser usada
117 1
        if (empty($fontePDF)) {
118 1
            $this->fontePadrao = 'Times';
119
        } else {
120
            $this->fontePadrao = $fontePDF;
121
        }
122
        //se for passado o xml
123 1
        if (empty($xmlfile)) {
124
            $this->errMsg = 'Um caminho para o arquivo xml da MDFe deve ser passado!';
125
            $this->errStatus = true;
126
        }
127 1
        if (!is_file($xmlfile)) {
128 1
            $this->errMsg = 'Um caminho para o arquivo xml da MDFe deve ser passado!';
129 1
            $this->errStatus = true;
130
        }
131
132
//        $docxml = file_get_contents($xmlfile);
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
133 1
        $this->dom = new Dom();
134 1
        $this->dom->loadXML($this->xml);
135 1
        $this->mdfeProc = $this->dom->getElementsByTagName("mdfeProc")->item(0);
0 ignored issues
show
Bug introduced by
The property mdfeProc does not exist. Did you maybe forget to declare it?

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

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

}

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

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

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

Loading history...
Unused Code introduced by
$y is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
261 1
    } //fim buildCCe
262
    /**
263
     * headerMDFePaisagem
264
     * @param float $x
265
     * @param float $y
266
     * @param integer $pag
267
     * @return string
268
     */
269
    private function headerMDFePaisagem($x, $y, $pag)
0 ignored issues
show
Unused Code introduced by
The parameter $pag is not used and could be removed.

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

Loading history...
270
    {
271
        $oldX = $x;
0 ignored issues
show
Unused Code introduced by
$oldX is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
272
        $oldY = $y;
273
        $maxW = $this->wPrint;
274
        //####################################################################################
275
        //coluna esquerda identificação do emitente
276
        $w = $maxW; //round($maxW*0.41, 0);// 80;
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
277
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
0 ignored issues
show
Unused Code introduced by
$aFont is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
278
        $w1 = $w;
0 ignored issues
show
Unused Code introduced by
$w1 is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
279
        $h=30;
280
        $oldY += $h;
281
        $this->pTextBox($x, $y, $w, $h);
282
        if (is_file($this->logomarca)) {
283
            $logoInfo = getimagesize($this->logomarca);
284
            //largura da imagem em mm
285
            $logoWmm = ($logoInfo[0]/72)*25.4;
286
            //altura da imagem em mm
287
            $logoHmm = ($logoInfo[1]/72)*25.4;
288
            if ($this->logoAlign=='L') {
289
                $nImgW = round($w/4.5, 0);
290
                $nImgH = round($logoHmm * ($nImgW/$logoWmm), 0);
291
                $xImg = $x+1;
292
                $yImg = round(($h-$nImgH)/2, 0)+$y;
293
                //estabelecer posições do texto
294
                $x1 = round($xImg + $nImgW +1, 0);
295
                $y1 = round($y+2, 0);
296
                $tw = round(2*$w/3, 0);
297
            }
298
            if ($this->logoAlign=='C') {
299
                $nImgH = round($h/3, 0);
300
                $nImgW = round($logoWmm * ($nImgH/$logoHmm), 0);
301
                $xImg = round(($w-$nImgW)/2+$x, 0);
302
                $yImg = $y+3;
303
                $x1 = $x;
304
                $y1 = round($yImg + $nImgH + 1, 0);
305
                $tw = $w;
306
            }
307
            if ($this->logoAlign=='R') {
308
                $nImgW = round($w/3, 0);
309
                $nImgH = round($logoHmm * ($nImgW/$logoWmm), 0);
310
                $xImg = round($x+($w-(1+$nImgW)), 0);
311
                $yImg = round(($h-$nImgH)/2, 0)+$y;
312
                $x1 = $x;
313
                $y1 = round($h/3+$y, 0);
314
                $tw = round(2*$w/3, 0);
315
            }
316
            $this->pdf->Image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg');
0 ignored issues
show
Bug introduced by
The variable $xImg does not seem to be defined for all execution paths leading up to this point.

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
317
        } else {
318
            $x1 = $x;
319
            $y1 = round($h/3+$y, 0);
320
            $tw = $w;
321
        }
322
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
323
        $razao = $this->xNome;
324
        $cnpj = 'CNPJ: '.$this->pFormat($this->CNPJ, "###.###.###/####-##");
325
        $ie = 'IE: '.$this->pFormat($this->IE, '##/########');
326
        $lgr = 'Logradouro: '.$this->xLgr;
327
        $nro = 'Nº: '.$this->nro;
328
        $bairro = 'Bairro: '.$this->xBairro;
329
        $CEP = $this->CEP;
330
        $CEP = 'CEP: '.$this->pFormat($CEP, "##.###-###");
331
        $UF = 'UF: '.$this->UF;
332
        $mun = 'Municipio: '.$this->xMun;
333
        
334
        $texto = $razao . "\n" . $cnpj . ' - ' . $ie . "\n";
335
        $texto .= $lgr . ' - ' . $nro . "\n";
336
        $texto .= $bairro . "\n";
337
        $texto .= $UF . ' - ' . $mun . ' - ' . $CEP;
338
        $this->pTextBox($x1, $y1+5, $tw, 8, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Bug introduced by
The variable $x1 does not seem to be defined for all execution paths leading up to this point.

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
339
        $x = $x+$maxW/2;
340
        $w = $maxW / 2;
341
        $this->pTextBox($x, $y, $w, $h);
342
        $aFont = array('font'=>$this->fontePadrao, 'size'=>12, 'style'=>'I');
343
        $this->pTextBox(
344
            $x,
345
            $y,
346
            $w,
347
            8,
348
            'DAMDFE - Documento Auxiliar de Manifesto Eletronico de Documentos Fiscais',
349
            $aFont,
350
            'T',
351
            'C',
352
            0,
353
            ''
354
        );
355
        $this->pTextBox($x, $y, $w, 6);
356
        $bH = 13;
357
        $bW = round(($w), 0);
358
        $this->pdf->SetFillColor(0, 0, 0);
359
        $this->pdf->Code128($x+5, $y+7.5, $this->chMDFe, $bW-10, $bH);
360
        $this->pdf->SetFillColor(255, 255, 255);
361
        $y = $y + 22;
362
        $this->pTextBox($x, $y, $w, 8);
363
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'I');
364
        $tsHora = $this->pConvertTime($this->dhEvento);
0 ignored issues
show
Unused Code introduced by
$tsHora is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
365
        $texto = 'CHAVE DE ACESSO';
366
        $this->pTextBox($x, $y, $maxW, 6, $texto, $aFont, 'T', 'L', 0, '');
367
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
368
        $texto = $this->pFormat($this->chMDFe, $this->formatoChave);
369
        $this->pTextBox($x, $y+3, $w, 6, $texto, $aFont, 'T', 'C', 0, '');
370
        $y = $y + 11;
371
        $this->pTextBox($x, $y, $w, 12);
372
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'I');
373
        $texto = 'PROTOCOLO DE AUTORIZACAO DE USO';
374
        $this->pTextBox($x, $y, $w, 8, $texto, $aFont, 'T', 'L', 0, '');
375
        
376
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
377
        if (is_object($this->mdfeProc)) {
378
            $tsHora = $this->pConvertTime($this->dhRecbto);
379
            $texto = $this->nProt.' - '.date('d/m/Y   H:i:s', $tsHora);
380
        } else {
381
            $texto = 'DAMDFE impresso em contingência - '.date('d/m/Y   H:i:s');
382
        }
383
        $this->pTextBox($x, $y+4, $w, 8, $texto, $aFont, 'T', 'C', 0, '');
384
        if ($this->tpAmb != 1) {
385
            $x = 10;
386
            if ($this->orientacao == 'P') {
387
                $yy = round($this->hPrint*2/3, 0);
388
            } else {
389
                $yy = round($this->hPrint/2, 0);
390
            }
391
            $h = 5;
392
            $w = $maxW-(2*$x);
393
            $this->pdf->SetTextColor(90, 90, 90);
394
            $texto = "SEM VALOR FISCAL";
395
            $aFont = array('font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B');
396
            $this->pTextBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
397
            $aFont = array('font'=>$this->fontePadrao, 'size'=>30, 'style'=>'B');
398
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
399
            $this->pTextBox($x, $yy+14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
400
            $this->pdf->SetTextColor(0, 0, 0);
401
        } else {
402
            $x = 10;
403
            if ($this->orientacao == 'P') {
404
                $yy = round($this->hPrint*2/3, 0);
405
            } else {
406
                $yy = round($this->hPrint/2, 0);
407
            }//fim orientacao
408
            $h = 5;
409
            $w = $maxW-(2*$x);
410
            $this->pdf->SetTextColor(90, 90, 90);
411
            //indicar FALTA DO PROTOCOLO se MDFe não for em contingência
412
            if (($this->tpEmis == 2 || $this->tpEmis == 5)) {
413
                //Contingência
414
                $texto = "DAMDFE Emitido em Contingência";
415
                $aFont = array('font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B');
416
                $this->pTextBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
417
                $aFont = array('font'=>$this->fontePadrao, 'size'=>30, 'style'=>'B');
418
                $texto = "devido à problemas técnicos";
419
                $this->pTextBox($x, $yy+12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
420
            }
421
            $this->pdf->SetTextColor(0, 0, 0);
422
        }
423
        return $y;
424
    }// fim headerMDFe
425
    
426
    /**
427
     * headerMDFeRetrato
428
     *
429
     * @param float $x
430
     * @param float $y
431
     * @param integer $pag
432
     * @return string
433
     */
434 1
    private function headerMDFeRetrato($x, $y, $pag)
0 ignored issues
show
Unused Code introduced by
The parameter $pag is not used and could be removed.

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

Loading history...
435
    {
436 1
        $oldX = $x;
0 ignored issues
show
Unused Code introduced by
$oldX is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
437 1
        $oldY = $y;
438 1
        $maxW = $this->wPrint;
439
        //####################################################################################
440
        //coluna esquerda identificação do emitente
441 1
        $w = $maxW; //round($maxW*0.41, 0);// 80;
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
442 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'I');
0 ignored issues
show
Unused Code introduced by
$aFont is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
443 1
        $w1 = $w;
0 ignored issues
show
Unused Code introduced by
$w1 is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
444 1
        $h=20;
445 1
        $oldY += $h;
446 1
        $this->pTextBox($x, $y, $w, $h);
447 1
        if (is_file($this->logomarca)) {
448
            $logoInfo = getimagesize($this->logomarca);
449
            //largura da imagem em mm
450
            $logoWmm = ($logoInfo[0]/72)*25.4;
451
            //altura da imagem em mm
452
            $logoHmm = ($logoInfo[1]/72)*25.4;
453
            if ($this->logoAlign=='L') {
454
                $nImgW = round($w/8, 0);
455
                $nImgH = round($logoHmm * ($nImgW/$logoWmm), 0);
456
                $xImg = $x+1;
457
                $yImg = round(($h-$nImgH)/2, 0)+$y;
458
                //estabelecer posições do texto
459
                $x1 = round($xImg + $nImgW +1, 0);
460
                $y1 = round($y+2, 0);
461
                $tw = round(2*$w/3, 0);
462
            }
463
            if ($this->logoAlign=='C') {
464
                $nImgH = round($h/3, 0);
465
                $nImgW = round($logoWmm * ($nImgH/$logoHmm), 0);
466
                $xImg = round(($w-$nImgW)/2+$x, 0);
467
                $yImg = $y+3;
468
                $x1 = $x;
469
                $y1 = round($yImg + $nImgH + 1, 0);
470
                $tw = $w;
471
            }
472
            if ($this->logoAlign=='R') {
473
                $nImgW = round($w/3, 0);
474
                $nImgH = round($logoHmm * ($nImgW/$logoWmm), 0);
475
                $xImg = round($x+($w-(1+$nImgW)), 0);
476
                $yImg = round(($h-$nImgH)/2, 0)+$y;
477
                $x1 = $x;
478
                $y1 = round($h/3+$y, 0);
479
                $tw = round(2*$w/3, 0);
480
            }
481
            $this->pdf->Image($this->logomarca, $xImg, $yImg, $nImgW, $nImgH, 'jpeg');
0 ignored issues
show
Bug introduced by
The variable $xImg does not seem to be defined for all execution paths leading up to this point.

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
482
        } else {
483 1
            $x1 = $x+40;
484 1
            $y1 = $y;
485 1
            $tw = $w;
486
        }
487 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
488 1
        $razao = $this->xNome;
489 1
        $cnpj = 'CNPJ: '.$this->pFormat($this->CNPJ, "###.###.###/####-##");
490 1
        $ie = 'IE: '.$this->pFormat($this->IE, '###/#######');
491 1
        $lgr = 'Logradouro: '.$this->xLgr;
492 1
        $nro = 'Nº: '.$this->nro;
493 1
        $bairro = 'Bairro: '.$this->xBairro;
494 1
        $CEP = $this->CEP;
495 1
        $CEP = 'CEP: '.$this->pFormat($CEP, "##.###-###");
496 1
        $mun = 'Municipio: '.$this->xMun;
497 1
        $UF = 'UF: '.$this->UF;
498 1
        $texto = $razao . "\n" . $cnpj . ' - ' . $ie . "\n";
499 1
        $texto .= $lgr . ' - ' . $nro . "\n";
500 1
        $texto .= $bairro . "\n";
501 1
        $texto .= $UF . ' - ' . $mun . ' - ' . $CEP;
502 1
        $this->pTextBox($x1, $y1, $tw, 8, $texto, $aFont, 'T', 'L', 0, '');
0 ignored issues
show
Bug introduced by
The variable $x1 does not seem to be defined for all execution paths leading up to this point.

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

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

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

Let’s take a look at an example:

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

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

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

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

Available Fixes

  1. Check for existence of the variable explicitly:

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

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

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
503
        //##################################################
504 1
        $y = $h + 8;
505 1
        $this->pTextBox($x, $y, $maxW, 6);
506 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>12, 'style'=>'I');
507 1
        $this->pTextBox(
508 1
            $x,
509 1
            $y,
510 1
            $maxW,
511 1
            8,
512 1
            'DAMDFE - Documento Auxiliar de Manifesto Eletronico de Documentos Fiscais',
513 1
            $aFont,
514 1
            'T',
515 1
            'C',
516 1
            0,
517 1
            ''
518
        );
519 1
        $y = $y + 8;
520 1
        $this->pTextBox($x, $y, $maxW, 20);
521 1
        $bH = 16;
522 1
        $w = $maxW;
0 ignored issues
show
Unused Code introduced by
$w is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
523 1
        $this->pdf->SetFillColor(0, 0, 0);
524 1
        $this->pdf->Code128($x + 5, $y+2, $this->chMDFe, $maxW - 10, $bH);
525 1
        $this->pdf->SetFillColor(255, 255, 255);
526 1
        $y = $y + 22;
527 1
        $this->pTextBox($x, $y, $maxW, 10);
528 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'I');
529 1
        $tsHora = $this->pConvertTime($this->dhEvento);
0 ignored issues
show
Unused Code introduced by
$tsHora is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
530 1
        $texto = 'CHAVE DE ACESSO';
531 1
        $this->pTextBox($x, $y, $maxW, 6, $texto, $aFont, 'T', 'L', 0, '');
532 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
533 1
        $texto = $this->pFormat($this->chMDFe, $this->formatoChave);
534 1
        $this->pTextBox($x, $y+4, $maxW, 6, $texto, $aFont, 'T', 'C', 0, '');
535 1
        $y = $y + 12;
536 1
        $this->pTextBox($x, $y, $maxW, 10);
537 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'I');
538 1
        $texto = 'PROTOCOLO DE AUTORIZACAO DE USO';
539 1
        $this->pTextBox($x, $y, $maxW, 8, $texto, $aFont, 'T', 'L', 0, '');
540 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
541 1
        if (is_object($this->mdfeProc)) {
542 1
            $tsHora = $this->pConvertTime($this->dhRecbto);
543 1
            $texto = $this->nProt.' - '.date('d/m/Y   H:i:s', $tsHora);
544
        } else {
545
            $texto = 'DAMDFE impresso em contingência - '.date('d/m/Y   H:i:s');
546
        }
547 1
        $this->pTextBox($x, $y+4, $maxW, 8, $texto, $aFont, 'T', 'C', 0, '');
548 1
        if ($this->tpAmb != 1) {
549 1
            $x = 10;
550 1
            if ($this->orientacao == 'P') {
551 1
                $yy = round($this->hPrint*2/3, 0);
552
            } else {
553
                $yy = round($this->hPrint/2, 0);
554
            }
555 1
            $h = 5;
556 1
            $w = $maxW-(2*$x);
557 1
            $this->pdf->SetTextColor(90, 90, 90);
558 1
            $texto = "SEM VALOR FISCAL";
559 1
            $aFont = array('font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B');
560 1
            $this->pTextBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
561 1
            $aFont = array('font'=>$this->fontePadrao, 'size'=>30, 'style'=>'B');
562 1
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
563 1
            $this->pTextBox($x, $yy+14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
564 1
            $this->pdf->SetTextColor(0, 0, 0);
565
        } else {
566
            $x = 10;
567
            if ($this->orientacao == 'P') {
568
                $yy = round($this->hPrint*2/3, 0);
569
            } else {
570
                $yy = round($this->hPrint/2, 0);
571
            }//fim orientacao
572
            $h = 5;
573
            $w = $maxW-(2*$x);
574
            $this->pdf->SetTextColor(90, 90, 90);
575
            //indicar FALTA DO PROTOCOLO se MDFe não for em contingência
576
            if (($this->tpEmis == 2 || $this->tpEmis == 5)) {
577
                //Contingência
578
                $texto = "DAMDFE Emitido em Contingência";
579
                $aFont = array('font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B');
580
                $this->pTextBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
581
                $aFont = array('font'=>$this->fontePadrao, 'size'=>30, 'style'=>'B');
582
                $texto = "devido à problemas técnicos";
583
                $this->pTextBox($x, $yy+12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
584
            }
585
            $this->pdf->SetTextColor(0, 0, 0);
586
        }
587 1
        return $y+12;
588
    }// fim headerMDFe
589
    
590
    /**
591
     * bodyMDFe
592
     *
593
     * @param float $x
594
     * @param float $y
595
     * @return void
596
     */
597 1
    private function bodyMDFe($x, $y)
598
    {
599 1
        if ($this->orientacao == 'P') {
600 1
            $maxW = $this->wPrint;
601
        } else {
602
            $maxW = $this->wPrint / 2;
603
        }
604 1
        $x2 = ($maxW / 6);
605 1
        $x1 = $x2;
0 ignored issues
show
Unused Code introduced by
$x1 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...
606 1
        $this->pTextBox($x, $y, $x2-7, 12);
607 1
        $texto = 'Modelo';
608 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
609 1
        $this->pTextBox($x, $y, $x2-7, 8, $texto, $aFont, 'T', 'L', 0, '', false);
610 1
        $texto = $this->mod;
611 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
612 1
        $this->pTextBox($x, $y+4, $x2-7, 10, $texto, $aFont, 'T', 'C', 0, '', false);
613 1
        $x1 = $x2;
614 1
        $this->pTextBox($x1, $y, $x2-7, 12);
615 1
        $texto = 'Série';
616 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
617 1
        $this->pTextBox($x1, $y, $x2-7, 8, $texto, $aFont, 'T', 'L', 0, '', false);
618 1
        $texto = $this->serie;
619 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
620 1
        $this->pTextBox($x1, $y+4, $x2-7, 10, $texto, $aFont, 'T', 'C', 0, '', false);
621 1
        $x1 += $x2-7;
622 1
        $this->pTextBox($x1, $y, $x2+5, 12);
623 1
        $texto = 'Número';
624 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
625 1
        $this->pTextBox($x1, $y, $x2+5, 8, $texto, $aFont, 'T', 'L', 0, '', false);
626 1
        $texto = $this->pFormat(str_pad($this->nMDF, 9, '0', STR_PAD_LEFT), '###.###.###');
627 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
628 1
        $this->pTextBox($x1, $y+4, $x2+5, 10, $texto, $aFont, 'T', 'C', 0, '', false);
629 1
        $x1 += $x2+5;
630 1
        $this->pTextBox($x1, $y, $x2-7, 12);
631 1
        $texto = 'FL';
632 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
633 1
        $this->pTextBox($x1, $y, $x2-7, 8, $texto, $aFont, 'T', 'L', 0, '', false);
634 1
        $texto = '1';
635 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
636 1
        $this->pTextBox($x1, $y+4, $x2-7, 10, $texto, $aFont, 'T', 'C', 0, '', false);
637 1
        $x1 += $x2-7;
638 1
        $this->pTextBox($x1, $y, $x2+11, 12);
639 1
        $texto = 'Data e Hora de Emissão';
640 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
641 1
        $this->pTextBox($x1, $y, $x2+11, 8, $texto, $aFont, 'T', 'L', 0, '', false);
642 1
        $data = explode('T', $this->dhEmi);
643 1
        $texto = $this->pYmd2dmy($data[0]).' - '.$data[1];
644 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
645 1
        $this->pTextBox($x1, $y+4, $x2+11, 10, $texto, $aFont, 'T', 'C', 0, '', false);
646 1
        $x1 += $x2+11;
647 1
        $this->pTextBox($x1, $y, $x2-15, 12);
648 1
        $texto = 'UF Carreg.';
649 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
650 1
        $this->pTextBox($x1, $y, $x2-15, 8, $texto, $aFont, 'T', 'L', 0, '', false);
651 1
        $texto = $this->UFIni;
652 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
653 1
        $this->pTextBox($x1, $y+4, $x2-15, 10, $texto, $aFont, 'T', 'C', 0, '', false);
654 1
        $maxW = $this->wPrint;
0 ignored issues
show
Unused Code introduced by
$maxW is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
655
656 1
        $x1 += $x2-15;
657 1
        $this->pTextBox($x1, $y, $x2-13, 12);
658 1
        $texto = 'UF Descar.';
659 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
660 1
        $this->pTextBox($x1, $y, $x2-13, 8, $texto, $aFont, 'T', 'L', 0, '', false);
661 1
        $texto = $this->UFFim;
662 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
663 1
        $this->pTextBox($x1, $y+4, $x2-13, 10, $texto, $aFont, 'T', 'C', 0, '', false);
664 1
        $maxW = $this->wPrint;
665
666
667
668 1
        $x1 = $x;
669 1
        $x2 = $maxW;
670 1
        $y += 14;
671 1
        $this->pTextBox($x1, $y, $x2, 23);
672 1
        $texto = 'Modal Rodoviário de Carga';
673 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
674 1
        $this->pTextBox($x1, $y+1, $x2, 8, $texto, $aFont, 'T', 'C', 0, '', false);
675 1
        $x1 = $x;
676 1
        $x2 = ($maxW / 6);
677 1
        $y += 6;
678 1
        $this->pTextBox($x1, $y, $x2, 12);
679 1
        $texto = 'Qtd. CT-e';
680 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
681 1
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
682 1
        $texto = str_pad($this->qCTe, 3, '0', STR_PAD_LEFT);
683 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
684 1
        $this->pTextBox($x1, $y+4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
685 1
        $x1 += $x2;
686 1
        $this->pTextBox($x1, $y, $x2, 12);
687 1
        $texto = 'Qtd. NF-e';
688 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
689 1
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
690 1
        $texto = str_pad($this->qNFe, 3, '0', STR_PAD_LEFT);
691 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
692 1
        $this->pTextBox($x1, $y+4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
693 1
        $x1 += $x2;
694 1
        $this->pTextBox($x1, $y, $x2, 12);
695 1
        $texto = 'Peso Total (Kg)';
696 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
697 1
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
698 1
        $texto = number_format($this->qCarga, 4, ', ', '.');
699 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
700 1
        $this->pTextBox($x1, $y+4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
701 1
        $x1 = $x;
702 1
        $y += 12;
703 1
        $yold = $y;
704 1
        $x2 = round($maxW / 2, 0);
705 1
        $texto = 'Veículo';
706 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
707 1
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
708 1
        $y += 5;
709 1
        $x2 = round($maxW / 4, 0);
710 1
        $tamanho = 22;
711 1
        $this->pTextBox($x1, $y, $x2, $tamanho);
712 1
        $texto = 'Placa';
713 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
714 1
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
715 1
        $texto = $this->veicTracao->getElementsByTagName("placa")->item(0)->nodeValue;
716 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
717 1
        $this->pTextBox($x1, $y+4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
718 1
        $altura = $y + 4;
719
        /** @var \DOMNodeList $veicReboque */
720 1
        $veicReboque = $this->veicReboque;
721 1
        foreach ($veicReboque as $item) {
722
            /** @var \DOMElement $item */
723 1
            $altura += 4;
724 1
            $texto = $item->getElementsByTagName('placa')->item(0)->nodeValue;
725 1
            $this->pTextBox($x1, $altura, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
726
        }
727 1
        $x1 += $x2;
728 1
        $this->pTextBox($x1, $y, $x2, $tamanho);
729 1
        $texto = 'RNTRC';
730 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
731 1
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
732
        // RNTRC Não informado
733 1
        if ($this->rodo->getElementsByTagName("RNTRC")->length > 0) {
734 1
            $texto = $this->rodo->getElementsByTagName("RNTRC")->item(0)->nodeValue;
735
        } else {
736
            $texto = "";
737
        }
738 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
739 1
        $this->pTextBox($x1, $y+4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
740 1
        $altura = $y + 4;
741
        /** @var \DOMNodeList $veicReboque */
742 1
        $veicReboque = $this->veicReboque;
743 1
        foreach ($veicReboque as $item) {
744
            /** @var \DOMElement $item */
745 1
            $DOMNodeList = $item->getElementsByTagName('RNTRC');
746 1
            if ($DOMNodeList->length > 0) {
747
                $altura += 4;
748
                $texto = $DOMNodeList->item(0)->nodeValue;
749 1
                $this->pTextBox($x1, $altura, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
750
            }
751
        }
752 1
        $x1 = $x;
753 1
        $y += 22;
754 1
        $x2 = round($maxW / 2, 0);
755 1
        $valesPedagios = 1;
756 1
        $temVales = false;
757 1
        if ($this->valePed != "" && $this->valePed->length > 0) {
758
            $valesPedagios = $this->valePed->length;
759
            $temVales = true;
760
        }
761 1
        $tamanho = ($valesPedagios * 7.5);
762 1
        if (!$temVales) {
763 1
            $valesPedagios = 0;
764
        }
765 1
        $this->pTextBox($x1, $y, $x2, 11+$tamanho/2);
766 1
        $texto = 'Vale Pedágio';
767 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
768 1
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
769 1
        $y += 5;
770 1
        $x2 = ($x2 / 3);
771 1
        $this->pTextBox($x1, $y, $x2-3, 6+($tamanho/2));
772 1
        $texto = 'Responsável CNPJ';
773 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
774 1
        $this->pTextBox($x1, $y, $x2-4, 8, $texto, $aFont, 'T', 'L', 0, '', false);
775 1
        $altura = $y;
776 1
        for ($i = 0; $i < $valesPedagios; $i++) {
777
            $altura += 4;
778
            $texto = $this->valePed->item($i)->getElementsByTagName('CNPJForn')->item(0)->nodeValue;
779
            $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
780
            $this->pTextBox($x1 + 1, $altura, $x2-5, 10, $texto, $aFont, 'T', 'L', 0, '', false);
781
        }
782 1
        $x1 += $x2-3;
783 1
        $this->pTextBox($x1, $y, $x2-3, 6+($tamanho/2));
784 1
        $texto = 'Fornecedora CNPJ';
785 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
786 1
        $this->pTextBox($x1, $y, $x2-4, 8, $texto, $aFont, 'T', 'L', 0, '', false);
787 1
        $altura = $y;
788 1
        for ($i = 0; $i < $valesPedagios; $i++) {
789
            $altura += 4;
790
            $texto = $this->valePed->item($i)->getElementsByTagName('CNPJPg')->item(0)->nodeValue;
791
            $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
792
            $this->pTextBox($x1 + 1, $altura, $x2-5, 10, $texto, $aFont, 'T', 'L', 0, '', false);
793
        }
794 1
        $x1 += $x2-3;
795 1
        $this->pTextBox($x1, $y, $x2+6, 6+($tamanho/2));
796 1
        $texto = 'Nº Comprovante';
797 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
798 1
        $this->pTextBox($x1, $y, $x2+6, 8, $texto, $aFont, 'T', 'L', 0, '', false);
799 1
        $altura = $y;
800 1
        for ($i = 0; $i < $valesPedagios; $i++) {
801
            $altura += 4;
802
            $texto = $this->valePed->item($i)->getElementsByTagName('nCompra')->item(0)->nodeValue;
803
            $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
804
            $this->pTextBox($x1 + 1, $altura, $x2+5, 10, $texto, $aFont, 'T', 'L', 0, '', false);
805
        }
806 1
        if (!$temVales) {
807 1
            $altura += 4;
808
        }
809 1
        $this->condutor = $this->veicTracao->getElementsByTagName('condutor');
0 ignored issues
show
Bug introduced by
The property condutor does not exist. Did you maybe forget to declare it?

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
810 1
        $x1 = round($maxW / 2, 0) + 7;
811 1
        $y = $yold;
812 1
        $x2 = round($maxW / 2, 0);
813 1
        $texto = 'Condutor';
814 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
815 1
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
816 1
        $y += 5;
817 1
        $x2 = ($maxW / 4);
818 1
        $this->pTextBox($x1, $y, $x2, 33+($tamanho/2));
819 1
        $texto = 'CPF';
820 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
821 1
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
822 1
        $yold = $y;
823 1
        for ($i = 0; $i < $this->condutor->length; $i++) {
824 1
            $y += 4;
825 1
            $texto = $this->condutor->item($i)->getElementsByTagName('CPF')->item(0)->nodeValue;
826 1
            $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
827 1
            $this->pTextBox($x1 + 1, $y, $x2 - 1, 10, $texto, $aFont, 'T', 'L', 0, '', false);
828
        }
829 1
        $y = $yold;
830 1
        $x1 += $x2;
831 1
        $this->pTextBox($x1, $y, $x2, 33+($tamanho/2));
832 1
        $texto = 'Nome';
833 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
834 1
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
835 1
        for ($i = 0; $i < $this->condutor->length; $i++) {
836 1
            $y += 4;
837 1
            $texto = $this->condutor->item($i)->getElementsByTagName('xNome')->item(0)->nodeValue;
838 1
            $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
839 1
            $this->pTextBox($x1 + 1, $y, $x2 - 1, 8, $texto, $aFont, 'T', 'L', 0, '', false);
840
        }
841 1
        return $altura + 7;
842
    }//fim bodyMDFe
843
    /**
844
     * footerMDFe
845
     *
846
     * @param float $x
847
     * @param float $y
848
     */
849 1
    private function footerMDFe($x, $y)
850
    {
851 1
        $maxW = $this->wPrint;
852 1
        $x2 = $maxW;
853 1
        $this->pTextBox($x, $y, $x2, 30);
854
        $texto = 'Observação
855 1
        '.$this->infCpl;
856 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
857 1
        $this->pTextBox($x, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
858 1
        $y = $this->hPrint -4;
859 1
        $texto = "Impresso em  ". date('d/m/Y   H:i:s');
860 1
        $w = $this->wPrint-4;
861 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'I');
862 1
        $this->pTextBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, '');
863 1
    }//fim footerCCe
864
    /**
865
     * printMDFe
866
     *
867
     * @param string $nome
868
     * @param string $destino
869
     * @param string $printer
870
     * @return string
871
     */
872 1
    public function printMDFe($nome = '', $destino = 'I', $printer = '')
873
    {
874
        //monta
875 1
        $command = '';
876 1
        if ($nome == '') {
877
            $file = $this->pdfDir.'mdfe.pdf';
878
        } else {
879 1
            $file = $this->pdfDir.$nome;
880
        }
881 1
        if ($destino != 'I' && $destino != 'S' && $destino != 'F') {
882
            $destino = 'I';
883
        }
884 1
        if ($printer != '') {
885
            $command = "-P $printer";
886
        }
887
888 1
        $this->buildMDFe();
889 1
        $arq = $this->pdf->Output($file, $destino);
890 1
        if ($destino == 'S' && $command != '') {
891
            //aqui pode entrar a rotina de impressão direta
892
            $command = "lpr $command $file";
893
            system($command, $retorno);
894
        }
895
896 1
        return $arq;
897
    }//fim printMDFe
898
899
    /**
900
     * Dados brutos do PDF
901
     * @return string
902
     */
903
    public function render()
904
    {
905
        return $this->pdf->getPdf();
906
    }
907
}
908