Completed
Push — master ( 0f6c35...16dc49 )
by Roberto
06:14 queued 03:03
created

EvtConvInterm::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 4
crap 2
1
<?php
2
3
namespace NFePHP\eSocial\Factories;
4
5
/**
6
 * Class eSocial EvtConvInterm Event S-2260 constructor
7
 * Read for 2.5.0 layout
8
 *
9
 * @category  library
10
 * @package   NFePHP\eSocial
11
 * @copyright NFePHP Copyright (c) 2018
12
 * @license   http://www.gnu.org/licenses/lgpl.txt LGPLv3+
13
 * @license   https://opensource.org/licenses/MIT MIT
14
 * @license   http://www.gnu.org/licenses/gpl.txt GPLv3+
15
 * @author    Roberto L. Machado <linux.rlm at gmail dot com>
16
 * @link      http://github.com/nfephp-org/sped-esocial for the canonical source repository
17
 */
18
19
use NFePHP\Common\Certificate;
20
use NFePHP\eSocial\Common\Factory;
21
use NFePHP\eSocial\Common\FactoryId;
22
use NFePHP\eSocial\Common\FactoryInterface;
23
use stdClass;
24
25
class EvtConvInterm extends Factory implements FactoryInterface
26
{
27
    /**
28
     * @var int
29
     */
30
    public $sequencial;
31
    /**
32
     * @var string
33
     */
34
    protected $evtName = 'evtConvInterm';
35
    /**
36
     * @var string
37
     */
38
    protected $evtAlias = 'S-2260';
39
    /**
40
     * Parameters patterns
41
     *
42
     * @var array
43
     */
44
    protected $parameters = [];
45
46
    /**
47
     * Constructor
48
     *
49
     * @param string $config
50
     * @param stdClass $std
51
     * @param Certificate $certificate | null
52
     * @param string $date
53
     */
54
    public function __construct(
55
        $config,
56
        stdClass $std,
57
        Certificate $certificate = null,
58
        $date = ''
59
    ) {
60
        parent::__construct($config, $std, $certificate, $date);
61
    }
62
63
    /**
64
     * Node constructor
65
     */
66
    protected function toNode()
67
    {
68
        $ideEmpregador = $this->node->getElementsByTagName('ideEmpregador')->item(0);
69
        //o idEvento pode variar de evento para evento
70
        //então cada factory individualmente terá de construir o seu
71
        $ideEvento = $this->dom->createElement("ideEvento");
72
        $this->dom->addChild(
73
            $ideEvento,
74
            "indRetif",
75
            $this->std->indretif,
76
            true
77
        );
78
        $this->dom->addChild(
79
            $ideEvento,
80
            "nrRecibo",
81
            ! empty($this->std->nrrecibo) ? $this->std->nrrecibo : null,
82
            false
83
        );
84
        $this->dom->addChild(
85
            $ideEvento,
86
            "tpAmb",
87
            $this->tpAmb,
88
            true
89
        );
90
        $this->dom->addChild(
91
            $ideEvento,
92
            "procEmi",
93
            $this->procEmi,
94
            true
95
        );
96
        $this->dom->addChild(
97
            $ideEvento,
98
            "verProc",
99
            $this->verProc,
100
            true
101
        );
102
        $this->node->insertBefore($ideEvento, $ideEmpregador);
103
        $ideVinculo = $this->dom->createElement("ideVinculo");
104
        $this->dom->addChild(
105
            $ideVinculo,
106
            "cpfTrab",
107
            $this->std->idevinculo->cpftrab,
108
            true
109
        );
110
        $this->dom->addChild(
111
            $ideVinculo,
112
            "nisTrab",
113
            $this->std->idevinculo->nistrab,
114
            true
115
        );
116
        $this->dom->addChild(
117
            $ideVinculo,
118
            "matricula",
119
            $this->std->idevinculo->matricula,
120
            true
121
        );
122
        $this->node->appendChild($ideVinculo);
123
        
124
        $i = $this->std->infoconvinterm;
125
        $info = $this->dom->createElement("infoConvInterm");
126
        $this->dom->addChild(
127
            $info,
128
            "codConv",
129
            $i->codconv,
130
            true
131
        );
132
        $this->dom->addChild(
133
            $info,
134
            "dtInicio",
135
            $i->dtinicio,
136
            true
137
        );
138
        $this->dom->addChild(
139
            $info,
140
            "dtFim",
141
            $i->dtfim,
142
            true
143
        );
144
        $this->dom->addChild(
145
            $info,
146
            "dtPrevPgto",
147
            $i->dtprevpgto,
148
            true
149
        );
150
        $jornada = $this->dom->createElement("jornada");
151
        $this->dom->addChild(
152
            $jornada,
153
            "codHorContrat",
154
            !empty($i->jornada->codhorcontrat) ? $i->jornada->codhorcontrat : null,
155
            false
156
        );
157
        $this->dom->addChild(
158
            $jornada,
159
            "dscJornada",
160
            !empty($i->jornada->dscjornada) ? $i->jornada->dscjornada : null,
161
            false
162
        );
163
        $info->appendChild($jornada);
164
        
165
        $localTrab = $this->dom->createElement("localTrab");
166
        $this->dom->addChild(
167
            $localTrab,
168
            "indLocal",
169
            $i->localtrab->indlocal,
170
            true
171
        );
172
        if (!empty($i->localtrab->localtrabinterm)) {
173
            $l = $i->localtrab->localtrabinterm;
174
            $local = $this->dom->createElement("localTrabInterm");
175
            $this->dom->addChild(
176
                $local,
177
                "tpLograd",
178
                $l->tplograd,
179
                true
180
            );
181
            $this->dom->addChild(
182
                $local,
183
                "dscLograd",
184
                $l->dsclograd,
185
                true
186
            );
187
            $this->dom->addChild(
188
                $local,
189
                "nrLograd",
190
                $l->nrlograd,
191
                true
192
            );
193
            $this->dom->addChild(
194
                $local,
195
                "complem",
196
                !empty($l->complem) ? $l->complem : null,
197
                false
198
            );
199
            $this->dom->addChild(
200
                $local,
201
                "bairro",
202
                !empty($l->bairro) ? $l->bairro : null,
203
                false
204
            );
205
            $this->dom->addChild(
206
                $local,
207
                "cep",
208
                $l->cep,
209
                true
210
            );
211
            $this->dom->addChild(
212
                $local,
213
                "codMunic",
214
                $l->codmunic,
215
                true
216
            );
217
            $this->dom->addChild(
218
                $local,
219
                "uf",
220
                $l->uf,
221
                true
222
            );
223
            $localTrab->appendChild($local);
224
        }
225
        $info->appendChild($localTrab);
226
        $this->node->appendChild($info);
227
        $this->eSocial->appendChild($this->node);
228
        //$this->xml = $this->dom->saveXML($this->eSocial);
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% 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...
229
        $this->sign();
230
    }
231
}
232