Conditions | 5 |
Paths | 1 |
Total Lines | 97 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
33 | protected function toNode() |
||
34 | { |
||
35 | $ideDeclarante = $this->node->getElementsByTagName('ideDeclarante')->item(0); |
||
36 | //o idEvento pode variar de evento para evento |
||
37 | //então cada factory individualmente terá de construir o seu |
||
38 | $ideEvento = $this->dom->createElement("ideEvento"); |
||
39 | $this->dom->addChild( |
||
40 | $ideEvento, |
||
41 | "indRetificacao", |
||
42 | $this->std->indretificacao, |
||
43 | true |
||
44 | ); |
||
45 | $this->dom->addChild( |
||
46 | $ideEvento, |
||
47 | "nrRecibo", |
||
48 | isset($this->std->nrrecibo) ? $this->std->nrrecibo : null, |
||
49 | false |
||
50 | ); |
||
51 | $this->dom->addChild( |
||
52 | $ideEvento, |
||
53 | "tpAmb", |
||
54 | (string) $this->tpAmb, |
||
55 | true |
||
56 | ); |
||
57 | $this->dom->addChild( |
||
58 | $ideEvento, |
||
59 | "aplicEmi", |
||
60 | '1', |
||
61 | true |
||
62 | ); |
||
63 | $this->dom->addChild( |
||
64 | $ideEvento, |
||
65 | "verAplic", |
||
66 | $this->verAplic, |
||
67 | true |
||
68 | ); |
||
69 | $this->node->insertBefore($ideEvento, $ideDeclarante); |
||
70 | |||
71 | $infoIntermediario = $this->dom->createElement("infoIntermediario"); |
||
72 | $this->dom->addChild( |
||
73 | $infoIntermediario, |
||
74 | "GIIN", |
||
75 | !empty($this->std->giin) ? $this->std->giin : null, |
||
76 | false |
||
77 | ); |
||
78 | $this->dom->addChild( |
||
79 | $infoIntermediario, |
||
80 | "tpNI", |
||
81 | !empty($this->std->tpni) ? $this->std->tpni : null, |
||
82 | false |
||
83 | ); |
||
84 | $this->dom->addChild( |
||
85 | $infoIntermediario, |
||
86 | "NIIntermediario", |
||
87 | !empty($this->std->niintermediario) ? $this->std->niintermediario : null, |
||
88 | false |
||
89 | ); |
||
90 | $this->dom->addChild( |
||
91 | $infoIntermediario, |
||
92 | "nomeIntermediario", |
||
93 | $this->std->nomeintermediario, |
||
94 | true |
||
95 | ); |
||
96 | $endereco = $this->dom->createElement("endereco"); |
||
97 | $this->dom->addChild( |
||
98 | $endereco, |
||
99 | "enderecoLivre", |
||
100 | $this->std->endereco->enderecolivre, |
||
101 | true |
||
102 | ); |
||
103 | $this->dom->addChild( |
||
104 | $endereco, |
||
105 | "municipio", |
||
106 | $this->std->endereco->municipio, |
||
107 | true |
||
108 | ); |
||
109 | $this->dom->addChild( |
||
110 | $endereco, |
||
111 | "pais", |
||
112 | $this->std->endereco->pais, |
||
113 | true |
||
114 | ); |
||
115 | $infoIntermediario->appendChild($endereco); |
||
116 | $this->dom->addChild( |
||
117 | $infoIntermediario, |
||
118 | "paisResidencia", |
||
119 | $this->std->paisresidencia, |
||
120 | true |
||
121 | ); |
||
122 | $this->node->appendChild($infoIntermediario); |
||
123 | |||
124 | |||
125 | //finalização do xml |
||
126 | $this->eFinanceira->appendChild($this->node); |
||
127 | //$this->xml = $this->dom->saveXML($this->eFinanceira); |
||
128 | $this->sign($this->evtTag); |
||
129 | } |
||
130 | } |
||
131 |