Passed
Pull Request — master (#180)
by
unknown
05:18
created

Damdfe::printMDFe()   B

Complexity

Conditions 8
Paths 16

Size

Total Lines 26

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 10.3696

Importance

Changes 0
Metric Value
cc 8
nc 16
nop 3
dl 0
loc 26
ccs 10
cts 15
cp 0.6667
crap 10.3696
rs 8.4444
c 0
b 0
f 0
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->infAdic = $this->dom->getElementsByTagName("infAdic")->item(0);
0 ignored issues
show
Bug introduced by
The property infAdic 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->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...
159 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...
160 1
        if ($this->dom->getElementsByTagName("qNFe")->item(0) != "") {
161
            $this->qNFe = $this->dom->getElementsByTagName("qNFe")->item(0)->nodeValue;
162
        }
163 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...
164 1
        if ($this->dom->getElementsByTagName("qNF")->item(0) != "") {
165
            $this->qNF = $this->dom->getElementsByTagName("qNF")->item(0)->nodeValue;
166
        }
167 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...
168 1
        if ($this->dom->getElementsByTagName("qCTe")->item(0) != "") {
169 1
            $this->qCTe = $this->dom->getElementsByTagName("qCTe")->item(0)->nodeValue;
170
        }
171 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...
172 1
        if ($this->dom->getElementsByTagName("qCT")->item(0) != "") {
173
            $this->qCT = $this->dom->getElementsByTagName("qCT")->item(0)->nodeValue;
174
        }
175 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...
176 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...
177 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...
178 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...
179 1
        if ($this->dom->getElementsByTagName('CIOT')->item(0) != "") {
180
            $this->ciot = $this->dom->getElementsByTagName('CIOT')->item(0)->nodeValue;
181
        }
182 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...
183 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...
184 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...
185 1
        if ($this->dom->getElementsByTagName("valePed")->item(0) != "") {
186
            $this->valePed = $this->dom->getElementsByTagName("valePed")->item(0)->getElementsByTagName("disp");
187
        }
188 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...
189 1
        $this->chMDFe = str_replace(
190 1
            'MDFe',
191 1
            '',
192 1
            $this->infMDFe->getAttribute("Id")
193
        );
194 1
        if (is_object($this->mdfeProc)) {
195 1
            $this->nProt = ! empty($this->mdfeProc->getElementsByTagName("nProt")->item(0)->nodeValue) ?
196 1
                    $this->mdfeProc->getElementsByTagName("nProt")->item(0)->nodeValue : '';
197 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...
198
        }
199 1
    }//fim construct
200
    /**
201
     *buildMDFe
202
     *
203
     */
204 1
    public function buildMDFe()
205
    {
206 1
        $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel);
207 1
        if ($this->orientacao == 'P') {
208
            // margens do PDF
209 1
            $margSup = 7;
210 1
            $margEsq = 7;
211 1
            $margDir = 7;
212
            // posição inicial do relatorio
213 1
            $xInic = 7;
214 1
            $yInic = 7;
215 1
            if ($this->papel =='A4') { //A4 210x297mm
216 1
                $maxW = 210;
217 1
                $maxH = 297;
218
            }
219
        } else {
220
            // margens do PDF
221
            $margSup = 7;
222
            $margEsq = 7;
223
            $margDir = 7;
224
            // posição inicial do relatorio
225
            $xInic = 7;
226
            $yInic = 7;
227
            if ($this->papel =='A4') { //A4 210x297mm
228
                $maxH = 210;
229
                $maxW = 297;
230
            }
231
        }//orientação
232
        //largura imprimivel em mm
233 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...
234
        //comprimento imprimivel em mm
235 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...
236
        // estabelece contagem de paginas
237 1
        $this->pdf->AliasNbPages();
238
        // fixa as margens
239 1
        $this->pdf->SetMargins($margEsq, $margSup, $margDir);
240 1
        $this->pdf->SetDrawColor(0, 0, 0);
241 1
        $this->pdf->SetFillColor(255, 255, 255);
242
        // inicia o documento
243 1
        $this->pdf->Open();
244
        // adiciona a primeira página
245 1
        $this->pdf->AddPage($this->orientacao, $this->papel);
246 1
        $this->pdf->SetLineWidth(0.1);
247 1
        $this->pdf->SetTextColor(0, 0, 0);
248
        //montagem da página
249 1
        $pag = 1;
250 1
        $x = $xInic;
251 1
        $y = $yInic;
252
        //coloca o cabeçalho Paisagem
253 1
        if ($this->orientacao == 'P') {
254 1
            $y = $this->headerMDFeRetrato($x, $y, $pag);
255
        } else {
256
            $y = $this->headerMDFePaisagem($x, $y, $pag);
257
        }
258
        //coloca os dados da MDFe
259 1
        $y = $this->bodyMDFe($x, $y);
260
        //coloca os dados da MDFe
261 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...
262 1
    } //fim buildCCe
263
    /**
264
     * headerMDFePaisagem
265
     * @param float $x
266
     * @param float $y
267
     * @param integer $pag
268
     * @return string
269
     */
270
    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...
271
    {
272
        $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...
273
        $oldY = $y;
274
        $maxW = $this->wPrint;
275
        //####################################################################################
276
        //coluna esquerda identificação do emitente
277
        $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...
278
        $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...
279
        $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...
280
        $h=30;
281
        $oldY += $h;
282
        $this->pTextBox($x, $y, $w, $h);
283
        if (is_file($this->logomarca)) {
284
            $logoInfo = getimagesize($this->logomarca);
285
            //largura da imagem em mm
286
            $logoWmm = ($logoInfo[0]/72)*25.4;
287
            //altura da imagem em mm
288
            $logoHmm = ($logoInfo[1]/72)*25.4;
289
            if ($this->logoAlign=='L') {
290
                $nImgW = round($w/4.5, 0);
291
                $nImgH = round($logoHmm * ($nImgW/$logoWmm), 0);
292
                $xImg = $x+1;
293
                $yImg = round(($h-$nImgH)/2, 0)+$y;
294
                //estabelecer posições do texto
295
                $x1 = round($xImg + $nImgW +1, 0);
296
                $y1 = round($y+2, 0);
297
                $tw = round(2*$w/3, 0);
298
            }
299
            if ($this->logoAlign=='C') {
300
                $nImgH = round($h/3, 0);
301
                $nImgW = round($logoWmm * ($nImgH/$logoHmm), 0);
302
                $xImg = round(($w-$nImgW)/2+$x, 0);
303
                $yImg = $y+3;
304
                $x1 = $x;
305
                $y1 = round($yImg + $nImgH + 1, 0);
306
                $tw = $w;
307
            }
308
            if ($this->logoAlign=='R') {
309
                $nImgW = round($w/3, 0);
310
                $nImgH = round($logoHmm * ($nImgW/$logoWmm), 0);
311
                $xImg = round($x+($w-(1+$nImgW)), 0);
312
                $yImg = round(($h-$nImgH)/2, 0)+$y;
313
                $x1 = $x;
314
                $y1 = round($h/3+$y, 0);
315
                $tw = round(2*$w/3, 0);
316
            }
317
            $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...
318
        } else {
319
            $x1 = $x;
320
            $y1 = round($h/3+$y, 0);
321
            $tw = $w;
322
        }
323
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
324
        $razao = $this->xNome;
325
        $cnpj = 'CNPJ: '.$this->pFormat($this->CNPJ, "###.###.###/####-##");
326
        $ie = 'IE: '.$this->pFormat($this->IE, '##/########');
327
        $lgr = 'Logradouro: '.$this->xLgr;
328
        $nro = 'Nº: '.$this->nro;
329
        $bairro = 'Bairro: '.$this->xBairro;
330
        $CEP = $this->CEP;
331
        $CEP = 'CEP: '.$this->pFormat($CEP, "##.###-###");
332
        $UF = 'UF: '.$this->UF;
333
        $mun = 'Municipio: '.$this->xMun;
334
335
        $texto = $razao . "\n" . $cnpj . ' - ' . $ie . "\n";
336
        $texto .= $lgr . ' - ' . $nro . "\n";
337
        $texto .= $bairro . "\n";
338
        $texto .= $UF . ' - ' . $mun . ' - ' . $CEP;
339
        $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...
340
        $x = $x+$maxW/2;
341
        $w = $maxW / 2;
342
        $this->pTextBox($x, $y, $w, $h);
343
        $aFont = array('font'=>$this->fontePadrao, 'size'=>12, 'style'=>'I');
344
        $this->pTextBox(
345
            $x,
346
            $y,
347
            $w,
348
            8,
349
            'DAMDFE - Documento Auxiliar de Manifesto Eletronico de Documentos Fiscais',
350
            $aFont,
351
            'T',
352
            'C',
353
            0,
354
            ''
355
        );
356
        $this->pTextBox($x, $y, $w, 6);
357
        $bH = 13;
358
        $bW = round(($w), 0);
359
        $this->pdf->SetFillColor(0, 0, 0);
360
        $this->pdf->Code128($x+5, $y+7.5, $this->chMDFe, $bW-10, $bH);
361
        $this->pdf->SetFillColor(255, 255, 255);
362
        $y = $y + 22;
363
        $this->pTextBox($x, $y, $w, 8);
364
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'I');
365
        $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...
366
        $texto = 'CHAVE DE ACESSO';
367
        $this->pTextBox($x, $y, $maxW, 6, $texto, $aFont, 'T', 'L', 0, '');
368
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
369
        $texto = $this->pFormat($this->chMDFe, $this->formatoChave);
370
        $this->pTextBox($x, $y+3, $w, 6, $texto, $aFont, 'T', 'C', 0, '');
371
        $y = $y + 11;
372
        $this->pTextBox($x, $y, $w, 12);
373
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'I');
374
        $texto = 'PROTOCOLO DE AUTORIZACAO DE USO';
375
        $this->pTextBox($x, $y, $w, 8, $texto, $aFont, 'T', 'L', 0, '');
376
377
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
378
        if (is_object($this->mdfeProc)) {
379
            $tsHora = $this->pConvertTime($this->dhRecbto);
380
            $texto = $this->nProt.' - '.date('d/m/Y   H:i:s', $tsHora);
381
        } else {
382
            $texto = 'DAMDFE impresso em contingência - '.date('d/m/Y   H:i:s');
383
        }
384
        $this->pTextBox($x, $y+4, $w, 8, $texto, $aFont, 'T', 'C', 0, '');
385
        if ($this->tpAmb != 1) {
386
            $x = 10;
387
            if ($this->orientacao == 'P') {
388
                $yy = round($this->hPrint*2/3, 0);
389
            } else {
390
                $yy = round($this->hPrint/2, 0);
391
            }
392
            $h = 5;
393
            $w = $maxW-(2*$x);
394
            $this->pdf->SetTextColor(90, 90, 90);
395
            $texto = "SEM VALOR FISCAL";
396
            $aFont = array('font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B');
397
            $this->pTextBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
398
            $aFont = array('font'=>$this->fontePadrao, 'size'=>30, 'style'=>'B');
399
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
400
            $this->pTextBox($x, $yy+14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
401
            $this->pdf->SetTextColor(0, 0, 0);
402
        } else {
403
            $x = 10;
404
            if ($this->orientacao == 'P') {
405
                $yy = round($this->hPrint*2/3, 0);
406
            } else {
407
                $yy = round($this->hPrint/2, 0);
408
            }//fim orientacao
409
            $h = 5;
410
            $w = $maxW-(2*$x);
411
            $this->pdf->SetTextColor(90, 90, 90);
412
            //indicar FALTA DO PROTOCOLO se MDFe não for em contingência
413
            if (($this->tpEmis == 2 || $this->tpEmis == 5)) {
414
                //Contingência
415
                $texto = "DAMDFE Emitido em Contingência";
416
                $aFont = array('font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B');
417
                $this->pTextBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
418
                $aFont = array('font'=>$this->fontePadrao, 'size'=>30, 'style'=>'B');
419
                $texto = "devido à problemas técnicos";
420
                $this->pTextBox($x, $yy+12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
421
            }
422
            $this->pdf->SetTextColor(0, 0, 0);
423
        }
424
        return $y;
425
    }// fim headerMDFe
426
427
    /**
428
     * headerMDFeRetrato
429
     *
430
     * @param float $x
431
     * @param float $y
432
     * @param integer $pag
433
     * @return string
434
     */
435 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...
436
    {
437 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...
438 1
        $oldY = $y;
439 1
        $maxW = $this->wPrint;
440
        //####################################################################################
441
        //coluna esquerda identificação do emitente
442 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...
443 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...
444 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...
445 1
        $h=20;
446 1
        $oldY += $h;
447 1
        $this->pTextBox($x, $y, $w, $h);
448 1
        if (is_file($this->logomarca)) {
449
            $logoInfo = getimagesize($this->logomarca);
450
            //largura da imagem em mm
451
            $logoWmm = ($logoInfo[0]/72)*25.4;
452
            //altura da imagem em mm
453
            $logoHmm = ($logoInfo[1]/72)*25.4;
454
            if ($this->logoAlign=='L') {
455
                $nImgW = round($w/8, 0);
456
                $nImgH = round($logoHmm * ($nImgW/$logoWmm), 0);
457
                $xImg = $x+1;
458
                $yImg = round(($h-$nImgH)/2, 0)+$y;
459
                //estabelecer posições do texto
460
                $x1 = round($xImg + $nImgW +1, 0);
461
                $y1 = round($y+2, 0);
462
                $tw = round(2*$w/3, 0);
463
            }
464
            if ($this->logoAlign=='C') {
465
                $nImgH = round($h/3, 0);
466
                $nImgW = round($logoWmm * ($nImgH/$logoHmm), 0);
467
                $xImg = round(($w-$nImgW)/2+$x, 0);
468
                $yImg = $y+3;
469
                $x1 = $x;
470
                $y1 = round($yImg + $nImgH + 1, 0);
471
                $tw = $w;
472
            }
473
            if ($this->logoAlign=='R') {
474
                $nImgW = round($w/3, 0);
475
                $nImgH = round($logoHmm * ($nImgW/$logoWmm), 0);
476
                $xImg = round($x+($w-(1+$nImgW)), 0);
477
                $yImg = round(($h-$nImgH)/2, 0)+$y;
478
                $x1 = $x;
479
                $y1 = round($h/3+$y, 0);
480
                $tw = round(2*$w/3, 0);
481
            }
482
            $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...
483
        } else {
484 1
            $x1 = $x+40;
485 1
            $y1 = $y;
486 1
            $tw = $w;
487
        }
488 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
489 1
        $razao = $this->xNome;
490 1
        $cnpj = 'CNPJ: '.$this->pFormat($this->CNPJ, "###.###.###/####-##");
491 1
        $ie = 'IE: '.$this->pFormat($this->IE, '###/#######');
492 1
        $lgr = 'Logradouro: '.$this->xLgr;
493 1
        $nro = 'Nº: '.$this->nro;
494 1
        $bairro = 'Bairro: '.$this->xBairro;
495 1
        $CEP = $this->CEP;
496 1
        $CEP = 'CEP: '.$this->pFormat($CEP, "##.###-###");
497 1
        $mun = 'Municipio: '.$this->xMun;
498 1
        $UF = 'UF: '.$this->UF;
499 1
        $texto = $razao . "\n" . $cnpj . ' - ' . $ie . "\n";
500 1
        $texto .= $lgr . ' - ' . $nro . "\n";
501 1
        $texto .= $bairro . "\n";
502 1
        $texto .= $UF . ' - ' . $mun . ' - ' . $CEP;
503 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...
504
        //##################################################
505 1
        $y = $h + 8;
506 1
        $this->pTextBox($x, $y, $maxW, 6);
507 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>12, 'style'=>'I');
508 1
        $this->pTextBox(
509 1
            $x,
510 1
            $y,
511 1
            $maxW,
512 1
            8,
513 1
            'DAMDFE - Documento Auxiliar de Manifesto Eletronico de Documentos Fiscais',
514 1
            $aFont,
515 1
            'T',
516 1
            'C',
517 1
            0,
518 1
            ''
519
        );
520 1
        $y = $y + 8;
521 1
        $this->pTextBox($x, $y, $maxW, 20);
522 1
        $bH = 16;
523 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...
524 1
        $this->pdf->SetFillColor(0, 0, 0);
525 1
        $this->pdf->Code128($x + 5, $y+2, $this->chMDFe, $maxW - 10, $bH);
526 1
        $this->pdf->SetFillColor(255, 255, 255);
527 1
        $y = $y + 22;
528 1
        $this->pTextBox($x, $y, $maxW, 10);
529 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'I');
530 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...
531 1
        $texto = 'CHAVE DE ACESSO';
532 1
        $this->pTextBox($x, $y, $maxW, 6, $texto, $aFont, 'T', 'L', 0, '');
533 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
534 1
        $texto = $this->pFormat($this->chMDFe, $this->formatoChave);
535 1
        $this->pTextBox($x, $y+4, $maxW, 6, $texto, $aFont, 'T', 'C', 0, '');
536 1
        $y = $y + 12;
537 1
        $this->pTextBox($x, $y, $maxW, 10);
538 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'I');
539 1
        $texto = 'PROTOCOLO DE AUTORIZACAO DE USO';
540 1
        $this->pTextBox($x, $y, $maxW, 8, $texto, $aFont, 'T', 'L', 0, '');
541 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
542 1
        if (is_object($this->mdfeProc)) {
543 1
            $tsHora = $this->pConvertTime($this->dhRecbto);
544 1
            $texto = $this->nProt.' - '.date('d/m/Y   H:i:s', $tsHora);
545
        } else {
546
            $texto = 'DAMDFE impresso em contingência - '.date('d/m/Y   H:i:s');
547
        }
548 1
        $this->pTextBox($x, $y+4, $maxW, 8, $texto, $aFont, 'T', 'C', 0, '');
549 1
        if ($this->tpAmb != 1) {
550 1
            $x = 10;
551 1
            if ($this->orientacao == 'P') {
552 1
                $yy = round($this->hPrint*2/3, 0);
553
            } else {
554
                $yy = round($this->hPrint/2, 0);
555
            }
556 1
            $h = 5;
557 1
            $w = $maxW-(2*$x);
558 1
            $this->pdf->SetTextColor(90, 90, 90);
559 1
            $texto = "SEM VALOR FISCAL";
560 1
            $aFont = array('font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B');
561 1
            $this->pTextBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
562 1
            $aFont = array('font'=>$this->fontePadrao, 'size'=>30, 'style'=>'B');
563 1
            $texto = "AMBIENTE DE HOMOLOGAÇÃO";
564 1
            $this->pTextBox($x, $yy+14, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
565 1
            $this->pdf->SetTextColor(0, 0, 0);
566
        } else {
567
            $x = 10;
568
            if ($this->orientacao == 'P') {
569
                $yy = round($this->hPrint*2/3, 0);
570
            } else {
571
                $yy = round($this->hPrint/2, 0);
572
            }//fim orientacao
573
            $h = 5;
574
            $w = $maxW-(2*$x);
575
            $this->pdf->SetTextColor(90, 90, 90);
576
            //indicar FALTA DO PROTOCOLO se MDFe não for em contingência
577
            if (($this->tpEmis == 2 || $this->tpEmis == 5)) {
578
                //Contingência
579
                $texto = "DAMDFE Emitido em Contingência";
580
                $aFont = array('font'=>$this->fontePadrao, 'size'=>48, 'style'=>'B');
581
                $this->pTextBox($x, $yy, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
582
                $aFont = array('font'=>$this->fontePadrao, 'size'=>30, 'style'=>'B');
583
                $texto = "devido à problemas técnicos";
584
                $this->pTextBox($x, $yy+12, $w, $h, $texto, $aFont, 'C', 'C', 0, '');
585
            }
586
            $this->pdf->SetTextColor(0, 0, 0);
587
        }
588 1
        return $y+12;
589
    }// fim headerMDFe
590
591
    /**
592
     * bodyMDFe
593
     *
594
     * @param float $x
595
     * @param float $y
596
     * @return void
597
     */
598 1
    private function bodyMDFe($x, $y)
599
    {
600 1
        if ($this->orientacao == 'P') {
601 1
            $maxW = $this->wPrint;
602
        } else {
603
            $maxW = $this->wPrint / 2;
604
        }
605 1
        $x2 = ($maxW / 6);
606 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...
607 1
        $this->pTextBox($x, $y, $x2-7, 12);
608 1
        $texto = 'Modelo';
609 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
610 1
        $this->pTextBox($x, $y, $x2-7, 8, $texto, $aFont, 'T', 'L', 0, '', false);
611 1
        $texto = $this->mod;
612 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
613 1
        $this->pTextBox($x, $y+4, $x2-7, 10, $texto, $aFont, 'T', 'C', 0, '', false);
614 1
        $x1 = $x2;
615 1
        $this->pTextBox($x1, $y, $x2-7, 12);
616 1
        $texto = 'Série';
617 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
618 1
        $this->pTextBox($x1, $y, $x2-7, 8, $texto, $aFont, 'T', 'L', 0, '', false);
619 1
        $texto = $this->serie;
620 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
621 1
        $this->pTextBox($x1, $y+4, $x2-7, 10, $texto, $aFont, 'T', 'C', 0, '', false);
622 1
        $x1 += $x2-7;
623 1
        $this->pTextBox($x1, $y, $x2+5, 12);
624 1
        $texto = 'Número';
625 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
626 1
        $this->pTextBox($x1, $y, $x2+5, 8, $texto, $aFont, 'T', 'L', 0, '', false);
627 1
        $texto = $this->pFormat(str_pad($this->nMDF, 9, '0', STR_PAD_LEFT), '###.###.###');
628 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
629 1
        $this->pTextBox($x1, $y+4, $x2+5, 10, $texto, $aFont, 'T', 'C', 0, '', false);
630 1
        $x1 += $x2+5;
631 1
        $this->pTextBox($x1, $y, $x2-7, 12);
632 1
        $texto = 'FL';
633 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
634 1
        $this->pTextBox($x1, $y, $x2-7, 8, $texto, $aFont, 'T', 'L', 0, '', false);
635 1
        $texto = '1';
636 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
637 1
        $this->pTextBox($x1, $y+4, $x2-7, 10, $texto, $aFont, 'T', 'C', 0, '', false);
638 1
        $x1 += $x2-7;
639 1
        $this->pTextBox($x1, $y, $x2+11, 12);
640 1
        $texto = 'Data e Hora de Emissão';
641 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
642 1
        $this->pTextBox($x1, $y, $x2+11, 8, $texto, $aFont, 'T', 'L', 0, '', false);
643 1
        $data = explode('T', $this->dhEmi);
644 1
        $texto = $this->pYmd2dmy($data[0]).' - '.$data[1];
645 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
646 1
        $this->pTextBox($x1, $y+4, $x2+11, 10, $texto, $aFont, 'T', 'C', 0, '', false);
647 1
        $x1 += $x2+11;
648 1
        $this->pTextBox($x1, $y, $x2-15, 12);
649 1
        $texto = 'UF Carreg.';
650 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
651 1
        $this->pTextBox($x1, $y, $x2-15, 8, $texto, $aFont, 'T', 'L', 0, '', false);
652 1
        $texto = $this->UFIni;
653 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
654 1
        $this->pTextBox($x1, $y+4, $x2-15, 10, $texto, $aFont, 'T', 'C', 0, '', false);
655 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...
656
657 1
        $x1 += $x2-15;
658 1
        $this->pTextBox($x1, $y, $x2-13, 12);
659 1
        $texto = 'UF Descar.';
660 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
661 1
        $this->pTextBox($x1, $y, $x2-13, 8, $texto, $aFont, 'T', 'L', 0, '', false);
662 1
        $texto = $this->UFFim;
663 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
664 1
        $this->pTextBox($x1, $y+4, $x2-13, 10, $texto, $aFont, 'T', 'C', 0, '', false);
665 1
        $maxW = $this->wPrint;
666
667
668
669 1
        $x1 = $x;
670 1
        $x2 = $maxW;
671 1
        $y += 14;
672 1
        $this->pTextBox($x1, $y, $x2, 23);
673 1
        $texto = 'Modal Rodoviário de Carga';
674 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'B');
675 1
        $this->pTextBox($x1, $y+1, $x2, 8, $texto, $aFont, 'T', 'C', 0, '', false);
676 1
        $x1 = $x;
677 1
        $x2 = ($maxW / 6);
678 1
        $y += 6;
679 1
        $this->pTextBox($x1, $y, $x2, 12);
680 1
        $texto = 'Qtd. CT-e';
681 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
682 1
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
683 1
        $texto = str_pad($this->qCTe, 3, '0', STR_PAD_LEFT);
684 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
685 1
        $this->pTextBox($x1, $y+4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
686 1
        $x1 += $x2;
687 1
        $this->pTextBox($x1, $y, $x2, 12);
688 1
        $texto = 'Qtd. NF-e';
689 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
690 1
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
691 1
        $texto = str_pad($this->qNFe, 3, '0', STR_PAD_LEFT);
692 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
693 1
        $this->pTextBox($x1, $y+4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
694 1
        $x1 += $x2;
695 1
        $this->pTextBox($x1, $y, $x2, 12);
696 1
        $texto = 'Peso Total (Kg)';
697 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
698 1
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
699 1
        $texto = number_format($this->qCarga, 4, ', ', '.');
700 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
701 1
        $this->pTextBox($x1, $y+4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
702 1
        $x1 = $x;
703 1
        $y += 12;
704 1
        $yold = $y;
705 1
        $x2 = round($maxW / 2, 0);
706 1
        $texto = 'Veículo';
707 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
708 1
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
709 1
        $y += 5;
710 1
        $x2 = round($maxW / 4, 0);
711 1
        $tamanho = 22;
712 1
        $this->pTextBox($x1, $y, $x2, $tamanho);
713 1
        $texto = 'Placa';
714 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
715 1
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
716 1
        $texto = $this->veicTracao->getElementsByTagName("placa")->item(0)->nodeValue;
717 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
718 1
        $this->pTextBox($x1, $y+4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
719 1
        $altura = $y + 4;
720
        /** @var \DOMNodeList $veicReboque */
721 1
        $veicReboque = $this->veicReboque;
722 1
        foreach ($veicReboque as $item) {
723
            /** @var \DOMElement $item */
724 1
            $altura += 4;
725 1
            $texto = $item->getElementsByTagName('placa')->item(0)->nodeValue;
726 1
            $this->pTextBox($x1, $altura, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
727
        }
728 1
        $x1 += $x2;
729 1
        $this->pTextBox($x1, $y, $x2, $tamanho);
730 1
        $texto = 'RNTRC';
731 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
732 1
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
733
        // RNTRC Não informado
734 1
        if ($this->rodo->getElementsByTagName("RNTRC")->length > 0) {
735 1
            $texto = $this->rodo->getElementsByTagName("RNTRC")->item(0)->nodeValue;
736
        } else {
737
            $texto = "";
738
        }
739 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
740 1
        $this->pTextBox($x1, $y+4, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
741 1
        $altura = $y + 4;
742
        /** @var \DOMNodeList $veicReboque */
743 1
        $veicReboque = $this->veicReboque;
744 1
        foreach ($veicReboque as $item) {
745
            /** @var \DOMElement $item */
746 1
            $DOMNodeList = $item->getElementsByTagName('RNTRC');
747 1
            if ($DOMNodeList->length > 0) {
748
                $altura += 4;
749
                $texto = $DOMNodeList->item(0)->nodeValue;
750 1
                $this->pTextBox($x1, $altura, $x2, 10, $texto, $aFont, 'T', 'C', 0, '', false);
751
            }
752
        }
753 1
        $x1 = $x;
754 1
        $y += 22;
755 1
        $x2 = round($maxW / 2, 0);
756 1
        $valesPedagios = 1;
757 1
        $temVales = false;
758 1
        if ($this->valePed != "" && $this->valePed->length > 0) {
759
            $valesPedagios = $this->valePed->length;
760
            $temVales = true;
761
        }
762 1
        $tamanho = ($valesPedagios * 7.5);
763 1
        if (!$temVales) {
764 1
            $valesPedagios = 0;
765
        }
766 1
        $this->pTextBox($x1, $y, $x2, 11+$tamanho/2);
767 1
        $texto = 'Vale Pedágio';
768 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
769 1
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
770 1
        $y += 5;
771 1
        $x2 = ($x2 / 3);
772 1
        $this->pTextBox($x1, $y, $x2-3, 6+($tamanho/2));
773 1
        $texto = 'Responsável CNPJ';
774 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
775 1
        $this->pTextBox($x1, $y, $x2-4, 8, $texto, $aFont, 'T', 'L', 0, '', false);
776 1
        $altura = $y;
777 1
        for ($i = 0; $i < $valesPedagios; $i++) {
778
            $altura += 4;
779
            $texto = $this->valePed->item($i)->getElementsByTagName('CNPJForn')->item(0)->nodeValue;
780
            $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
781
            $this->pTextBox($x1 + 1, $altura, $x2-5, 10, $texto, $aFont, 'T', 'L', 0, '', false);
782
        }
783 1
        $x1 += $x2-3;
784 1
        $this->pTextBox($x1, $y, $x2-3, 6+($tamanho/2));
785 1
        $texto = 'Fornecedora CNPJ';
786 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
787 1
        $this->pTextBox($x1, $y, $x2-4, 8, $texto, $aFont, 'T', 'L', 0, '', false);
788 1
        $altura = $y;
789 1
        for ($i = 0; $i < $valesPedagios; $i++) {
790
            $altura += 4;
791
            $texto = $this->valePed->item($i)->getElementsByTagName('CNPJPg')->item(0)->nodeValue;
792
            $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
793
            $this->pTextBox($x1 + 1, $altura, $x2-5, 10, $texto, $aFont, 'T', 'L', 0, '', false);
794
        }
795 1
        $x1 += $x2-3;
796 1
        $this->pTextBox($x1, $y, $x2+6, 6+($tamanho/2));
797 1
        $texto = 'Nº Comprovante';
798 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
799 1
        $this->pTextBox($x1, $y, $x2+6, 8, $texto, $aFont, 'T', 'L', 0, '', false);
800 1
        $altura = $y;
801 1
        for ($i = 0; $i < $valesPedagios; $i++) {
802
            $altura += 4;
803
            $texto = $this->valePed->item($i)->getElementsByTagName('nCompra')->item(0)->nodeValue;
804
            $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
805
            $this->pTextBox($x1 + 1, $altura, $x2+5, 10, $texto, $aFont, 'T', 'L', 0, '', false);
806
        }
807 1
        if (!$temVales) {
808 1
            $altura += 4;
809
        }
810 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...
811 1
        $x1 = round($maxW / 2, 0) + 7;
812 1
        $y = $yold;
813 1
        $x2 = round($maxW / 2, 0);
814 1
        $texto = 'Condutor';
815 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
816 1
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
817 1
        $y += 5;
818 1
        $x2 = ($maxW / 4);
819 1
        $this->pTextBox($x1, $y, $x2, 33+($tamanho/2));
820 1
        $texto = 'CPF';
821 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
822 1
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
823 1
        $yold = $y;
824 1
        for ($i = 0; $i < $this->condutor->length; $i++) {
825 1
            $y += 4;
826 1
            $texto = $this->condutor->item($i)->getElementsByTagName('CPF')->item(0)->nodeValue;
827 1
            $aFont = array('font'=>$this->fontePadrao, 'size'=>10, 'style'=>'');
828 1
            $this->pTextBox($x1 + 1, $y, $x2 - 1, 10, $texto, $aFont, 'T', 'L', 0, '', false);
829
        }
830 1
        $y = $yold;
831 1
        $x1 += $x2;
832 1
        $this->pTextBox($x1, $y, $x2, 33+($tamanho/2));
833 1
        $texto = 'Nome';
834 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
835 1
        $this->pTextBox($x1, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
836 1
        for ($i = 0; $i < $this->condutor->length; $i++) {
837 1
            $y += 4;
838 1
            $texto = $this->condutor->item($i)->getElementsByTagName('xNome')->item(0)->nodeValue;
839 1
            $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
840 1
            $this->pTextBox($x1 + 1, $y, $x2 - 1, 8, $texto, $aFont, 'T', 'L', 0, '', false);
841
        }
842 1
        return $altura + 7;
843
    }//fim bodyMDFe
844
    /**
845
     * footerMDFe
846
     *
847
     * @param float $x
848
     * @param float $y
849
     */
850 1
    private function footerMDFe($x, $y)
851
    {
852 1
        $maxW = $this->wPrint;
853 1
        $x2 = $maxW;
854 1
        $this->pTextBox($x, $y, $x2, 30);
855 1
        $texto = 'Observação ';
856 1
        if (isset($this->infAdic)) {
857 1
            $texto .= $this->infCpl;
858
        }
859 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>8, 'style'=>'');
860 1
        $this->pTextBox($x, $y, $x2, 8, $texto, $aFont, 'T', 'L', 0, '', false);
861 1
        $y = $this->hPrint -4;
862 1
        $texto = "Impresso em  ". date('d/m/Y   H:i:s');
863 1
        $w = $this->wPrint-4;
864 1
        $aFont = array('font'=>$this->fontePadrao, 'size'=>6, 'style'=>'I');
865 1
        $this->pTextBox($x, $y, $w, 4, $texto, $aFont, 'T', 'L', 0, '');
866 1
    }//fim footerCCe
867
    /**
868
     * printMDFe
869
     *
870
     * @param string $nome
871
     * @param string $destino
872
     * @param string $printer
873
     * @return string
874
     */
875 1
    public function printMDFe($nome = '', $destino = 'I', $printer = '')
876
    {
877
        //monta
878 1
        $command = '';
879 1
        if ($nome == '') {
880
            $file = $this->pdfDir.'mdfe.pdf';
881
        } else {
882 1
            $file = $this->pdfDir.$nome;
883
        }
884 1
        if ($destino != 'I' && $destino != 'S' && $destino != 'F') {
885
            $destino = 'I';
886
        }
887 1
        if ($printer != '') {
888
            $command = "-P $printer";
889
        }
890
891 1
        $this->buildMDFe();
892 1
        $arq = $this->pdf->Output($file, $destino);
893 1
        if ($destino == 'S' && $command != '') {
894
            //aqui pode entrar a rotina de impressão direta
895
            $command = "lpr $command $file";
896
            system($command, $retorno);
897
        }
898
899 1
        return $arq;
900
    }//fim printMDFe
901
902
    /**
903
     * Dados brutos do PDF
904
     * @return string
905
     */
906
    public function render()
907
    {
908
        return $this->pdf->getPdf();
909
    }
910
911
}
912