Completed
Pull Request — master (#97)
by
unknown
02:26
created

EvtAdmissao::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 7
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 3
crap 2
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) ?
483
                    $this->std->endereco->exterior->complemento : null,
484
                false
485
            );
486
            $this->dom->addChild(
487
                $exterior,
488
                "bairro",
489
                !empty($this->std->endereco->exterior->bairro) ? $this->std->endereco->exterior->bairro : null,
490
                false
491
            );
492
            $this->dom->addChild(
493
                $exterior,
494
                "nmCid",
495
                $this->std->endereco->exterior->nmCid,
496
                true
497
            );
498
            $this->dom->addChild(
499
                $exterior,
500
                "codPostal",
501
                !empty($this->std->endereco->exterior->codpostal) ? $this->std->endereco->exterior->codpostal : null,
502
                false
503
            );
504
            $endereco->appendChild($exterior);
505
        }
506
        //        encerra endereço
507
        $trabalhador->appendChild($endereco);
508
509
        if (isset($this->std->trabestrangeiro)) {
510
            $trabEstrangeiro = $this->dom->createElement("trabEstrangeiro");
511
            $this->dom->addChild(
512
                $trabEstrangeiro,
513
                "dtChegada",
514
                $this->std->trabestrangeiro->dtchegada,
515
                true
516
            );
517
            $this->dom->addChild(
518
                $trabEstrangeiro,
519
                "classTrabEstrang",
520
                $this->std->trabestrangeiro->classtrabestrang,
521
                true
522
            );
523
            $this->dom->addChild(
524
                $trabEstrangeiro,
525
                "casadoBr",
526
                $this->std->trabestrangeiro->casadobr,
527
                true
528
            );
529
            $this->dom->addChild(
530
                $trabEstrangeiro,
531
                "filhosBr",
532
                $this->std->trabestrangeiro->filhosbr,
533
                true
534
            );
535
            $trabalhador->appendChild($trabEstrangeiro);
536
        }
537
538
        //deficiencia (opcional)
539
        if (isset($this->std->deficiencia)) {
540
            $deficiencia = $this->dom->createElement("infoDeficiencia");
541
            $this->dom->addChild(
542
                $deficiencia,
543
                "defFisica",
544
                $this->std->deficiencia->deffisica,
545
                true
546
            );
547
            $this->dom->addChild(
548
                $deficiencia,
549
                "defVisual",
550
                $this->std->deficiencia->defvisual,
551
                true
552
            );
553
            $this->dom->addChild(
554
                $deficiencia,
555
                "defAuditiva",
556
                $this->std->deficiencia->defauditiva,
557
                true
558
            );
559
            $this->dom->addChild(
560
                $deficiencia,
561
                "defMental",
562
                $this->std->deficiencia->defmental,
563
                true
564
            );
565
            $this->dom->addChild(
566
                $deficiencia,
567
                "defIntelectual",
568
                $this->std->deficiencia->defintelectual,
569
                true
570
            );
571
            $this->dom->addChild(
572
                $deficiencia,
573
                "reabReadap",
574
                $this->std->deficiencia->reabreadap,
575
                true
576
            );
577
578
            $this->dom->addChild(
579
                $deficiencia,
580
                "infoCota",
581
                $this->std->deficiencia->infocota,
582
                true
583
            );
584
            $this->dom->addChild(
585
                $deficiencia,
586
                "observacao",
587
                !empty($this->std->deficiencia->observacao) ? $this->std->deficiencia->observacao : null,
588
                false
589
            );
590
            $trabalhador->appendChild($deficiencia);
591
        }
592
        //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...
593
        if (isset($this->std->dependente)) {
594
            foreach ($this->std->dependente as $dep) {
595
                $dependente = $this->dom->createElement("dependente");
596
                $this->dom->addChild(
597
                    $dependente,
598
                    "tpDep",
599
                    $dep->tpdep,
600
                    true
601
                );
602
                $this->dom->addChild(
603
                    $dependente,
604
                    "nmDep",
605
                    $dep->nmdep,
606
                    true
607
                );
608
                $this->dom->addChild(
609
                    $dependente,
610
                    "dtNascto",
611
                    $dep->dtnascto,
612
                    true
613
                );
614
                $this->dom->addChild(
615
                    $dependente,
616
                    "cpfDep",
617
                    !empty($dep->cpfdep) ? $dep->cpfdep : null,
618
                    false
619
                );
620
                $this->dom->addChild(
621
                    $dependente,
622
                    "depIRRF",
623
                    $dep->depirrf,
624
                    true
625
                );
626
                $this->dom->addChild(
627
                    $dependente,
628
                    "depSF",
629
                    $dep->depsf,
630
                    true
631
                );
632
                $this->dom->addChild(
633
                    $dependente,
634
                    "incTrab",
635
                    $dep->inctrab,
636
                    true
637
                );
638
                $trabalhador->appendChild($dependente);
639
            }
640
        }
641
642
        //aposentadoria (opcional)
643
        if (isset($this->std->aposentadoria)) {
644
            $aposentadoria = $this->dom->createElement("aposentadoria");
645
            $this->dom->addChild(
646
                $aposentadoria,
647
                "trabAposent",
648
                $this->std->aposentadoria->trabaposent,
649
                true
650
            );
651
            $trabalhador->appendChild($aposentadoria);
652
        }
653
654
        //contato (opcional)
655
        if (isset($this->std->contato)) {
656
            $contato = $this->dom->createElement("contato");
657
            $this->dom->addChild(
658
                $contato,
659
                "fonePrinc",
660
                !empty($this->std->contato->foneprinc) ? $this->std->contato->foneprinc : null,
661
                false
662
            );
663
            $this->dom->addChild(
664
                $contato,
665
                "foneAlternat",
666
                !empty($this->std->contato->fonealternat) ? $this->std->contato->fonealternat : null,
667
                false
668
            );
669
            $this->dom->addChild(
670
                $contato,
671
                "emailPrinc",
672
                !empty($this->std->contato->emailprinc) ? $this->std->contato->emailprinc : null,
673
                false
674
            );
675
            $this->dom->addChild(
676
                $contato,
677
                "emailAlternat",
678
                !empty($this->std->contato->emailalternat) ? $this->std->contato->emailalternat : null,
679
                false
680
            );
681
            $trabalhador->appendChild($contato);
682
        }
683
684
        //encerra trabalhador
685
        $evtAdmissao->appendChild($trabalhador);
686
687
        //vinculo (obrigatorio)
688
        $vinculo = $this->dom->createElement("vinculo");
689
        $this->dom->addChild(
690
            $vinculo,
691
            "matricula",
692
            $this->std->vinculo->matricula,
693
            true
694
        );
695
        $this->dom->addChild(
696
            $vinculo,
697
            "tpRegTrab",
698
            $this->std->vinculo->tpregtrab,
699
            true
700
        );
701
        $this->dom->addChild(
702
            $vinculo,
703
            "tpRegPrev",
704
            $this->std->vinculo->tpregprev,
705
            true
706
        );
707
        $this->dom->addChild(
708
            $vinculo,
709
            "nrRecInfPrelim",
710
            !empty($this->std->vinculo->nrrecinfprelim) ? $this->std->vinculo->nrrecinfprelim : null,
711
            false
712
        );
713
        $this->dom->addChild(
714
            $vinculo,
715
            "cadIni",
716
            $this->std->vinculo->cadini,
717
            true
718
        );
719
        //infoRegimeTrab (obrigatorio)
720
        $infoRegimeTrab = $this->dom->createElement("infoRegimeTrab");
721
722
        if (isset($this->std->vinculo->celetista)) {
723
            $celetista = $this->dom->createElement("infoCeletista");
724
            $this->dom->addChild(
725
                $celetista,
726
                "dtAdm",
727
                $this->std->vinculo->celetista->dtadm,
728
                true
729
            );
730
            $this->dom->addChild(
731
                $celetista,
732
                "tpAdmissao",
733
                $this->std->vinculo->celetista->tpadmissao,
734
                true
735
            );
736
            $this->dom->addChild(
737
                $celetista,
738
                "indAdmissao",
739
                $this->std->vinculo->celetista->indadmissao,
740
                true
741
            );
742
            $this->dom->addChild(
743
                $celetista,
744
                "tpRegJor",
745
                $this->std->vinculo->celetista->tpregjor,
746
                true
747
            );
748
            $this->dom->addChild(
749
                $celetista,
750
                "natAtividade",
751
                $this->std->vinculo->celetista->natatividade,
752
                true
753
            );
754
            $this->dom->addChild(
755
                $celetista,
756
                "dtBase",
757
                !empty($this->std->vinculo->celetista->dtbase) ? $this->std->vinculo->celetista->dtbase : null,
758
                false
759
            );
760
            $this->dom->addChild(
761
                $celetista,
762
                "cnpjSindCategProf",
763
                $this->std->vinculo->celetista->cnpjsindcategprof,
764
                true
765
            );
766
            //FGTS (obrigatorio)
767
            $fgts = $this->dom->createElement("FGTS");
768
            $this->dom->addChild(
769
                $fgts,
770
                "opcFGTS",
771
                $this->std->vinculo->celetista->opcfgts,
772
                true
773
            );
774
            $this->dom->addChild(
775
                $fgts,
776
                "dtOpcFGTS",
777
                !empty($this->std->vinculo->celetista->dtopcfgts) ? $this->std->vinculo->celetista->dtopcfgts : null,
778
                false
779
            );
780
            $celetista->appendChild($fgts);
781
782
            if (isset($this->std->vinculo->celetista->trabtemporario)) {
783
                $trabTemporario = $this->dom->createElement("trabTemporario");
784
                $this->dom->addChild(
785
                    $trabTemporario,
786
                    "hipLeg",
787
                    $this->std->vinculo->celetista->trabtemporario->hipleg,
788
                    true
789
                );
790
                $this->dom->addChild(
791
                    $trabTemporario,
792
                    "justContr",
793
                    $this->std->vinculo->celetista->trabtemporario->justcontr,
794
                    true
795
                );
796
                $this->dom->addChild(
797
                    $trabTemporario,
798
                    "tpInclContr",
799
                    $this->std->vinculo->celetista->trabtemporario->tpinclcontr,
800
                    true
801
                );
802
                //identificação do tomador (obrigatório)
803
                $ideTomadorServ = $this->dom->createElement("ideTomadorServ");
804
                $this->dom->addChild(
805
                    $ideTomadorServ,
806
                    "tpInsc",
807
                    $this->std->vinculo->celetista->trabtemporario->tomador->tpinsc,
808
                    true
809
                );
810
                $this->dom->addChild(
811
                    $ideTomadorServ,
812
                    "nrInsc",
813
                    $this->std->vinculo->celetista->trabtemporario->tomador->nrinsc,
814
                    true
815
                );
816
                $trabTemporario->appendChild($ideTomadorServ);
817
818
                //identificaçã o estabelecimento (opcional)
819
                if (isset($this->std->vinculo->celetista->trabTemporario->estab)) {
820
                    $ideEstabVinc = $this->dom->createElement("ideEstabVinc");
821
                    $this->dom->addChild(
822
                        $ideEstabVinc,
823
                        "tpInsc",
824
                        $this->std->vinculo->celetista->trabtemporario->estabvinc->tpinsc,
825
                        true
826
                    );
827
                    $this->dom->addChild(
828
                        $ideEstabVinc,
829
                        "nrInsc",
830
                        $this->std->vinculo->celetista->trabtemporario->estabvinc->nrinsc,
831
                        true
832
                    );
833
                    $trabTemporario->appendChild($ideEstabVinc);
834
                }
835
836
                //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...
837
                if (isset($this->std->vinculo->celetista->trabTemporario->substituido)) {
838
                    foreach ($this->std->vinculo->celetista->trabTemporario->substituido as $subs) {
839
                        $ideTrabSubstituido = $this->dom->createElement("ideTrabSubstituido");
840
                        $this->dom->addChild(
841
                            $ideEstabVinc,
842
                            "cpfTrabSubst",
843
                            $subs->cpftrabsubst,
844
                            true
845
                        );
846
                        $trabTemporario->appendChild($ideTrabSubstituido);
847
                    }
848
                }
849
                //encerra trabTemporario
850
                $celetista->appendChild($trabTemporario);
851
            }
852
            //aprendiz (opcional)
853
            if (isset($this->std->vinculo->celetista->aprendiz)) {
854
                $aprendiz = $this->dom->createElement("aprend");
855
                $this->dom->addChild(
856
                    $aprendiz,
857
                    "tpInsc",
858
                    $this->std->vinculo->celetista->aprendiz->tpinsc,
859
                    true
860
                );
861
                $this->dom->addChild(
862
                    $aprendiz,
863
                    "nrInsc",
864
                    $this->std->vinculo->celetista->aprendiz->nrinsc,
865
                    true
866
                );
867
                $celetista->appendChild($aprendiz);
868
            }
869
            //encerra celetista
870
            $infoRegimeTrab->appendChild($celetista);
871
        }
872
        $vinculo->appendChild($infoRegimeTrab);
873
        if (isset($this->std->vinculo->estatutario)) {
874
            $estatutario = $this->dom->createElement("infoEstatutario");
875
            $this->dom->addChild(
876
                $estatutario,
877
                "indProvim",
878
                $this->std->vinculo->estatutario->indprovim,
879
                true
880
            );
881
            $this->dom->addChild(
882
                $estatutario,
883
                "tpProv",
884
                $this->std->vinculo->estatutario->tpprov,
885
                true
886
            );
887
            $this->dom->addChild(
888
                $estatutario,
889
                "dtNomeacao",
890
                $this->std->vinculo->estatutario->dtnomeacao,
891
                true
892
            );
893
            $this->dom->addChild(
894
                $estatutario,
895
                "dtPosse",
896
                $this->std->vinculo->estatutario->dtposse,
897
                true
898
            );
899
            $this->dom->addChild(
900
                $estatutario,
901
                "dtExercicio",
902
                $this->std->vinculo->estatutario->dtexercicio,
903
                true
904
            );
905
            $this->dom->addChild(
906
                $estatutario,
907
                "tpPlanRP",
908
                !empty($this->std->vinculo->estatutario->tpplanrp) ? $this->std->vinculo->estatutario->tpplanrp : null,
909
                false
910
            );
911
            //infoDecJud (opcional)
912
            if (isset($this->std->vinculo->estatutario->judicial)) {
913
                $infoDecJud = $this->dom->createElement("infoDecJud");
914
                $this->dom->addChild(
915
                    $infoDecJud,
916
                    "nrProcJud",
917
                    $this->std->vinculo->estatutario->judicial->nrprocjud,
918
                    true
919
                );
920
                $estatutario->appendChild($infoDecJud);
921
            }
922
            //encerra estatutario
923
            $infoRegimeTrab->appendChild($estatutario);
924
        }
925
926
        //infoContrato (obrigatorio)
927
        $contrato = $this->dom->createElement("infoContrato");
928
        $this->dom->addChild(
929
            $contrato,
930
            "codCargo",
931
            !empty($this->std->vinculo->contrato->codcargo) ? $this->std->vinculo->contrato->codcargo : null,
932
            false
933
        );
934
        $this->dom->addChild(
935
            $contrato,
936
            "codFuncao",
937
            !empty($this->std->vinculo->contrato->codfuncao) ? $this->std->vinculo->contrato->codfuncao : null,
938
            false
939
        );
940
        $this->dom->addChild(
941
            $contrato,
942
            "codCateg",
943
            $this->std->vinculo->contrato->codcateg,
944
            true
945
        );
946
        $this->dom->addChild(
947
            $contrato,
948
            "codCarreira",
949
            !empty($this->std->vinculo->contrato->codcarreira) ? $this->std->vinculo->contrato->codcarreira : null,
950
            false
951
        );
952
        $this->dom->addChild(
953
            $contrato,
954
            "dtIngrCarr",
955
            !empty($this->std->vinculo->contrato->dtingrcarr) ? $this->std->vinculo->contrato->dtingrcarr : null,
956
            false
957
        );
958
        //remuneracao (obrigatorio)
959
        $remuneracao = $this->dom->createElement("remuneracao");
960
        $this->dom->addChild(
961
            $remuneracao,
962
            "vrSalFx",
963
            $this->std->vinculo->contrato->vrsalfx,
964
            true
965
        );
966
        $this->dom->addChild(
967
            $remuneracao,
968
            "undSalFixo",
969
            $this->std->vinculo->contrato->undsalfixo,
970
            true
971
        );
972
        $this->dom->addChild(
973
            $remuneracao,
974
            "dscSalVar",
975
            !empty($this->std->vinculo->contrato->dscsalvar) ? $this->std->vinculo->contrato->dscsalvar : null,
976
            false
977
        );
978
        $contrato->appendChild($remuneracao);
979
980
        //duracao (obrigatorio)
981
        $duracao = $this->dom->createElement("duracao");
982
        $this->dom->addChild(
983
            $duracao,
984
            "tpContr",
985
            $this->std->vinculo->contrato->tpcontr,
986
            true
987
        );
988
        $this->dom->addChild(
989
            $duracao,
990
            "dtTerm",
991
            !empty($this->std->vinculo->contrato->dtterm) ? $this->std->vinculo->contrato->dtterm : null,
992
            false
993
        );
994
        $this->dom->addChild(
995
            $duracao,
996
            "clauAsseg",
997
            !empty($this->std->vinculo->contrato->clauasseg) ? $this->std->vinculo->contrato->clauasseg : null,
998
            false
999
        );
1000
        $contrato->appendChild($duracao);
1001
        //
1002
        //localTrabalho (obrigatorio)
1003
        $localTrabalho = $this->dom->createElement("localTrabalho");
1004
        //localTrabGeral (opcional)
1005
        if (isset($this->std->vinculo->contrato->local)) {
1006
            $localgeral = $this->dom->createElement("localTrabGeral");
1007
            $this->dom->addChild(
1008
                $localgeral,
1009
                "tpInsc",
1010
                $this->std->vinculo->contrato->local->tpinsc,
1011
                true
1012
            );
1013
            $this->dom->addChild(
1014
                $localgeral,
1015
                "nrInsc",
1016
                $this->std->vinculo->contrato->local->nrinsc,
1017
                true
1018
            );
1019
            $this->dom->addChild(
1020
                $localgeral,
1021
                "descComp",
1022
                !empty($this->std->vinculo->contrato->local->desccomp) ?
1023
                    $this->std->vinculo->contrato->local->desccomp : null,
1024
                false
1025
            );
1026
            $localTrabalho->appendChild($localgeral);
1027
        }
1028
        //localTrabDom (opcional)
1029
        if (isset($this->std->vinculo->contrato->domestico)) {
1030
            $localDomestico = $this->dom->createElement("localTrabDom");
1031
            $this->dom->addChild(
1032
                $localDomestico,
1033
                "tpLograd",
1034
                $this->std->vinculo->contrato->domestico->tplograd,
1035
                true
1036
            );
1037
            $this->dom->addChild(
1038
                $localDomestico,
1039
                "dscLograd",
1040
                $this->std->vinculo->contrato->domestico->dsclograd,
1041
                true
1042
            );
1043
            $this->dom->addChild(
1044
                $localDomestico,
1045
                "nrLograd",
1046
                $this->std->vinculo->contrato->domestico->nrlograd,
1047
                true
1048
            );
1049
            $this->dom->addChild(
1050
                $localDomestico,
1051
                "complemento",
1052
                !empty($this->std->vinculo->contrato->domestico->complemento) ?
1053
                    $this->std->vinculo->contrato->domestico->complemento : null,
1054
                false
1055
            );
1056
            $this->dom->addChild(
1057
                $localDomestico,
1058
                "bairro",
1059
                !empty($this->std->vinculo->contrato->domestico->bairro) ?
1060
                    $this->std->vinculo->contrato->domestico->bairro : null,
1061
                false
1062
            );
1063
            $this->dom->addChild(
1064
                $localDomestico,
1065
                "cep",
1066
                $this->std->vinculo->contrato->domestico->cep,
1067
                true
1068
            );
1069
            $this->dom->addChild(
1070
                $localDomestico,
1071
                "codMunic",
1072
                $this->std->vinculo->contrato->domestico->codmunic,
1073
                true
1074
            );
1075
            $this->dom->addChild(
1076
                $localDomestico,
1077
                "uf",
1078
                $this->std->vinculo->contrato->domestico->uf,
1079
                true
1080
            );
1081
            $localTrabalho->appendChild($localDomestico);
1082
        }
1083
        $contrato->appendChild($localTrabalho);
1084
1085
        //horContratual (opcional)
1086
        if (isset($this->std->vinculo->contrato->horcontatual)) {
1087
            $horContratual = $this->dom->createElement("horContratual");
1088
            $this->dom->addChild(
1089
                $horContratual,
1090
                "qtdHrsSem",
1091
                $this->std->vinculo->contrato->horcontratual->qtdhrssem,
1092
                true
1093
            );
1094
            $this->dom->addChild(
1095
                $horContratual,
1096
                "tpJornada",
1097
                $this->std->vinculo->contrato->horcontratual->tpjornada,
1098
                true
1099
            );
1100
            $this->dom->addChild(
1101
                $horContratual,
1102
                "dscTpJorn",
1103
                !empty($this->std->vinculo->contrato->horcontratual->dsctpjorn) ?
1104
                    $this->std->vinculo->contrato->horcontratual->dsctpjorn : null,
1105
                false
1106
            );
1107
            $this->dom->addChild(
1108
                $horContratual,
1109
                "tmpParc",
1110
                $this->std->vinculo->contrato->horcontratual->tmpparc,
1111
                true
1112
            );
1113
            //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...
1114
            if (isset($this->std->vinculo->contrato->horcontratual->horario)) {
1115
                foreach ($this->std->vinculo->contrato->horcontratual->horario as $hr) {
1116
                    $horario = $this->dom->createElement("horario");
1117
                    $this->dom->addChild(
1118
                        $horario,
1119
                        "dia",
1120
                        $hr->dia,
1121
                        true
1122
                    );
1123
                    $this->dom->addChild(
1124
                        $horario,
1125
                        "codHorContrat",
1126
                        $hr->codhorcontrat,
1127
                        true
1128
                    );
1129
                    $horContratual->appendChild($horario);
1130
                }
1131
            }
1132
            //encerra horContratual
1133
            $contrato->appendChild($horContratual);
1134
        }
1135
1136
        //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...
1137
        if (isset($this->std->vinculo->contrato->filiacaosindical)) {
1138
            foreach ($this->std->vinculo->contrato->filiacaosindical as $sind) {
1139
                $filiacaoSindical = $this->dom->createElement("filiacaoSindical");
1140
                $this->dom->addChild(
1141
                    $horario,
1142
                    "cnpjSindTrab",
1143
                    $sind->cnpjsindtrab,
1144
                    true
1145
                );
1146
                $contrato->appendChild($filiacaoSindical);
1147
            }
1148
        }
1149
        //alvaraJudicial (opcional)
1150
        if (isset($this->std->vinculo->contrato->judicial)) {
1151
            $alvaraJudicial = $this->dom->createElement("alvaraJudicial");
1152
            $this->dom->addChild(
1153
                $alvaraJudicial,
1154
                "nrProcJud",
1155
                $this->std->vinculo->contrato->judicial->nrprocjud,
1156
                true
1157
            );
1158
            $contrato->appendChild($alvaraJudicial);
1159
        }
1160
        //encerra contrato
1161
        $vinculo->appendChild($contrato);
1162
1163
        //sucessaoVinc (opcional)
1164
        if (isset($this->std->vinculo->sucessao)) {
1165
            $sucessaoVinc = $this->dom->createElement("sucessaoVinc");
1166
            $this->dom->addChild(
1167
                $sucessaoVinc,
1168
                "cnpjEmpregAnt",
1169
                $this->std->vinculo->sucessao->cnpjempregant,
1170
                true
1171
            );
1172
            $this->dom->addChild(
1173
                $sucessaoVinc,
1174
                "matricAnt",
1175
                !empty($this->std->vinculo->sucessao->matricant) ? $this->std->vinculo->sucessao->matricant : null,
1176
                false
1177
            );
1178
            $this->dom->addChild(
1179
                $sucessaoVinc,
1180
                "dtIniVinculo",
1181
                $this->std->vinculo->sucessao->dtinivinculo,
1182
                true
1183
            );
1184
            $this->dom->addChild(
1185
                $sucessaoVinc,
1186
                "observacao",
1187
                !empty($this->std->vinculo->sucessao->observacao) ? $this->std->vinculo->sucessao->observacao : null,
1188
                false
1189
            );
1190
            $vinculo->appendChild($sucessaoVinc);
1191
        }
1192
        //afastamento (opcional)
1193
        if (isset($this->std->vinculo->afastamento)) {
1194
            $afastamento = $this->dom->createElement("afastamento");
1195
            $this->dom->addChild(
1196
                $afastamento,
1197
                "dtIniAfast",
1198
                $this->std->vinculo->afastamento->dtiniafast,
1199
                true
1200
            );
1201
            $this->dom->addChild(
1202
                $afastamento,
1203
                "codMotAfast",
1204
                $this->std->vinculo->afastamento->codmotafast,
1205
                true
1206
            );
1207
1208
            $vinculo->appendChild($afastamento);
1209
        }
1210
1211
        //desligamento (opcional)
1212
        if (isset($this->std->vinculo->desligamento)) {
1213
            $desligamento = $this->dom->createElement("desligamento");
1214
            $this->dom->addChild(
1215
                $desligamento,
1216
                "dtDeslig",
1217
                $this->std->vinculo->desligamento->dtdeslig,
1218
                true
1219
            );
1220
1221
            $vinculo->appendChild($desligamento);
1222
        }
1223
1224
        //encerra vinculo
1225
        $this->node->appendChild($vinculo);
1226
        //finalização do xml
1227
1228
        $evtAdmissao->appendChild($vinculo);
1229
1230
        $eSocial->appendChild($evtAdmissao);
1231
        $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...
1232
    }
1233
}
1234