Completed
Pull Request — master (#92)
by
unknown
02:47
created

EvtFechaEvPer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 179
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 179
ccs 0
cts 139
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
B toNode() 0 138 3
1
<?php
2
3
namespace NFePHP\eSocial\Factories;
4
5
/**
6
 * Class eSocial EvtFechaEvPer Event S-1299 constructor
7
 *
8
 * @category  NFePHP
9
 * @package   NFePHPSocial
10
 * @copyright NFePHP Copyright (c) 2017
11
 * @license   http://www.gnu.org/licenses/lgpl.txt LGPLv3+
12
 * @license   https://opensource.org/licenses/MIT MIT
13
 * @license   http://www.gnu.org/licenses/gpl.txt GPLv3+
14
 * @author    Roberto L. Machado <linux.rlm at gmail dot com>
15
 * @link      http://github.com/nfephp-org/sped-esocial for the canonical source repository
16
 */
17
18
use NFePHP\Common\Certificate;
19
use NFePHP\eSocial\Common\Factory;
20
use NFePHP\eSocial\Common\FactoryId;
21
use NFePHP\eSocial\Common\FactoryInterface;
22
use stdClass;
23
24
class EvtFechaEvPer extends Factory implements FactoryInterface
25
{
26
    /**
27
     * @var int
28
     */
29
    public $sequencial;
30
31
    /**
32
     * @var string
33
     */
34
    protected $evtName = 'evtFechaEvPer';
35
    /**
36
     * @var string
37
     */
38
    protected $evtAlias = 'S-1299';
39
    /**
40
     * Parameters patterns
41
     *
42
     * @var array
43
     */
44
    protected $parameters = [];
45
46
    /**
47
     * Constructor
48
     *
49
     * @param string      $config
50
     * @param stdClass    $std
51
     * @param Certificate $certificate
52
     */
53
    public function __construct(
54
        $config,
55
        stdClass $std,
56
        Certificate $certificate
57
    ) {
58
        parent::__construct($config, $std, $certificate);
59
    }
60
61
    /**
62
     * Node constructor
63
     */
64
    protected function toNode()
65
    {
66
        $evtid = FactoryId::build(
67
            $this->tpInsc,
68
            $this->nrInsc,
69
            $this->date,
70
            $this->sequencial
71
        );
72
        $eSocial = $this->dom->getElementsByTagName("eSocial")->item(0);
73
        $evtFechaEvPer = $this->dom->createElement("evtFechaEvPer");
74
        $att = $this->dom->createAttribute('Id');
75
        $att->value = $evtid;
76
        $evtFechaEvPer->appendChild($att);
77
78
        $ideEvento = $this->dom->createElement("ideEvento");
79
        $this->dom->addChild(
80
            $ideEvento,
81
            "indApuracao",
82
            $this->std->indapuracao,
83
            true
84
        );
85
        $this->dom->addChild(
86
            $ideEvento,
87
            "perApur",
88
            $this->std->perapur,
89
            true
90
        );
91
        $this->dom->addChild(
92
            $ideEvento,
93
            "tpAmb",
94
            $this->tpAmb,
95
            true
96
        );
97
        $this->dom->addChild(
98
            $ideEvento,
99
            "procEmi",
100
            $this->procEmi,
101
            true
102
        );
103
        $this->dom->addChild(
104
            $ideEvento,
105
            "verProc",
106
            $this->verProc,
107
            true
108
        );
109
        $evtFechaEvPer->appendChild($ideEvento);
110
111
        $ideEmpregador = $this->dom->createElement("ideEmpregador");
112
        $this->dom->addChild(
113
            $ideEmpregador,
114
            "tpInsc",
115
            $this->tpInsc,
116
            true
117
        );
118
        $this->dom->addChild(
119
            $ideEmpregador,
120
            "nrInsc",
121
            $this->nrInsc,
122
            true
123
        );
124
        $evtFechaEvPer->appendChild($ideEmpregador);
125
126
        $ideRespInf = $this->dom->createElement("ideRespInf");
127
        $this->dom->addChild(
128
            $ideRespInf,
129
            "nmResp",
130
            $this->std->iderespinf->nmresp,
131
            true
132
        );
133
        $this->dom->addChild(
134
            $ideRespInf,
135
            "cpfResp",
136
            $this->std->iderespinf->cpfresp,
137
            true
138
        );
139
        $this->dom->addChild(
140
            $ideRespInf,
141
            "telefone",
142
            $this->std->iderespinf->telefone,
143
            true
144
        );
145
        $this->dom->addChild(
146
            $ideRespInf,
147
            "email",
148
            !empty($this->std->iderespinf->email) ? $this->std->iderespinf->email : null,
149
            false
150
        );
151
        $evtFechaEvPer->appendChild($ideRespInf);
152
153
        $infoFech = $this->dom->createElement("infoFech");
154
        $this->dom->addChild(
155
            $infoFech,
156
            "evtRemun",
157
            $this->std->infofech->evtremun,
158
            true
159
        );
160
        $this->dom->addChild(
161
            $infoFech,
162
            "evtPgtos",
163
            $this->std->infofech->evtpgtos,
164
            true
165
        );
166
        $this->dom->addChild(
167
            $infoFech,
168
            "evtAqProd",
169
            $this->std->infofech->evtaqprod,
170
            true
171
        );
172
        $this->dom->addChild(
173
            $infoFech,
174
            "evtComProd",
175
            $this->std->infofech->evtcomprod,
176
            true
177
        );
178
        $this->dom->addChild(
179
            $infoFech,
180
            "evtContratAvNP",
181
            $this->std->infofech->evtcontratavnp,
182
            true
183
        );
184
        $this->dom->addChild(
185
            $infoFech,
186
            "evtInfoComplPer",
187
            $this->std->infofech->evtinfocomplper,
188
            true
189
        );
190
        $this->dom->addChild(
191
            $infoFech,
192
            "compSemMovto",
193
            !empty($this->std->infofech->compsemmovto) ? $this->std->infofech->compsemmovto : null,
194
            false
195
        );
196
        $evtFechaEvPer->appendChild($infoFech);
197
198
199
        $eSocial->appendChild($evtFechaEvPer);
200
        $this->sign($eSocial);
0 ignored issues
show
Unused Code introduced by
The call to EvtFechaEvPer::sign() has too many arguments starting with $eSocial.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
201
    }
202
}
203