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

TraitS1207   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 123
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 0
loc 123
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B toNode250() 0 109 6
A toNodeS100() 0 4 1
1
<?php
2
3
namespace NFePHP\eSocial\Factories\Traits;
4
5
trait TraitS1207
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
            "indRetif",
19
            $this->std->indretif,
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...
20
            true
21
        );
22
        $this->dom->addChild(
23
            $ideEvento,
24
            "nrRecibo",
25
            !empty($this->std->nrrecibo) ? $this->std->nrrecibo : null,
26
            false
27
        );
28
        $this->dom->addChild(
29
            $ideEvento,
30
            "indApuracao",
31
            $this->std->indapuracao,
32
            true
33
        );
34
        $this->dom->addChild(
35
            $ideEvento,
36
            "perApur",
37
            $this->std->perapur,
38
            true
39
        );
40
        $this->dom->addChild(
41
            $ideEvento,
42
            "tpAmb",
43
            $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...
44
            true
45
        );
46
        $this->dom->addChild(
47
            $ideEvento,
48
            "procEmi",
49
            $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...
50
            true
51
        );
52
        $this->dom->addChild(
53
            $ideEvento,
54
            "verProc",
55
            $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...
56
            true
57
        );
58
        $this->node->insertBefore($ideEvento, $ideEmpregador);
59
        $ideBenef = $this->dom->createElement("ideBenef");
60
        $this->dom->addChild(
61
            $ideBenef,
62
            "cpfBenef",
63
            $this->std->cpfbenef,
64
            true
65
        );
66
        $this->node->appendChild($ideBenef);
67
        if (isset($this->std->dmdev)) {
68
            foreach ($this->std->dmdev as $dev) {
69
                $dmDev = $this->dom->createElement("dmDev");
70
                $this->dom->addChild(
71
                    $dmDev,
72
                    "tpBenef",
73
                    $dev->tpbenef,
74
                    true
75
                );
76
                $this->dom->addChild(
77
                    $dmDev,
78
                    "nrBenefic",
79
                    $dev->nrbenefic,
80
                    true
81
                );
82
                $this->dom->addChild(
83
                    $dmDev,
84
                    "ideDmDev",
85
                    $dev->idedmdev,
86
                    true
87
                );
88
                if (isset($dev->itens)) {
89
                    foreach ($dev->itens as $item) {
90
                        $itens = $this->dom->createElement("itens");
91
                        $this->dom->addChild(
92
                            $itens,
93
                            "codRubr",
94
                            $item->codrubr,
95
                            true
96
                        );
97
                        $this->dom->addChild(
98
                            $itens,
99
                            "ideTabRubr",
100
                            $item->idetabrubr,
101
                            true
102
                        );
103
                        $this->dom->addChild(
104
                            $itens,
105
                            "vrRubr",
106
                            $item->vrrubr,
107
                            true
108
                        );
109
                        $dmDev->appendChild($itens);
110
                    }
111
                }
112
                $this->node->appendChild($dmDev);
113
            }
114
        }
115
        $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...
116
        //$this->xml = $this->dom->saveXML($this->eSocial);
117
        $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...
118
    }
119
    
120
    /**
121
     * builder for version S.1.0.0
122
     */
123
    protected function toNodeS100()
124
    {
125
        throw new \Exception("TODO !!");
126
    }
127
}
128