Test Failed
Push — master ( 88ea0f...5ac8de )
by Roberto
03:16 queued 14s
created

TraitS2206   A

Complexity

Total Complexity 33

Size/Duplication

Total Lines 421
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 33
lcom 1
cbo 0
dl 0
loc 421
rs 9.76
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
F toNode250() 0 407 32
A toNodeS100() 0 4 1
1
<?php
2
3
namespace NFePHP\eSocial\Factories\Traits;
4
5
trait TraitS2206
6
{
7
    /**
8
     * builder for version 2.5.0
9
     */
10
    protected function toNode250()
11
    {
12
        $ideEmpregador = $this->node->getElementsByTagName('ideEmpregador')->item(0);
0 ignored issues
show
Bug introduced by
The property node 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...
13
        $ideEvento = $this->dom->createElement("ideEvento");
0 ignored issues
show
Bug introduced by
The property dom 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...
14
        $this->dom->addChild(
15
            $ideEvento,
16
            "indRetif",
17
            $this->std->indretif,
0 ignored issues
show
Bug introduced by
The property std 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...
18
            true
19
        );
20
        $this->dom->addChild(
21
            $ideEvento,
22
            "nrRecibo",
23
            ! empty($this->std->nrrecibo) ? $this->std->nrrecibo : null,
24
            false
25
        );
26
        $this->dom->addChild(
27
            $ideEvento,
28
            "tpAmb",
29
            $this->tpAmb,
0 ignored issues
show
Bug introduced by
The property tpAmb 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...
30
            true
31
        );
32
        $this->dom->addChild(
33
            $ideEvento,
34
            "procEmi",
35
            $this->procEmi,
0 ignored issues
show
Bug introduced by
The property procEmi 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...
36
            true
37
        );
38
        $this->dom->addChild(
39
            $ideEvento,
40
            "verProc",
41
            $this->verProc,
0 ignored issues
show
Bug introduced by
The property verProc 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...
42
            true
43
        );
44
        $this->node->insertBefore($ideEvento, $ideEmpregador);
45
        
46
        $ideVinculo = $this->dom->createElement("ideVinculo");
47
        $this->dom->addChild(
48
            $ideVinculo,
49
            "cpfTrab",
50
            $this->std->cpftrab,
51
            true
52
        );
53
        $this->dom->addChild(
54
            $ideVinculo,
55
            "nisTrab",
56
            $this->std->nistrab,
57
            true
58
        );
59
        $this->dom->addChild(
60
            $ideVinculo,
61
            "matricula",
62
            $this->std->matricula,
63
            true
64
        );
65
        $this->node->appendChild($ideVinculo);
66
        
67
        $altContratual = $this->dom->createElement("altContratual");
68
        $this->dom->addChild(
69
            $altContratual,
70
            "dtAlteracao",
71
            $this->std->dtalteracao,
72
            true
73
        );
74
        $this->dom->addChild(
75
            $altContratual,
76
            "dtEf",
77
            !empty($this->std->dtef) ? $this->std->dtef : null,
78
            false
79
        );
80
        $this->dom->addChild(
81
            $altContratual,
82
            "dscAlt",
83
            !empty($this->std->dscalt) ? $this->std->dscalt : null,
84
            false
85
        );
86
        
87
        $vinculo = $this->dom->createElement("vinculo");
88
        $this->dom->addChild(
89
            $vinculo,
90
            "tpRegPrev",
91
            $this->std->tpregprev,
92
            true
93
        );
94
        $altContratual->appendChild($vinculo);
95
96
        $infoRegimeTrab = $this->dom->createElement("infoRegimeTrab");
97
        if (!empty($this->std->infoceletista)) {
98
            $ct = $this->std->infoceletista;
99
            $infoCeletista = $this->dom->createElement("infoCeletista");
100
            $this->dom->addChild(
101
                $infoCeletista,
102
                "tpRegJor",
103
                $ct->tpregjor,
104
                true
105
            );
106
            $this->dom->addChild(
107
                $infoCeletista,
108
                "natAtividade",
109
                $ct->natatividade,
110
                true
111
            );
112
            $this->dom->addChild(
113
                $infoCeletista,
114
                "dtBase",
115
                !empty($ct->dtbase) ? $ct->dtbase : null,
116
                false
117
            );
118
            $this->dom->addChild(
119
                $infoCeletista,
120
                "cnpjSindCategProf",
121
                $ct->cnpjsindcategprof,
122
                true
123
            );
124
            if (!empty($ct->trabtemp)) {
125
                $trabTemp = $this->dom->createElement("trabTemp");
126
                $this->dom->addChild(
127
                    $trabTemp,
128
                    "justProrr",
129
                    $ct->trabtemp->justprorr,
130
                    true
131
                );
132
                $infoCeletista->appendChild($trabTemp);
133
            }
134
            if (!empty($ct->aprend)) {
135
                $aprend = $this->dom->createElement("aprend");
136
                $this->dom->addChild(
137
                    $aprend,
138
                    "tpInsc",
139
                    $ct->aprend->tpinsc,
140
                    true
141
                );
142
                $this->dom->addChild(
143
                    $aprend,
144
                    "nrInsc",
145
                    $ct->aprend->nrinsc,
146
                    true
147
                );
148
                $infoCeletista->appendChild($aprend);
149
            }
150
            $infoRegimeTrab->appendChild($infoCeletista);
151
        } elseif (!empty($this->std->infoestatutario)) {
152
            $ct = $this->std->infoestatutario;
153
            $infoEstatutario = $this->dom->createElement("infoEstatutario");
154
            $this->dom->addChild(
155
                $infoEstatutario,
156
                "tpPlanRP",
157
                $ct->tpPlanRP,
158
                true
159
            );
160
            $infoRegimeTrab->appendChild($infoEstatutario);
161
        }
162
        $altContratual->appendChild($infoRegimeTrab);
163
        
164
        $infoContrato = $this->dom->createElement("infoContrato");
165
        $ct = $this->std->infocontrato;
166
        $this->dom->addChild(
167
            $infoContrato,
168
            "codCargo",
169
            !empty($ct->codcargo) ? $ct->codcargo : null,
170
            false
171
        );
172
        $this->dom->addChild(
173
            $infoContrato,
174
            "codFuncao",
175
            !empty($ct->codfuncao) ? $ct->codfuncao : null,
176
            false
177
        );
178
        $this->dom->addChild(
179
            $infoContrato,
180
            "codCateg",
181
            $ct->codcateg,
182
            true
183
        );
184
        $this->dom->addChild(
185
            $infoContrato,
186
            "codCarreira",
187
            !empty($ct->codcarreira) ? $ct->codcarreira : null,
188
            false
189
        );
190
        $this->dom->addChild(
191
            $infoContrato,
192
            "dtIngrCarr",
193
            !empty($ct->dtingrcarr) ? $ct->dtingrcarr : null,
194
            false
195
        );
196
        $remuneracao = $this->dom->createElement("remuneracao");
197
        $this->dom->addChild(
198
            $remuneracao,
199
            "vrSalFx",
200
            $ct->vrsalfx,
201
            true
202
        );
203
        $this->dom->addChild(
204
            $remuneracao,
205
            "undSalFixo",
206
            $ct->undsalfixo,
207
            true
208
        );
209
        $this->dom->addChild(
210
            $remuneracao,
211
            "dscSalVar",
212
            !empty($ct->dscsalvar) ? $ct->dscsalvar : null,
213
            false
214
        );
215
        $infoContrato->appendChild($remuneracao);
216
        $duracao = $this->dom->createElement("duracao");
217
        $this->dom->addChild(
218
            $duracao,
219
            "tpContr",
220
            $ct->tpcontr,
221
            true
222
        );
223
        $this->dom->addChild(
224
            $duracao,
225
            "dtTerm",
226
            !empty($ct->dtterm) ? $ct->dtterm : null,
227
            false
228
        );
229
        $this->dom->addChild(
230
            $duracao,
231
            "objDet",
232
            !empty($ct->objdet) ? $ct->objdet : null,
233
            false
234
        );
235
        $infoContrato->appendChild($duracao);
236
        
237
        $localTrabalho = $this->dom->createElement("localTrabalho");
238
        if (!empty($this->std->localtrabgeral)) {
239
            $tg = $this->std->localtrabgeral;
240
            $localTrabGeral = $this->dom->createElement("localTrabGeral");
241
            $this->dom->addChild(
242
                $localTrabGeral,
243
                "tpInsc",
244
                $tg->tpinsc,
245
                true
246
            );
247
            $this->dom->addChild(
248
                $localTrabGeral,
249
                "nrInsc",
250
                $tg->nrinsc,
251
                true
252
            );
253
            $this->dom->addChild(
254
                $localTrabGeral,
255
                "descComp",
256
                !empty($tg->desccomp) ? $tg->desccomp : null,
257
                false
258
            );
259
            $localTrabalho->appendChild($localTrabGeral);
260
        } elseif (!empty($this->std->localtrabdom)) {
261
            $tg = $this->std->localtrabdom;
262
            $localTrabDom = $this->dom->createElement("localTrabDom");
263
            $this->dom->addChild(
264
                $localTrabDom,
265
                "tpLograd",
266
                $tg->tplograd,
267
                true
268
            );
269
            $this->dom->addChild(
270
                $localTrabDom,
271
                "dscLograd",
272
                $tg->dsclograd,
273
                true
274
            );
275
            $this->dom->addChild(
276
                $localTrabDom,
277
                "nrLograd",
278
                $tg->nrlograd,
279
                true
280
            );
281
            $this->dom->addChild(
282
                $localTrabDom,
283
                "complemento",
284
                !empty($tg->complemento) ? $tg->complemento : null,
285
                false
286
            );
287
            $this->dom->addChild(
288
                $localTrabDom,
289
                "bairro",
290
                !empty($tg->bairro) ? $tg->bairro : null,
291
                false
292
            );
293
            $this->dom->addChild(
294
                $localTrabDom,
295
                "cep",
296
                $tg->cep,
297
                true
298
            );
299
            $this->dom->addChild(
300
                $localTrabDom,
301
                "codMunic",
302
                $tg->codmunic,
303
                true
304
            );
305
            $this->dom->addChild(
306
                $localTrabDom,
307
                "uf",
308
                $tg->uf,
309
                true
310
            );
311
            $localTrabalho->appendChild($localTrabDom);
312
        }
313
        $infoContrato->appendChild($localTrabalho);
314
        
315
        if (!empty($this->std->horcontratual)) {
316
            $hc = $this->std->horcontratual;
317
            $horContratual = $this->dom->createElement("horContratual");
318
            $this->dom->addChild(
319
                $horContratual,
320
                "qtdHrsSem",
321
                !empty($hc->qtdhrssem) ? $hc->qtdhrssem : null,
322
                false
323
            );
324
            $this->dom->addChild(
325
                $horContratual,
326
                "tpJornada",
327
                $hc->tpjornada,
328
                true
329
            );
330
            $this->dom->addChild(
331
                $horContratual,
332
                "dscTpJorn",
333
                !empty($hc->dsctpjorn) ? $hc->dsctpjorn : null,
334
                false
335
            );
336
            $this->dom->addChild(
337
                $horContratual,
338
                "tmpParc",
339
                $hc->tmpparc,
340
                true
341
            );
342
            if (!empty($hc->horario)) {
343
                foreach ($hc->horario as $hor) {
344
                    $horario = $this->dom->createElement("horario");
345
                    $this->dom->addChild(
346
                        $horario,
347
                        "dia",
348
                        $hor->dia,
349
                        true
350
                    );
351
                    $this->dom->addChild(
352
                        $horario,
353
                        "codHorContrat",
354
                        $hor->codhorcontrat,
355
                        true
356
                    );
357
                    $horContratual->appendChild($horario);
358
                }
359
            }
360
            $infoContrato->appendChild($horContratual);
361
        }
362
        
363
        if (!empty($this->std->filiacaosindical)) {
364
            foreach ($this->std->filiacaosindical as $fs) {
365
                $filiacaoSindical = $this->dom->createElement("filiacaoSindical");
366
                $this->dom->addChild(
367
                    $filiacaoSindical,
368
                    "cnpjSindTrab",
369
                    $fs->cnpjsindtrab,
370
                    true
371
                );
372
                $infoContrato->appendChild($filiacaoSindical);
373
            }
374
        }
375
        
376
        if (!empty($this->std->alvarajudicial)) {
377
            $alvaraJudicial = $this->dom->createElement("alvaraJudicial");
378
            $this->dom->addChild(
379
                $alvaraJudicial,
380
                "nrProcJud",
381
                $this->std->alvarajudicial->nrprocjud,
382
                true
383
            );
384
            $infoContrato->appendChild($alvaraJudicial);
385
        }
386
        
387
        if (!empty($this->std->observacoes)) {
388
            foreach ($this->std->observacoes as $obs) {
389
                $observacoes = $this->dom->createElement("observacoes");
390
                $this->dom->addChild(
391
                    $observacoes,
392
                    "observacao",
393
                    $obs->observacao,
394
                    true
395
                );
396
                $infoContrato->appendChild($observacoes);
397
            }
398
        }
399
        
400
        if (!empty($this->std->servpubl)) {
401
            $servPubl = $this->dom->createElement("servPubl");
402
            $this->dom->addChild(
403
                $servPubl,
404
                "mtvAlter",
405
                $this->std->servpubl->mtvalter,
406
                true
407
            );
408
            $infoContrato->appendChild($servPubl);
409
        }
410
        $altContratual->appendChild($infoContrato);
411
        $this->node->appendChild($altContratual);
412
        //finalização do xml
413
        $this->eSocial->appendChild($this->node);
0 ignored issues
show
Bug introduced by
The property eSocial 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...
414
        //$this->xml = $this->dom->saveXML($this->eSocial);
415
        $this->sign();
0 ignored issues
show
Bug introduced by
It seems like sign() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
416
    }
417
    
418
    /**
419
     * builder for version S.1.0.0
420
     */
421
    protected function toNodeS100()
422
    {
423
        throw new \Exception("TODO !!");
424
    }
425
}
426