Passed
Pull Request — master (#97)
by
unknown
02:23
created

EvtAdmissao::toNode()   F

Complexity

Conditions 77
Paths > 20000

Size

Total Lines 1165
Code Lines 898

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6006

Importance

Changes 0
Metric Value
dl 0
loc 1165
ccs 0
cts 1087
cp 0
rs 2
c 0
b 0
f 0
cc 77
eloc 898
nc 103809024
nop 0
crap 6006

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace NFePHP\eSocial\Factories;
4
5
/**
6
 * Class eSocial EvtAdmissao Event S-2200 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 EvtAdmissao extends Factory implements FactoryInterface
25
{
26
    /**
27
     * @var int
28
     */
29
    public $sequencial = 1;
30
31
    /**
32
     * @var string
33
     */
34
    protected $evtName = 'evtAdmissao';
35
    /**
36
     * @var string
37
     */
38
    protected $evtAlias = 'S-2200';
39
    /**
40
     * @var array
41
     */
42
    protected $parameters = [];
43
44
45
    /**
46
     * Constructor
47
     *
48
     * @param string      $config
49
     * @param stdClass    $std
50
     * @param Certificate $certificate
51
     */
52
    public function __construct(
53
        $config,
54
        stdClass $std,
55
        Certificate $certificate
56
    ) {
57
        parent::__construct($config, $std, $certificate);
58
    }
59
60
    /**
61
     * Node constructor
62
     */
63
    protected function toNode()
64
    {
65
        $evtid = FactoryId::build(
66
            $this->tpInsc,
67
            $this->nrInsc,
68
            $this->date,
69
            $this->sequencial
70
        );
71
        $eSocial = $this->dom->getElementsByTagName("eSocial")->item(0);
72
        $evtAdmissao = $this->dom->createElement("evtAdmissao");
73
        $att = $this->dom->createAttribute('Id');
74
        $att->value = $evtid;
75
        $evtAdmissao->appendChild($att);
76
77
        $ideEvento = $this->dom->createElement("ideEvento");
78
        $this->dom->addChild(
79
            $ideEvento,
80
            "indRetif",
81
            $this->std->indretif,
82
            true
83
        );
84
        $this->dom->addChild(
85
            $ideEvento,
86
            "nrRecibo",
87
            !empty($this->std->nrrecibo) ? $this->std->nrrecibo : null,
88
            false
89
        );
90
        $this->dom->addChild(
91
            $ideEvento,
92
            "tpAmb",
93
            $this->tpAmb,
94
            true
95
        );
96
        $this->dom->addChild(
97
            $ideEvento,
98
            "procEmi",
99
            $this->procEmi,
100
            true
101
        );
102
        $this->dom->addChild(
103
            $ideEvento,
104
            "verProc",
105
            $this->verProc,
106
            true
107
        );
108
        $evtAdmissao->appendChild($ideEvento);
109
110
        $ideEmpregador = $this->dom->createElement("ideEmpregador");
111
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
        $evtAdmissao->appendChild($ideEmpregador);
125
126
        //trabalhador (obrigatório)
127
        $trabalhador = $this->dom->createElement("trabalhador");
128
        $this->dom->addChild(
129
            $trabalhador,
130
            "cpfTrab",
131
            $this->std->trabalhador->cpftrab,
132
            true
133
        );
134
        $this->dom->addChild(
135
            $trabalhador,
136
            "nisTrab",
137
            $this->std->trabalhador->nistrab,
138
            true
139
        );
140
        $this->dom->addChild(
141
            $trabalhador,
142
            "nmTrab",
143
            $this->std->trabalhador->nmtrab,
144
            true
145
        );
146
        $this->dom->addChild(
147
            $trabalhador,
148
            "sexo",
149
            $this->std->trabalhador->sexo,
150
            true
151
        );
152
        $this->dom->addChild(
153
            $trabalhador,
154
            "racaCor",
155
            $this->std->trabalhador->racacor,
156
            true
157
        );
158
        $this->dom->addChild(
159
            $trabalhador,
160
            "estCiv",
161
            !empty($this->std->trabalhador->estciv) ? $this->std->trabalhador->estciv : null,
162
            false
163
        );
164
        $this->dom->addChild(
165
            $trabalhador,
166
            "grauInstr",
167
            $this->std->trabalhador->grauinstr,
168
            true
169
        );
170
        $this->dom->addChild(
171
            $trabalhador,
172
            "indPriEmpr",
173
            $this->std->trabalhador->indpriempr,
174
            true
175
        );
176
        $this->dom->addChild(
177
            $trabalhador,
178
            "nmSoc",
179
            !empty($this->std->trabalhador->nmsoc) ? $this->std->trabalhador->nmsoc : null,
180
            false
181
        );
182
        //nascimento (obrigatorio)
183
        $nascimento = $this->dom->createElement("nascimento");
184
        $this->dom->addChild(
185
            $nascimento,
186
            "dtNascto",
187
            $this->std->trabalhador->dtnascto,
188
            true
189
        );
190
        $this->dom->addChild(
191
            $nascimento,
192
            "codMunic",
193
            !empty($this->std->trabalhador->codmunic) ? $this->std->trabalhador->codmunic : null,
194
            false
195
        );
196
        $this->dom->addChild(
197
            $nascimento,
198
            "uf",
199
            !empty($this->std->trabalhador->uf) ? $this->std->trabalhador->uf : null,
200
            false
201
        );
202
        $this->dom->addChild(
203
            $nascimento,
204
            "paisNascto",
205
            $this->std->trabalhador->paisnascto,
206
            true
207
        );
208
        $this->dom->addChild(
209
            $nascimento,
210
            "paisNac",
211
            $this->std->trabalhador->paisnac,
212
            true
213
        );
214
        $this->dom->addChild(
215
            $nascimento,
216
            "nmMae",
217
            !empty($this->std->trabalhador->nmmae) ? $this->std->trabalhador->nmmae : null,
218
            false
219
        );
220
        $this->dom->addChild(
221
            $nascimento,
222
            "nmPai",
223
            !empty($this->std->trabalhador->nmpai) ? $this->std->trabalhador->nmpai : null,
224
            false
225
        );
226
        //encerra nascimento
227
        $trabalhador->appendChild($nascimento);
228
229
230
//        documentos (obrig)
231
        $documentos = $this->dom->createElement("documentos");
232
        //CTPS (Opc)
233
        if (isset($this->std->ctps)) {
234
            $ctps = $this->dom->createElement("CTPS");
235
            $this->dom->addChild(
236
                $ctps,
237
                "nrCtps",
238
                $this->std->ctps->nrctps,
239
                true
240
            );
241
            $this->dom->addChild(
242
                $ctps,
243
                "serieCtps",
244
                $this->std->ctps->seriectps,
245
                true
246
            );
247
            $this->dom->addChild(
248
                $ctps,
249
                "ufCtps",
250
                $this->std->ctps->ufctps,
251
                true
252
            );
253
            $documentos->appendChild($ctps);
254
        }
255
//        //RIC (Opc)
256
        if (isset($this->std->ric)) {
257
            $ric = $this->dom->createElement("RIC");
258
            $this->dom->addChild(
259
                $ric,
260
                "nrRic",
261
                $this->std->ric->nrric,
262
                true
263
            );
264
            $this->dom->addChild(
265
                $ric,
266
                "orgaoEmissor",
267
                $this->std->ric->orgaoemissor,
268
                true
269
            );
270
            $this->dom->addChild(
271
                $ric,
272
                "dtExped",
273
                !empty($this->std->ric->dtexped) ? $this->std->ric->dtexped : null,
274
                false
275
            );
276
            $documentos->appendChild($ric);
277
        }
278
//        //RG
279
        if (isset($this->std->rg)) {
280
            $rg = $this->dom->createElement("RG");
281
            $this->dom->addChild(
282
                $rg,
283
                "nrRg",
284
                $this->std->rg->nrrg,
285
                true
286
            );
287
            $this->dom->addChild(
288
                $rg,
289
                "orgaoEmissor",
290
                $this->std->rg->orgaoemissor,
291
                true
292
            );
293
            $this->dom->addChild(
294
                $rg,
295
                "dtExped",
296
                !empty($this->std->rg->dtexped) ? $this->std->rg->dtexped : null,
297
                false
298
            );
299
            $documentos->appendChild($rg);
300
        }
301
//        //RNE (Opc)
302
        if (isset($this->std->rne)) {
303
            $rne = $this->dom->createElement("RNE");
304
            $this->dom->addChild(
305
                $rne,
306
                "nrRne",
307
                $this->std->rne->nrrne,
308
                true
309
            );
310
            $this->dom->addChild(
311
                $rne,
312
                "orgaoEmissor",
313
                $this->std->rne->orgaoemissor,
314
                true
315
            );
316
            $this->dom->addChild(
317
                $rne,
318
                "dtExped",
319
                !empty($this->std->rne->dtexped) ? $this->std->rne->dtexped : null,
320
                false
321
            );
322
            $this->dom->addChild(
323
                $rne,
324
                "dtValid",
325
                !empty($this->std->rne->dtvalid) ? $this->std->rne->dtvalid : null,
326
                false
327
            );
328
            $documentos->appendChild($rne);
329
        }
330
//        //OC (Opc)
331
        if (isset($this->std->oc)) {
332
            $oc = $this->dom->createElement("OC");
333
            $this->dom->addChild(
334
                $oc,
335
                "nrOc",
336
                $this->std->oc->nroc,
337
                true
338
            );
339
            $this->dom->addChild(
340
                $oc,
341
                "orgaoEmissor",
342
                $this->std->oc->orgaoemissor,
343
                true
344
            );
345
            $this->dom->addChild(
346
                $oc,
347
                "dtExped",
348
                !empty($this->std->oc->dtexped) ? $this->std->oc->dtexped : null,
349
                false
350
            );
351
352
            $this->dom->addChild(
353
                $oc,
354
                "dtValid",
355
                !empty($this->std->oc->dtvalid) ? $this->std->oc->dtvalid : null,
356
                false
357
            );
358
359
            $documentos->appendChild($oc);
360
        }
361
        //CNH (Ops)
362
        if (isset($this->std->cnh)) {
363
            $cnh = $this->dom->createElement("CNH");
364
            $this->dom->addChild(
365
                $cnh,
366
                "nrRegCnh",
367
                $this->std->cnh->nrregcnh,
368
                true
369
            );
370
            $this->dom->addChild(
371
                $cnh,
372
                "dtExped",
373
                !empty($this->std->cnh->dtExped) ? $this->std->cnh->dtExped : null,
374
                false
375
            );
376
            $this->dom->addChild(
377
                $cnh,
378
                "ufCnh",
379
                $this->std->cnh->ufcnh,
380
                true
381
            );
382
            $this->dom->addChild(
383
                $cnh,
384
                "dtValid",
385
                $this->std->cnh->dtvalid,
386
                true
387
            );
388
            $this->dom->addChild(
389
                $cnh,
390
                "dtPriHab",
391
                !empty($this->std->cnh->dtprihab) ? $this->std->cnh->dtprihab : null,
392
                false
393
            );
394
            $this->dom->addChild(
395
                $cnh,
396
                "categoriaCnh",
397
                $this->std->cnh->categoriacnh,
398
                true
399
            );
400
            $documentos->appendChild($cnh);
401
        }
402
        //encerra documentos
403
        $trabalhador->appendChild($documentos);
404
405
//        //Endereço (obrigatorio)
406
        $endereco = $this->dom->createElement("endereco");
407
        if (isset($this->std->endereco->brasil)) {
408
            $brasil = $this->dom->createElement("brasil");
409
            $this->dom->addChild(
410
                $brasil,
411
                "tpLograd",
412
                $this->std->endereco->brasil->tplograd,
413
                true
414
            );
415
            $this->dom->addChild(
416
                $brasil,
417
                "dscLograd",
418
                $this->std->endereco->brasil->dsclograd,
419
                true
420
            );
421
            $this->dom->addChild(
422
                $brasil,
423
                "nrLograd",
424
                $this->std->endereco->brasil->nrlograd,
425
                true
426
            );
427
            $this->dom->addChild(
428
                $brasil,
429
                "complemento",
430
                !empty($this->std->endereco->brasil->complemento) ? $this->std->endereco->brasil->complemento : null,
431
                false
432
            );
433
            $this->dom->addChild(
434
                $brasil,
435
                "bairro",
436
                !empty($this->std->endereco->brasil->bairro) ? $this->std->endereco->brasil->bairro : null,
437
                true
438
            );
439
            $this->dom->addChild(
440
                $brasil,
441
                "cep",
442
                $this->std->endereco->brasil->cep,
443
                true
444
            );
445
            $this->dom->addChild(
446
                $brasil,
447
                "codMunic",
448
                $this->std->endereco->brasil->codmunic,
449
                true
450
            );
451
            $this->dom->addChild(
452
                $brasil,
453
                "uf",
454
                $this->std->endereco->brasil->uf,
455
                true
456
            );
457
            $endereco->appendChild($brasil);
458
        }
459
        if (isset($this->std->endereco->exterior)) {
460
            $exterior = $this->dom->createElement("exterior");
461
            $this->dom->addChild(
462
                $exterior,
463
                "paisResid",
464
                $this->std->endereco->exterior->paisresid,
465
                true
466
            );
467
            $this->dom->addChild(
468
                $exterior,
469
                "dscLograd",
470
                $this->std->endereco->exterior->dsclograd,
471
                true
472
            );
473
            $this->dom->addChild(
474
                $exterior,
475
                "nrLograd",
476
                $this->std->endereco->exterior->nrlograd,
477
                true
478
            );
479
            $this->dom->addChild(
480
                $exterior,
481
                "complemento",
482
                !empty($this->std->endereco->exterior->complemento) ? $this->std->endereco->exterior->complemento : null,
483
                false
484
            );
485
            $this->dom->addChild(
486
                $exterior,
487
                "bairro",
488
                !empty($this->std->endereco->exterior->bairro) ? $this->std->endereco->exterior->bairro : null,
489
                false
490
            );
491
            $this->dom->addChild(
492
                $exterior,
493
                "nmCid",
494
                $this->std->endereco->exterior->nmCid,
495
                true
496
            );
497
            $this->dom->addChild(
498
                $exterior,
499
                "codPostal",
500
                !empty($this->std->endereco->exterior->codpostal) ? $this->std->endereco->exterior->codpostal : null,
501
                false
502
            );
503
            $endereco->appendChild($exterior);
504
        }
505
//        encerra endereço
506
        $trabalhador->appendChild($endereco);
507
508
        if (isset($this->std->trabestrangeiro)) {
509
            $trabEstrangeiro = $this->dom->createElement("trabEstrangeiro");
510
            $this->dom->addChild(
511
                $trabEstrangeiro,
512
                "dtChegada",
513
                $this->std->trabestrangeiro->dtchegada,
514
                true
515
            );
516
            $this->dom->addChild(
517
                $trabEstrangeiro,
518
                "classTrabEstrang",
519
                $this->std->trabestrangeiro->classtrabestrang,
520
                true
521
            );
522
            $this->dom->addChild(
523
                $trabEstrangeiro,
524
                "casadoBr",
525
                $this->std->trabestrangeiro->casadobr,
526
                true
527
            );
528
            $this->dom->addChild(
529
                $trabEstrangeiro,
530
                "filhosBr",
531
                $this->std->trabestrangeiro->filhosbr,
532
                true
533
            );
534
            $trabalhador->appendChild($trabEstrangeiro);
535
        }
536
537
        //deficiencia (opcional)
538
        if (isset($this->std->deficiencia)) {
539
            $deficiencia = $this->dom->createElement("infoDeficiencia");
540
            $this->dom->addChild(
541
                $deficiencia,
542
                "defFisica",
543
                $this->std->deficiencia->deffisica,
544
                true
545
            );
546
            $this->dom->addChild(
547
                $deficiencia,
548
                "defVisual",
549
                $this->std->deficiencia->defvisual,
550
                true
551
            );
552
            $this->dom->addChild(
553
                $deficiencia,
554
                "defAuditiva",
555
                $this->std->deficiencia->defauditiva,
556
                true
557
            );
558
            $this->dom->addChild(
559
                $deficiencia,
560
                "defMental",
561
                $this->std->deficiencia->defmental,
562
                true
563
            );
564
            $this->dom->addChild(
565
                $deficiencia,
566
                "defIntelectual",
567
                $this->std->deficiencia->defintelectual,
568
                true
569
            );
570
            $this->dom->addChild(
571
                $deficiencia,
572
                "reabReadap",
573
                $this->std->deficiencia->reabreadap,
574
                true
575
            );
576
577
            $this->dom->addChild(
578
                $deficiencia,
579
                "infoCota",
580
                $this->std->deficiencia->infocota,
581
                true
582
            );
583
            $this->dom->addChild(
584
                $deficiencia,
585
                "observacao",
586
                !empty($this->std->deficiencia->observacao) ? $this->std->deficiencia->observacao : null,
587
                false
588
            );
589
            $trabalhador->appendChild($deficiencia);
590
        }
591
        //dependente (opcional) (ARRAY)
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% 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...
592
        if (isset($this->std->dependente)) {
593
            foreach ($this->std->dependente as $dep) {
594
                $dependente = $this->dom->createElement("dependente");
595
                $this->dom->addChild(
596
                    $dependente,
597
                    "tpDep",
598
                    $dep->tpdep,
599
                    true
600
                );
601
                $this->dom->addChild(
602
                    $dependente,
603
                    "nmDep",
604
                    $dep->nmdep,
605
                    true
606
                );
607
                $this->dom->addChild(
608
                    $dependente,
609
                    "dtNascto",
610
                    $dep->dtnascto,
611
                    true
612
                );
613
                $this->dom->addChild(
614
                    $dependente,
615
                    "cpfDep",
616
                    !empty($dep->cpfdep) ? $dep->cpfdep : null,
617
                    false
618
                );
619
                $this->dom->addChild(
620
                    $dependente,
621
                    "depIRRF",
622
                    $dep->depirrf,
623
                    true
624
                );
625
                $this->dom->addChild(
626
                    $dependente,
627
                    "depSF",
628
                    $dep->depsf,
629
                    true
630
                );
631
                $this->dom->addChild(
632
                    $dependente,
633
                    "incTrab",
634
                    $dep->inctrab,
635
                    true
636
                );
637
                $trabalhador->appendChild($dependente);
638
            }
639
        }
640
641
        //aposentadoria (opcional)
642
        if (isset($this->std->aposentadoria)) {
643
            $aposentadoria = $this->dom->createElement("aposentadoria");
644
            $this->dom->addChild(
645
                $aposentadoria,
646
                "trabAposent",
647
                $this->std->aposentadoria->trabaposent,
648
                true
649
            );
650
            $trabalhador->appendChild($aposentadoria);
651
        }
652
653
        //contato (opcional)
654
        if (isset($this->std->contato)) {
655
            $contato = $this->dom->createElement("contato");
656
            $this->dom->addChild(
657
                $contato,
658
                "fonePrinc",
659
                !empty($this->std->contato->foneprinc) ? $this->std->contato->foneprinc : null,
660
                false
661
            );
662
            $this->dom->addChild(
663
                $contato,
664
                "foneAlternat",
665
                !empty($this->std->contato->fonealternat) ? $this->std->contato->fonealternat : null,
666
                false
667
            );
668
            $this->dom->addChild(
669
                $contato,
670
                "emailPrinc",
671
                !empty($this->std->contato->emailprinc) ? $this->std->contato->emailprinc : null,
672
                false
673
            );
674
            $this->dom->addChild(
675
                $contato,
676
                "emailAlternat",
677
                !empty($this->std->contato->emailalternat) ? $this->std->contato->emailalternat : null,
678
                false
679
            );
680
            $trabalhador->appendChild($contato);
681
        }
682
683
        //encerra trabalhador
684
        $evtAdmissao->appendChild($trabalhador);
685
686
        //vinculo (obrigatorio)
687
        $vinculo = $this->dom->createElement("vinculo");
688
        $this->dom->addChild(
689
            $vinculo,
690
            "matricula",
691
            $this->std->vinculo->matricula,
692
            true
693
        );
694
        $this->dom->addChild(
695
            $vinculo,
696
            "tpRegTrab",
697
            $this->std->vinculo->tpregtrab,
698
            true
699
        );
700
        $this->dom->addChild(
701
            $vinculo,
702
            "tpRegPrev",
703
            $this->std->vinculo->tpregprev,
704
            true
705
        );
706
        $this->dom->addChild(
707
            $vinculo,
708
            "nrRecInfPrelim",
709
            !empty($this->std->vinculo->nrrecinfprelim) ? $this->std->vinculo->nrrecinfprelim : null,
710
            false
711
        );
712
        $this->dom->addChild(
713
            $vinculo,
714
            "cadIni",
715
            $this->std->vinculo->cadini,
716
            true
717
        );
718
        //infoRegimeTrab (obrigatorio)
719
        $infoRegimeTrab = $this->dom->createElement("infoRegimeTrab");
720
721
        if (isset($this->std->vinculo->celetista)) {
722
            $celetista = $this->dom->createElement("infoCeletista");
723
            $this->dom->addChild(
724
                $celetista,
725
                "dtAdm",
726
                $this->std->vinculo->celetista->dtadm,
727
                true
728
            );
729
            $this->dom->addChild(
730
                $celetista,
731
                "tpAdmissao",
732
                $this->std->vinculo->celetista->tpadmissao,
733
                true
734
            );
735
            $this->dom->addChild(
736
                $celetista,
737
                "indAdmissao",
738
                $this->std->vinculo->celetista->indadmissao,
739
                true
740
            );
741
            $this->dom->addChild(
742
                $celetista,
743
                "tpRegJor",
744
                $this->std->vinculo->celetista->tpregjor,
745
                true
746
            );
747
            $this->dom->addChild(
748
                $celetista,
749
                "natAtividade",
750
                $this->std->vinculo->celetista->natatividade,
751
                true
752
            );
753
            $this->dom->addChild(
754
                $celetista,
755
                "dtBase",
756
                !empty($this->std->vinculo->celetista->dtbase) ? $this->std->vinculo->celetista->dtbase : null,
757
                false
758
            );
759
            $this->dom->addChild(
760
                $celetista,
761
                "cnpjSindCategProf",
762
                $this->std->vinculo->celetista->cnpjsindcategprof,
763
                true
764
            );
765
            //FGTS (obrigatorio)
766
            $fgts = $this->dom->createElement("FGTS");
767
            $this->dom->addChild(
768
                $fgts,
769
                "opcFGTS",
770
                $this->std->vinculo->celetista->opcfgts,
771
                true
772
            );
773
            $this->dom->addChild(
774
                $fgts,
775
                "dtOpcFGTS",
776
                !empty($this->std->vinculo->celetista->dtopcfgts) ? $this->std->vinculo->celetista->dtopcfgts : null,
777
                false
778
            );
779
            $celetista->appendChild($fgts);
780
781
            if (isset($this->std->vinculo->celetista->trabtemporario)) {
782
                $trabTemporario = $this->dom->createElement("trabTemporario");
783
                $this->dom->addChild(
784
                    $trabTemporario,
785
                    "hipLeg",
786
                    $this->std->vinculo->celetista->trabtemporario->hipleg,
787
                    true
788
                );
789
                $this->dom->addChild(
790
                    $trabTemporario,
791
                    "justContr",
792
                    $this->std->vinculo->celetista->trabtemporario->justcontr,
793
                    true
794
                );
795
                $this->dom->addChild(
796
                    $trabTemporario,
797
                    "tpInclContr",
798
                    $this->std->vinculo->celetista->trabtemporario->tpinclcontr,
799
                    true
800
                );
801
                //identificação do tomador (obrigatório)
802
                $ideTomadorServ = $this->dom->createElement("ideTomadorServ");
803
                $this->dom->addChild(
804
                    $ideTomadorServ,
805
                    "tpInsc",
806
                    $this->std->vinculo->celetista->trabtemporario->tomador->tpinsc,
807
                    true
808
                );
809
                $this->dom->addChild(
810
                    $ideTomadorServ,
811
                    "nrInsc",
812
                    $this->std->vinculo->celetista->trabtemporario->tomador->nrinsc,
813
                    true
814
                );
815
                $trabTemporario->appendChild($ideTomadorServ);
816
817
                //identificaçã o estabelecimento (opcional)
818
                if (isset($this->std->vinculo->celetista->trabTemporario->estab)) {
819
                    $ideEstabVinc = $this->dom->createElement("ideEstabVinc");
820
                    $this->dom->addChild(
821
                        $ideEstabVinc,
822
                        "tpInsc",
823
                        $this->std->vinculo->celetista->trabtemporario->estabvinc->tpinsc,
824
                        true
825
                    );
826
                    $this->dom->addChild(
827
                        $ideEstabVinc,
828
                        "nrInsc",
829
                        $this->std->vinculo->celetista->trabtemporario->estabvinc->nrinsc,
830
                        true
831
                    );
832
                    $trabTemporario->appendChild($ideEstabVinc);
833
                }
834
835
                //substituido (opcional) ARRAY
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% 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...
836
                if (isset($this->std->vinculo->celetista->trabTemporario->substituido)) {
837
                    foreach ($this->std->vinculo->celetista->trabTemporario->substituido as $subs) {
838
                        $ideTrabSubstituido = $this->dom->createElement("ideTrabSubstituido");
839
                        $this->dom->addChild(
840
                            $ideEstabVinc,
841
                            "cpfTrabSubst",
842
                            $subs->cpftrabsubst,
843
                            true
844
                        );
845
                        $trabTemporario->appendChild($ideTrabSubstituido);
846
                    }
847
                }
848
                //encerra trabTemporario
849
                $celetista->appendChild($trabTemporario);
850
            }
851
            //aprendiz (opcional)
852
            if (isset($this->std->vinculo->celetista->aprendiz)) {
853
                $aprendiz = $this->dom->createElement("aprend");
854
                $this->dom->addChild(
855
                    $aprendiz,
856
                    "tpInsc",
857
                    $this->std->vinculo->celetista->aprendiz->tpinsc,
858
                    true
859
                );
860
                $this->dom->addChild(
861
                    $aprendiz,
862
                    "nrInsc",
863
                    $this->std->vinculo->celetista->aprendiz->nrinsc,
864
                    true
865
                );
866
                $celetista->appendChild($aprendiz);
867
            }
868
            //encerra celetista
869
            $infoRegimeTrab->appendChild($celetista);
870
        }
871
        $vinculo->appendChild($infoRegimeTrab);
872
        if (isset($this->std->vinculo->estatutario)) {
873
            $estatutario = $this->dom->createElement("infoEstatutario");
874
            $this->dom->addChild(
875
                $estatutario,
876
                "indProvim",
877
                $this->std->vinculo->estatutario->indprovim,
878
                true
879
            );
880
            $this->dom->addChild(
881
                $estatutario,
882
                "tpProv",
883
                $this->std->vinculo->estatutario->tpprov,
884
                true
885
            );
886
            $this->dom->addChild(
887
                $estatutario,
888
                "dtNomeacao",
889
                $this->std->vinculo->estatutario->dtnomeacao,
890
                true
891
            );
892
            $this->dom->addChild(
893
                $estatutario,
894
                "dtPosse",
895
                $this->std->vinculo->estatutario->dtposse,
896
                true
897
            );
898
            $this->dom->addChild(
899
                $estatutario,
900
                "dtExercicio",
901
                $this->std->vinculo->estatutario->dtexercicio,
902
                true
903
            );
904
            $this->dom->addChild(
905
                $estatutario,
906
                "tpPlanRP",
907
                !empty($this->std->vinculo->estatutario->tpplanrp) ? $this->std->vinculo->estatutario->tpplanrp : null,
908
                false
909
            );
910
            //infoDecJud (opcional)
911
            if (isset($this->std->vinculo->estatutario->judicial)) {
912
                $infoDecJud = $this->dom->createElement("infoDecJud");
913
                $this->dom->addChild(
914
                    $infoDecJud,
915
                    "nrProcJud",
916
                    $this->std->vinculo->estatutario->judicial->nrprocjud,
917
                    true
918
                );
919
                $estatutario->appendChild($infoDecJud);
920
            }
921
            //encerra estatutario
922
            $infoRegimeTrab->appendChild($estatutario);
923
        }
924
925
        //infoContrato (obrigatorio)
926
        $contrato = $this->dom->createElement("infoContrato");
927
        $this->dom->addChild(
928
            $contrato,
929
            "codCargo",
930
            !empty($this->std->vinculo->contrato->codcargo) ? $this->std->vinculo->contrato->codcargo : null,
931
            false
932
        );
933
        $this->dom->addChild(
934
            $contrato,
935
            "codFuncao",
936
            !empty($this->std->vinculo->contrato->codfuncao) ? $this->std->vinculo->contrato->codfuncao : null,
937
            false
938
        );
939
        $this->dom->addChild(
940
            $contrato,
941
            "codCateg",
942
            $this->std->vinculo->contrato->codcateg,
943
            true
944
        );
945
        $this->dom->addChild(
946
            $contrato,
947
            "codCarreira",
948
            !empty($this->std->vinculo->contrato->codcarreira) ? $this->std->vinculo->contrato->codcarreira : null,
949
            false
950
        );
951
        $this->dom->addChild(
952
            $contrato,
953
            "dtIngrCarr",
954
            !empty($this->std->vinculo->contrato->dtingrcarr) ? $this->std->vinculo->contrato->dtingrcarr : null,
955
            false
956
        );
957
        //remuneracao (obrigatorio)
958
        $remuneracao = $this->dom->createElement("remuneracao");
959
        $this->dom->addChild(
960
            $remuneracao,
961
            "vrSalFx",
962
            $this->std->vinculo->contrato->vrsalfx,
963
            true
964
        );
965
        $this->dom->addChild(
966
            $remuneracao,
967
            "undSalFixo",
968
            $this->std->vinculo->contrato->undsalfixo,
969
            true
970
        );
971
        $this->dom->addChild(
972
            $remuneracao,
973
            "dscSalVar",
974
            !empty($this->std->vinculo->contrato->dscsalvar) ? $this->std->vinculo->contrato->dscsalvar : null,
975
            false
976
        );
977
        $contrato->appendChild($remuneracao);
978
979
        //duracao (obrigatorio)
980
        $duracao = $this->dom->createElement("duracao");
981
        $this->dom->addChild(
982
            $duracao,
983
            "tpContr",
984
            $this->std->vinculo->contrato->tpcontr,
985
            true
986
        );
987
        $this->dom->addChild(
988
            $duracao,
989
            "dtTerm",
990
            !empty($this->std->vinculo->contrato->dtterm) ? $this->std->vinculo->contrato->dtterm : null,
991
            false
992
        );
993
        $this->dom->addChild(
994
            $duracao,
995
            "clauAsseg",
996
            !empty($this->std->vinculo->contrato->clauasseg) ? $this->std->vinculo->contrato->clauasseg : null,
997
            false
998
        );
999
        $contrato->appendChild($duracao);
1000
//
1001
        //localTrabalho (obrigatorio)
1002
        $localTrabalho = $this->dom->createElement("localTrabalho");
1003
        //localTrabGeral (opcional)
1004
        if (isset($this->std->vinculo->contrato->local)) {
1005
            $localgeral = $this->dom->createElement("localTrabGeral");
1006
            $this->dom->addChild(
1007
                $localgeral,
1008
                "tpInsc",
1009
                $this->std->vinculo->contrato->local->tpinsc,
1010
                true
1011
            );
1012
            $this->dom->addChild(
1013
                $localgeral,
1014
                "nrInsc",
1015
                $this->std->vinculo->contrato->local->nrinsc,
1016
                true
1017
            );
1018
            $this->dom->addChild(
1019
                $localgeral,
1020
                "descComp",
1021
                !empty($this->std->vinculo->contrato->local->desccomp) ? $this->std->vinculo->contrato->local->desccomp : null,
1022
                false
1023
            );
1024
            $localTrabalho->appendChild($localgeral);
1025
        }
1026
        //localTrabDom (opcional)
1027
        if (isset($this->std->vinculo->contrato->domestico)) {
1028
            $localDomestico = $this->dom->createElement("localTrabDom");
1029
            $this->dom->addChild(
1030
                $localDomestico,
1031
                "tpLograd",
1032
                $this->std->vinculo->contrato->domestico->tplograd,
1033
                true
1034
            );
1035
            $this->dom->addChild(
1036
                $localDomestico,
1037
                "dscLograd",
1038
                $this->std->vinculo->contrato->domestico->dsclograd,
1039
                true
1040
            );
1041
            $this->dom->addChild(
1042
                $localDomestico,
1043
                "nrLograd",
1044
                $this->std->vinculo->contrato->domestico->nrlograd,
1045
                true
1046
            );
1047
            $this->dom->addChild(
1048
                $localDomestico,
1049
                "complemento",
1050
                !empty($this->std->vinculo->contrato->domestico->complemento) ? $this->std->vinculo->contrato->domestico->complemento : null,
1051
                false
1052
            );
1053
            $this->dom->addChild(
1054
                $localDomestico,
1055
                "bairro",
1056
                !empty($this->std->vinculo->contrato->domestico->bairro) ? $this->std->vinculo->contrato->domestico->bairro : null,
1057
                false
1058
            );
1059
            $this->dom->addChild(
1060
                $localDomestico,
1061
                "cep",
1062
                $this->std->vinculo->contrato->domestico->cep,
1063
                true
1064
            );
1065
            $this->dom->addChild(
1066
                $localDomestico,
1067
                "codMunic",
1068
                $this->std->vinculo->contrato->domestico->codmunic,
1069
                true
1070
            );
1071
            $this->dom->addChild(
1072
                $localDomestico,
1073
                "uf",
1074
                $this->std->vinculo->contrato->domestico->uf,
1075
                true
1076
            );
1077
            $localTrabalho->appendChild($localDomestico);
1078
        }
1079
        $contrato->appendChild($localTrabalho);
1080
1081
        //horContratual (opcional)
1082
        if (isset($this->std->vinculo->contrato->horcontatual)) {
1083
            $horContratual = $this->dom->createElement("horContratual");
1084
            $this->dom->addChild(
1085
                $horContratual,
1086
                "qtdHrsSem",
1087
                $this->std->vinculo->contrato->horcontratual->qtdhrssem,
1088
                true
1089
            );
1090
            $this->dom->addChild(
1091
                $horContratual,
1092
                "tpJornada",
1093
                $this->std->vinculo->contrato->horcontratual->tpjornada,
1094
                true
1095
            );
1096
            $this->dom->addChild(
1097
                $horContratual,
1098
                "dscTpJorn",
1099
                !empty($this->std->vinculo->contrato->horcontratual->dsctpjorn) ? $this->std->vinculo->contrato->horcontratual->dsctpjorn : null,
1100
                false
1101
            );
1102
            $this->dom->addChild(
1103
                $horContratual,
1104
                "tmpParc",
1105
                $this->std->vinculo->contrato->horcontratual->tmpparc,
1106
                true
1107
            );
1108
            //horario (opcional) ARRAY
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% 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...
1109
            if (isset($this->std->vinculo->contrato->horcontratual->horario)) {
1110
                foreach ($this->std->vinculo->contrato->horcontratual->horario as $hr) {
1111
                    $horario = $this->dom->createElement("horario");
1112
                    $this->dom->addChild(
1113
                        $horario,
1114
                        "dia",
1115
                        $hr->dia,
1116
                        true
1117
                    );
1118
                    $this->dom->addChild(
1119
                        $horario,
1120
                        "codHorContrat",
1121
                        $hr->codhorcontrat,
1122
                        true
1123
                    );
1124
                    $horContratual->appendChild($horario);
1125
                }
1126
            }
1127
            //encerra horContratual
1128
            $contrato->appendChild($horContratual);
1129
        }
1130
1131
        //filiacaoSindical (opcional) ARRAY
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% 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...
1132
        if (isset($this->std->vinculo->contrato->filiacaosindical)) {
1133
            foreach ($this->std->vinculo->contrato->filiacaosindical as $sind) {
1134
                $filiacaoSindical = $this->dom->createElement("filiacaoSindical");
1135
                $this->dom->addChild(
1136
                    $horario,
1137
                    "cnpjSindTrab",
1138
                    $sind->cnpjsindtrab,
1139
                    true
1140
                );
1141
                $contrato->appendChild($filiacaoSindical);
1142
            }
1143
        }
1144
        //alvaraJudicial (opcional)
1145
        if (isset($this->std->vinculo->contrato->judicial)) {
1146
            $alvaraJudicial = $this->dom->createElement("alvaraJudicial");
1147
            $this->dom->addChild(
1148
                $alvaraJudicial,
1149
                "nrProcJud",
1150
                $this->std->vinculo->contrato->judicial->nrprocjud,
1151
                true
1152
            );
1153
            $contrato->appendChild($alvaraJudicial);
1154
        }
1155
        //encerra contrato
1156
        $vinculo->appendChild($contrato);
1157
1158
        //sucessaoVinc (opcional)
1159
        if (isset($this->std->vinculo->sucessao)) {
1160
            $sucessaoVinc = $this->dom->createElement("sucessaoVinc");
1161
            $this->dom->addChild(
1162
                $sucessaoVinc,
1163
                "cnpjEmpregAnt",
1164
                $this->std->vinculo->sucessao->cnpjempregant,
1165
                true
1166
            );
1167
            $this->dom->addChild(
1168
                $sucessaoVinc,
1169
                "matricAnt",
1170
                !empty($this->std->vinculo->sucessao->matricant) ? $this->std->vinculo->sucessao->matricant : null,
1171
                false
1172
            );
1173
            $this->dom->addChild(
1174
                $sucessaoVinc,
1175
                "dtIniVinculo",
1176
                $this->std->vinculo->sucessao->dtinivinculo,
1177
                true
1178
            );
1179
            $this->dom->addChild(
1180
                $sucessaoVinc,
1181
                "observacao",
1182
                !empty($this->std->vinculo->sucessao->observacao) ? $this->std->vinculo->sucessao->observacao : null,
1183
                false
1184
            );
1185
            $vinculo->appendChild($sucessaoVinc);
1186
        }
1187
        //afastamento (opcional)
1188
        if (isset($this->std->vinculo->afastamento)) {
1189
            $afastamento = $this->dom->createElement("afastamento");
1190
            $this->dom->addChild(
1191
                $afastamento,
1192
                "dtIniAfast",
1193
                $this->std->vinculo->afastamento->dtiniafast,
1194
                true
1195
            );
1196
            $this->dom->addChild(
1197
                $afastamento,
1198
                "codMotAfast",
1199
                $this->std->vinculo->afastamento->codmotafast,
1200
                true
1201
            );
1202
1203
            $vinculo->appendChild($afastamento);
1204
        }
1205
1206
        //desligamento (opcional)
1207
        if (isset($this->std->vinculo->desligamento)) {
1208
            $desligamento = $this->dom->createElement("desligamento");
1209
            $this->dom->addChild(
1210
                $desligamento,
1211
                "dtDeslig",
1212
                $this->std->vinculo->desligamento->dtdeslig,
1213
                true
1214
            );
1215
1216
            $vinculo->appendChild($desligamento);
1217
        }
1218
1219
        //encerra vinculo
1220
        $this->node->appendChild($vinculo);
1221
        //finalização do xml
1222
1223
        $evtAdmissao->appendChild($vinculo);
1224
1225
        $eSocial->appendChild($evtAdmissao);
1226
        $this->sign($eSocial);
0 ignored issues
show
Unused Code introduced by
The call to EvtAdmissao::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...
1227
    }
1228
}
1229