Test Failed
Push — master ( ce467a...63d89e )
by Roberto
02:31 queued 12s
created

TraitS1005::toNodeS100()   F

Complexity

Conditions 22
Paths 6156

Size

Total Lines 221

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 221
rs 0
c 0
b 0
f 0
cc 22
nc 6156
nop 0

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\Traits;
4
5
trait TraitS1005
6
{
7
    /**
8
     * builder for version 2.5.0
9
     */
10
    protected function toNode250()
11
    {
12
        $ideEmpregador = $this->node->getElementsByTagName('ideEmpregador')->item(0);
0 ignored issues
show
Bug introduced by
The property node does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
13
        //o idEvento pode variar de evento para evento
14
        //então cada factory individualmente terá de construir o seu
15
        $ideEvento = $this->dom->createElement("ideEvento");
0 ignored issues
show
Bug introduced by
The property dom does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
16
        $this->dom->addChild(
17
            $ideEvento,
18
            "tpAmb",
19
            $this->tpAmb,
0 ignored issues
show
Bug introduced by
The property tpAmb does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
20
            true
21
        );
22
        $this->dom->addChild(
23
            $ideEvento,
24
            "procEmi",
25
            $this->procEmi,
0 ignored issues
show
Bug introduced by
The property procEmi does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
26
            true
27
        );
28
        $this->dom->addChild(
29
            $ideEvento,
30
            "verProc",
31
            $this->verProc,
0 ignored issues
show
Bug introduced by
The property verProc does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
32
            true
33
        );
34
        $this->node->insertBefore($ideEvento, $ideEmpregador);
35
36
        //tag deste evento em particular
37
        $infoEstab = $this->dom->createElement("infoEstab");
0 ignored issues
show
Unused Code introduced by
$infoEstab is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
38
39
        //tag comum a todos os modos
40
        $ideEstab = $this->dom->createElement("ideEstab");
41
        $this->dom->addChild(
42
            $ideEstab,
43
            "tpInsc",
44
            $this->std->tpinsc,
0 ignored issues
show
Bug introduced by
The property std does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
45
            true
46
        );
47
        $this->dom->addChild(
48
            $ideEstab,
49
            "nrInsc",
50
            $this->std->nrinsc,
51
            true
52
        );
53
        $this->dom->addChild(
54
            $ideEstab,
55
            "iniValid",
56
            $this->std->inivalid,
57
            true
58
        );
59
        $this->dom->addChild(
60
            $ideEstab,
61
            "fimValid",
62
            ! empty($this->std->fimvalid) ? $this->std->fimvalid : null,
63
            false
64
        );
65
66
        if ($this->std->modo == 'INC') {
67
            $node = $this->dom->createElement("inclusao");
68
        } elseif ($this->std->modo == 'ALT') {
69
            $node = $this->dom->createElement("alteracao");
70
        } else {
71
            $node = $this->dom->createElement("exclusao");
72
        }
73
        $node->appendChild($ideEstab);
74
75
        if (! empty($this->std->dadosestab)) {
76
            $dadosEstab = $this->dom->createElement("dadosEstab");
77
            $this->dom->addChild(
78
                $dadosEstab,
79
                "cnaePrep",
80
                $this->std->dadosestab->cnaeprep,
81
                true
82
            );
83
            $aliqGilrat = $this->dom->createElement("aliqGilrat");
84
            $this->dom->addChild(
85
                $aliqGilrat,
86
                "aliqRat",
87
                $this->std->dadosestab->aliqgilrat->aliqrat,
88
                true
89
            );
90
            $fap = ! empty($this->std->dadosestab->aliqgilrat->fap) ? $this->std->dadosestab->aliqgilrat->fap : null;
91
            if ($fap) {
92
                $fap = number_format($fap, 4, '.', '');
93
            }
94
            $this->dom->addChild(
95
                $aliqGilrat,
96
                "fap",
97
                $fap,
98
                false
99
            );
100
            $aliqrata = ! empty($this->std->dadosestab->aliqgilrat->aliqratajust)
101
                ? $this->std->dadosestab->aliqgilrat->aliqratajust
102
                : null;
103
            if ($aliqrata) {
104
                $aliqrata = number_format($aliqrata, 4, '.', '');
105
            }
106
            $this->dom->addChild(
107
                $aliqGilrat,
108
                "aliqRatAjust",
109
                $aliqrata,
110
                false
111
            );
112
            if (! empty($this->std->dadosestab->aliqgilrat->procadmjudrat)) {
113
                $procAdmJudRat = $this->dom->createElement("procAdmJudRat");
114
                $this->dom->addChild(
115
                    $procAdmJudRat,
116
                    "tpProc",
117
                    $this->std->dadosestab->aliqgilrat->procadmjudrat->tpproc,
118
                    true
119
                );
120
                $this->dom->addChild(
121
                    $procAdmJudRat,
122
                    "nrProc",
123
                    $this->std->dadosestab->aliqgilrat->procadmjudrat->nrproc,
124
                    true
125
                );
126
                $this->dom->addChild(
127
                    $procAdmJudRat,
128
                    "codSusp",
129
                    $this->std->dadosestab->aliqgilrat->procadmjudrat->codsusp,
130
                    true
131
                );
132
                $aliqGilrat->appendChild($procAdmJudRat);
133
            }
134
            if (! empty($this->std->dadosestab->aliqgilrat->procadmjudfap)) {
135
                $procAdmJudFap = $this->dom->createElement("procAdmJudFap");
136
                $this->dom->addChild(
137
                    $procAdmJudFap,
138
                    "tpProc",
139
                    $this->std->dadosestab->aliqgilrat->procadmjudfap->tpproc,
140
                    true
141
                );
142
                $this->dom->addChild(
143
                    $procAdmJudFap,
144
                    "nrProc",
145
                    $this->std->dadosestab->aliqgilrat->procadmjudfap->nrproc,
146
                    true
147
                );
148
                $this->dom->addChild(
149
                    $procAdmJudFap,
150
                    "codSusp",
151
                    $this->std->dadosestab->aliqgilrat->procadmjudfap->codsusp,
152
                    true
153
                );
154
                $aliqGilrat->appendChild($procAdmJudFap);
155
            }
156
            $dadosEstab->appendChild($aliqGilrat);
157
158
            if (! empty($this->std->dadosestab->infocaepf)) {
159
                $infoCaepf = $this->dom->createElement("infoCaepf");
160
                $this->dom->addChild(
161
                    $infoCaepf,
162
                    "tpCaepf",
163
                    $this->std->dadosestab->infocaepf->tpcaepf,
164
                    true
165
                );
166
                $dadosEstab->appendChild($infoCaepf);
167
            }
168
169
            if (! empty($this->std->dadosestab->infoobra)) {
170
                $infoObra = $this->dom->createElement("infoObra");
171
                $this->dom->addChild(
172
                    $infoObra,
173
                    "indSubstPatrObra",
174
                    $this->std->dadosestab->infoobra->indsubstpatrobra,
175
                    true
176
                );
177
                $dadosEstab->appendChild($infoObra);
178
            }
179
            
180
            $infoTrab = $this->dom->createElement("infoTrab");
181
            $this->dom->addChild(
182
                $infoTrab,
183
                "regPt",
184
                $this->std->dadosestab->infotrab->regpt,
185
                true
186
            );
187
            if (! empty($this->std->dadosestab->infoapr)) {
188
                $infoApr = $this->dom->createElement("infoApr");
189
                $this->dom->addChild(
190
                    $infoApr,
191
                    "contApr",
192
                    $this->std->dadosestab->infotrab->infoapr->contapr,
193
                    true
194
                );
195
                $this->dom->addChild(
196
                    $infoApr,
197
                    "nrProcJud",
198
                    ! empty($this->std->dadosestab->infotrab->infoapr->nrprocjud)
199
                        ? $this->std->dadosestab->infotrab->infoapr->nrprocjud
200
                        : null,
201
                    false
202
                );
203
                $this->dom->addChild(
204
                    $infoApr,
205
                    "contEntEd",
206
                    ! empty($this->std->dadosestab->infotrab->infoapr->contented)
207
                        ? $this->std->dadosestab->infotrab->infoapr->contented
208
                        : null,
209
                    false
210
                );
211
212
                if (! empty($this->std->dadosestab->infotrab->infoapr->infoenteduc)) {
213
                    foreach ($this->std->dadosestab->infotrab->infoapr->infoenteduc as $edu) {
214
                        $infoEntEduc = $this->dom->createElement("infoEntEduc");
215
                        $this->dom->addChild(
216
                            $infoEntEduc,
217
                            "nrInsc",
218
                            $edu->nrinsc,
219
                            true
220
                        );
221
                        $infoApr->appendChild($infoEntEduc);
222
                    }
223
                }
224
225
                $infoTrab->appendChild($infoApr);
226
            }
227
            if (! empty($this->std->dadosestab->infotrab->infopdc)) {
228
                $infoPCD = $this->dom->createElement("infoPCD");
229
                $this->dom->addChild(
230
                    $infoPCD,
231
                    "contPCD",
232
                    $this->std->dadosestab->infotrab->infopdc->contpdc,
233
                    true
234
                );
235
                $this->dom->addChild(
236
                    $infoPCD,
237
                    "nrProcJud",
238
                    ! empty($this->std->dadosestab->infotrab->infopdc->nrprocjud)
239
                        ? $this->std->dadosestab->infotrab->infopdc->nrprocjud
240
                        : null,
241
                    false
242
                );
243
                $infoTrab->appendChild($infoPCD);
244
            }
245
            $dadosEstab->appendChild($infoTrab);
246
            $node->appendChild($dadosEstab);
247
        }
248
249
        if (! empty($this->std->novavalidade) && $this->std->modo == 'ALT') {
250
            $newVal = $this->std->novavalidade;
251
            $novaValidade = $this->dom->createElement("novaValidade");
252
            $this->dom->addChild(
253
                $novaValidade,
254
                "iniValid",
255
                $newVal->inivalid,
256
                true
257
            );
258
            $this->dom->addChild(
259
                $novaValidade,
260
                "fimValid",
261
                ! empty($newVal->fimvalid) ? $newVal->fimvalid : null,
262
                false
263
            );
264
            $node->appendChild($novaValidade);
265
        }
266
        $infoEstab = $this->dom->createElement("infoEstab");
267
        $infoEstab->appendChild($node);
268
        //finalização do xml
269
        $this->node->appendChild($infoEstab);
270
        $this->eSocial->appendChild($this->node);
0 ignored issues
show
Bug introduced by
The property eSocial does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
271
        $this->sign();
0 ignored issues
show
Bug introduced by
It seems like sign() must be provided by classes using this trait. How about adding it as abstract method to this trait?

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

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

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

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

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

Loading history...
272
    }
273
    
274
    /**
275
     * builder for version S.1.0.0
276
     */
277
    protected function toNodeS100()
278
    {
279
        $ideEmpregador = $this->node->getElementsByTagName('ideEmpregador')->item(0);
280
        //o idEvento pode variar de evento para evento
281
        //então cada factory individualmente terá de construir o seu
282
        $ideEvento = $this->dom->createElement("ideEvento");
283
        $this->dom->addChild(
284
            $ideEvento,
285
            "tpAmb",
286
            $this->tpAmb,
287
            true
288
        );
289
        $this->dom->addChild(
290
            $ideEvento,
291
            "procEmi",
292
            $this->procEmi,
293
            true
294
        );
295
        $this->dom->addChild(
296
            $ideEvento,
297
            "verProc",
298
            $this->verProc,
299
            true
300
        );
301
        $this->node->insertBefore($ideEvento, $ideEmpregador);
302
303
        //tag deste evento em particular
304
        $infoEstab = $this->dom->createElement("infoEstab");
0 ignored issues
show
Unused Code introduced by
$infoEstab is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
305
306
        //tag comum a todos os modos
307
        $ideEstab = $this->dom->createElement("ideEstab");
308
        $this->dom->addChild(
309
            $ideEstab,
310
            "tpInsc",
311
            $this->std->tpinsc,
312
            true
313
        );
314
        $this->dom->addChild(
315
            $ideEstab,
316
            "nrInsc",
317
            $this->std->nrinsc,
318
            true
319
        );
320
        $this->dom->addChild(
321
            $ideEstab,
322
            "iniValid",
323
            $this->std->inivalid,
324
            true
325
        );
326
        if ($this->std->modo !== 'INC') {
327
            $this->dom->addChild(
328
                $ideEstab,
329
                "fimValid",
330
                !empty($this->std->fimvalid) ? $this->std->fimvalid : null,
331
                false
332
            );
333
        }
334
335
        if ($this->std->modo == 'INC') {
336
            $node = $this->dom->createElement("inclusao");
337
        } elseif ($this->std->modo == 'ALT') {
338
            $node = $this->dom->createElement("alteracao");
339
        } else {
340
            $node = $this->dom->createElement("exclusao");
341
        }
342
        $node->appendChild($ideEstab);
343
344
        if (!empty($this->std->dadosestab) && in_array($this->std->modo, ['INC', 'ALT'])) {
345
            $dadosEstab = $this->dom->createElement("dadosEstab");
346
            $this->dom->addChild(
347
                $dadosEstab,
348
                "cnaePrep",
349
                $this->std->dadosestab->cnaeprep,
350
                true
351
            );
352
            $aliqGilrat = $this->dom->createElement("aliqGilrat");
353
            $this->dom->addChild(
354
                $aliqGilrat,
355
                "aliqRat",
356
                $this->std->dadosestab->aliqgilrat->aliqrat,
357
                false
358
            );
359
            $fap = !empty($this->std->dadosestab->aliqgilrat->fap) ? $this->std->dadosestab->aliqgilrat->fap : null;
360
            if ($fap) {
361
                $fap = number_format($fap, 4, '.', '');
362
            }
363
            $this->dom->addChild(
364
                $aliqGilrat,
365
                "fap",
366
                $fap,
367
                false
368
            );
369
            if (!empty($this->std->dadosestab->aliqgilrat->procadmjudrat)) {
370
                $procAdmJudRat = $this->dom->createElement("procAdmJudRat");
371
                $this->dom->addChild(
372
                    $procAdmJudRat,
373
                    "tpProc",
374
                    $this->std->dadosestab->aliqgilrat->procadmjudrat->tpproc,
375
                    true
376
                );
377
                $this->dom->addChild(
378
                    $procAdmJudRat,
379
                    "nrProc",
380
                    $this->std->dadosestab->aliqgilrat->procadmjudrat->nrproc,
381
                    true
382
                );
383
                $this->dom->addChild(
384
                    $procAdmJudRat,
385
                    "codSusp",
386
                    $this->std->dadosestab->aliqgilrat->procadmjudrat->codsusp,
387
                    true
388
                );
389
                $aliqGilrat->appendChild($procAdmJudRat);
390
            }
391
            if (!empty($this->std->dadosestab->aliqgilrat->procadmjudfap)) {
392
                $procAdmJudFap = $this->dom->createElement("procAdmJudFap");
393
                $this->dom->addChild(
394
                    $procAdmJudFap,
395
                    "tpProc",
396
                    $this->std->dadosestab->aliqgilrat->procadmjudfap->tpproc,
397
                    true
398
                );
399
                $this->dom->addChild(
400
                    $procAdmJudFap,
401
                    "nrProc",
402
                    $this->std->dadosestab->aliqgilrat->procadmjudfap->nrproc,
403
                    true
404
                );
405
                $this->dom->addChild(
406
                    $procAdmJudFap,
407
                    "codSusp",
408
                    $this->std->dadosestab->aliqgilrat->procadmjudfap->codsusp,
409
                    true
410
                );
411
                $aliqGilrat->appendChild($procAdmJudFap);
412
            }
413
            $dadosEstab->appendChild($aliqGilrat);
414
            if (!empty($this->std->dadosestab->infocaepf)) {
415
                $infoCaepf = $this->dom->createElement("infoCaepf");
416
                $this->dom->addChild(
417
                    $infoCaepf,
418
                    "tpCaepf",
419
                    $this->std->dadosestab->infocaepf->tpcaepf,
420
                    true
421
                );
422
                $dadosEstab->appendChild($infoCaepf);
423
            }
424
            if (! empty($this->std->dadosestab->infoobra)) {
425
                $infoObra = $this->dom->createElement("infoObra");
426
                $this->dom->addChild(
427
                    $infoObra,
428
                    "indSubstPatrObra",
429
                    $this->std->dadosestab->infoobra->indsubstpatrobra,
430
                    true
431
                );
432
                $dadosEstab->appendChild($infoObra);
433
            }
434
            if (!empty($this->std->dadosestab->infotrab)) {
435
                $infoTrab = $this->dom->createElement("infoTrab");
436
                if (!empty($this->std->dadosestab->infotrab->infoapr)) {
437
                    $infoApr = $this->dom->createElement("infoApr");
438
                    $this->dom->addChild(
439
                        $infoApr,
440
                        "nrProcJud",
441
                        ! empty($this->std->dadosestab->infotrab->infoapr->nrprocjud)
442
                            ? $this->std->dadosestab->infotrab->infoapr->nrprocjud
443
                            : null,
444
                        false
445
                    );
446
                    if (! empty($this->std->dadosestab->infotrab->infoapr->infoenteduc)) {
447
                        foreach ($this->std->dadosestab->infotrab->infoapr->infoenteduc as $edu) {
448
                            $infoEntEduc = $this->dom->createElement("infoEntEduc");
449
                            $this->dom->addChild(
450
                                $infoEntEduc,
451
                                "nrInsc",
452
                                $edu->nrinsc,
453
                                true
454
                            );
455
                            $infoApr->appendChild($infoEntEduc);
456
                        }
457
                    }
458
                    $infoTrab->appendChild($infoApr);
459
                }
460
            }
461
            if (!empty($this->std->dadosestab->infotrab->infopdc)) {
462
                $infoPCD = $this->dom->createElement("infoPCD");
463
                $this->dom->addChild(
464
                    $infoPCD,
465
                    "nrProcJud",
466
                    $this->std->dadosestab->infotrab->infopdc->nrprocjud,
467
                    true
468
                );
469
                $infoTrab->appendChild($infoPCD);
0 ignored issues
show
Bug introduced by
The variable $infoTrab does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
470
            }
471
            $dadosEstab->appendChild($infoTrab);
472
            $node->appendChild($dadosEstab);
473
        }
474
        if (!empty($this->std->novavalidade) && $this->std->modo == 'ALT') {
475
            $newVal = $this->std->novavalidade;
476
            $novaValidade = $this->dom->createElement("novaValidade");
477
            $this->dom->addChild(
478
                $novaValidade,
479
                "iniValid",
480
                $newVal->inivalid,
481
                true
482
            );
483
            $this->dom->addChild(
484
                $novaValidade,
485
                "fimValid",
486
                !empty($newVal->fimvalid) ? $newVal->fimvalid : null,
487
                false
488
            );
489
            $node->appendChild($novaValidade);
490
        }
491
        $infoEstab = $this->dom->createElement("infoEstab");
492
        $infoEstab->appendChild($node);
493
        //finalização do xml
494
        $this->node->appendChild($infoEstab);
495
        $this->eSocial->appendChild($this->node);
496
        $this->sign();
0 ignored issues
show
Bug introduced by
It seems like sign() must be provided by classes using this trait. How about adding it as abstract method to this trait?

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

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

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

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

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

Loading history...
497
    }
498
}
499