EvtExclusao   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 62
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 62
loc 62
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 12 12 1
A toNode() 39 39 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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