EvtExclusao::toNode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 39

Duplication

Lines 39
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 39
loc 39
rs 9.296
cc 1
nc 1
nop 0
1
<?php
2
3
namespace NFePHP\eFinanc\Factories;
4
5
use NFePHP\eFinanc\Common\Factory;
6
use NFePHP\eFinanc\Common\FactoryInterface;
7
use NFePHP\eFinanc\Common\FactoryId;
8
use NFePHP\Common\Certificate;
9
use stdClass;
10
11 View Code Duplication
class EvtExclusao extends Factory implements FactoryInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
{
13
    /**
14
     * Constructor
15
     * @param string $config
16
     * @param stdClass $std
17
     * @param Certificate $certificate
18
     * @param string $data
19
     */
20
    public function __construct(
21
        $config,
22
        stdClass $std,
23
        Certificate $certificate = null,
24
        $data = ''
25
    ) {
26
        $params = new \stdClass();
27
        $params->evtName = 'evtExclusao';
28
        $params->evtTag = 'evtExclusao';
29
        $params->evtAlias = 'F-5000';
30
        parent::__construct($config, $std, $params, $certificate, $data);
31
    }
32
33
    protected function toNode()
34
    {
35
        $ideDeclarante = $this->node->getElementsByTagName('ideDeclarante')->item(0);
36
        //o idEvento pode variar de evento para evento
37
        //então cada factory individualmente terá de construir o seu
38
        $ideEvento = $this->dom->createElement("ideEvento");
39
        $this->dom->addChild(
40
            $ideEvento,
41
            "tpAmb",
42
            (string) $this->tpAmb,
43
            true
44
        );
45
        $this->dom->addChild(
46
            $ideEvento,
47
            "aplicEmi",
48
            '1',
49
            true
50
        );
51
        $this->dom->addChild(
52
            $ideEvento,
53
            "verAplic",
54
            $this->verAplic,
55
            true
56
        );
57
        $this->node->insertBefore($ideEvento, $ideDeclarante);
58
        $infoExclusao = $this->dom->createElement("infoExclusao");
59
        $this->dom->addChild(
60
            $infoExclusao,
61
            "nrReciboEvento",
62
            $this->std->nrreciboevento,
63
            true
64
        );
65
        $this->node->appendChild($infoExclusao);
66
        
67
        //finalização do xml
68
        $this->eFinanceira->appendChild($this->node);
69
        //$this->xml = $this->dom->saveXML($this->eFinanceira);
70
        $this->sign($this->evtTag);
71
    }
72
}
73