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

TraitS1030::toNodeS100()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace NFePHP\eSocial\Factories\Traits;
4
5
trait TraitS1030
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
        $ide = $this->dom->createElement("ideCargo");
37
        $this->dom->addChild(
38
            $ide,
39
            "codCargo",
40
            $this->std->codcargo,
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...
41
            true
42
        );
43
        $this->dom->addChild(
44
            $ide,
45
            "iniValid",
46
            $this->std->inivalid,
47
            true
48
        );
49
        $this->dom->addChild(
50
            $ide,
51
            "fimValid",
52
            ! empty($this->std->fimvalid) ? $this->std->fimvalid : null,
53
            false
54
        );
55
56
57
        if (!empty($this->std->dadoscargo)) {
58
            $da = $this->std->dadoscargo;
59
            $dados = $this->dom->createElement("dadosCargo");
60
            $this->dom->addChild(
61
                $dados,
62
                "nmCargo",
63
                $da->nmcargo,
64
                true
65
            );
66
            $this->dom->addChild(
67
                $dados,
68
                "codCBO",
69
                $da->codcbo,
70
                true
71
            );
72
            if (!empty($da->cargopublico)) {
73
                $cpub = $this->dom->createElement("cargoPublico");
74
                $this->dom->addChild(
75
                    $cpub,
76
                    "acumCargo",
77
                    $da->cargopublico->acumcargo,
78
                    true
79
                );
80
                $this->dom->addChild(
81
                    $cpub,
82
                    "contagemEsp",
83
                    $da->cargopublico->contagemesp,
84
                    true
85
                );
86
                $this->dom->addChild(
87
                    $cpub,
88
                    "dedicExcl",
89
                    $da->cargopublico->dedicexcl,
90
                    true
91
                );
92
                $lei = $this->dom->createElement("leiCargo");
93
                $this->dom->addChild(
94
                    $lei,
95
                    "nrLei",
96
                    $da->cargopublico->nrlei,
97
                    true
98
                );
99
                $this->dom->addChild(
100
                    $lei,
101
                    "dtLei",
102
                    $da->cargopublico->dtlei,
103
                    true
104
                );
105
                $this->dom->addChild(
106
                    $lei,
107
                    "sitCargo",
108
                    $da->cargopublico->sitcargo,
109
                    true
110
                );
111
                $cpub->appendChild($lei);
112
                $dados->appendChild($cpub);
113
            }
114
        }
115
116
        if (!empty($this->std->novavalidade)) {
117
            $nova = $this->dom->createElement("novaValidade");
118
            $this->dom->addChild(
119
                $nova,
120
                "iniValid",
121
                $this->std->novavalidade->inivalid,
122
                true
123
            );
124
            $this->dom->addChild(
125
                $nova,
126
                "fimValid",
127
                ! empty($this->std->novavalidade->fimvalid)
128
                    ? $this->std->novavalidade->fimvalid
129
                    : null,
130
                false
131
            );
132
        }
133
134
        $info = $this->dom->createElement("infoCargo");
135
        //seleção do modo
136
        if ($this->std->modo == 'INC') {
137
            $node = $this->dom->createElement("inclusao");
138
            $node->appendChild($ide);
139
            isset($dados) ? $node->appendChild($dados) : null;
140
        } elseif ($this->std->modo == 'ALT') {
141
            $node = $this->dom->createElement("alteracao");
142
            $node->appendChild($ide);
143
            isset($dados) ? $node->appendChild($dados): null;
144
            isset($nova) ? $node->appendChild($nova): null;
145
        } else {
146
            $node = $this->dom->createElement("exclusao");
147
            $node->appendChild($ide);
148
        }
149
        $info->appendChild($node);
150
        $this->node->appendChild($info);
151
        $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...
152
        //$this->xml = $this->dom->saveXML($this->eSocial);
153
        $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...
154
    }
155
    
156
    /**
157
     * builder for version S.1.0.0
158
     */
159
    protected function toNodeS100()
160
    {
161
        throw new \Exception("NÃO EXISTE EVENTO {$this->evtAlias} na versão S_1.0 !!");
0 ignored issues
show
Bug introduced by
The property evtAlias 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...
162
    }
163
}
164