Conditions | 8 |
Paths | 48 |
Total Lines | 63 |
Code Lines | 46 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
53 | public function crear_documento_cobros($pendiente, $pagado) |
||
54 | { |
||
55 | // $this->pendiente = $this->pagosFactura(false); |
||
56 | // $this->pagado = $this->pagosFactura(true); |
||
57 | $linea_actual = 0; |
||
58 | $pagina = 1; |
||
59 | $lppag = 32; /// líneas por página |
||
60 | while ($linea_actual < count($pendiente)) { |
||
61 | /// salto de página |
||
62 | if ($linea_actual > 0) { |
||
63 | $this->documento->pdf->ezNewPage(); |
||
64 | } |
||
65 | $this->documento->generar_pdf_cabecera($this->empresa, $lppag); |
||
66 | $this->documento->generar_datos_residente($this->documento, 'informe_cobros', $lppag); |
||
67 | $this->documento->generar_pdf_lineas( |
||
68 | $this->documento, |
||
69 | $pendiente, |
||
70 | $linea_actual, |
||
71 | $lppag, |
||
72 | 'pendiente' |
||
73 | ); |
||
74 | $this->documento->set_y($this->documento->pdf->y - 16); |
||
75 | } |
||
76 | |||
77 | $linea_actual2 = 0; |
||
78 | while ($linea_actual2 < count($pagado)) { |
||
79 | if ($linea_actual2 > 0) { |
||
80 | $this->documento->pdf->ezNewPage(); |
||
81 | } elseif ($linea_actual === 0) { |
||
82 | $this->documento->generar_pdf_cabecera($this->empresa, $lppag); |
||
83 | $this->documento->generar_datos_residente($this->documento, 'informe_cobros', $lppag); |
||
84 | } |
||
85 | $this->documento->generar_pdf_lineas( |
||
86 | $this->documento, |
||
87 | $pagado, |
||
88 | $linea_actual2, |
||
89 | $lppag, |
||
90 | 'pagado' |
||
91 | ); |
||
92 | $pagina++; |
||
93 | } |
||
94 | $this->documento->set_y(80); |
||
95 | if ($this->empresa->pie_factura) { |
||
96 | $this->documento->pdf->addText(20, 40, 8, fs_fix_html('<b>Generado por:</b> ' . |
||
97 | $this->user->get_agente_fullname()), 0); |
||
98 | $this->documento->pdf->addText( |
||
99 | 10, |
||
100 | 30, |
||
101 | 8, |
||
102 | $this->documento->center_text(fs_fix_html($this->empresa->pie_factura), 180) |
||
103 | ); |
||
104 | } |
||
105 | |||
106 | if ($this->info_accion === 'enviar') { |
||
107 | $this->documento->save('tmp/' . FS_TMP_NAME . 'enviar/' . $this->archivo); |
||
108 | $this->emailHelper->accountStatusEmail( |
||
109 | $this->empresa, |
||
110 | $this->cliente_residente, |
||
111 | $this->user, |
||
112 | $this->archivo |
||
113 | ); |
||
114 | } else { |
||
115 | $this->documento->show('documento_cobros_' . \date('dmYhis') . '.pdf'); |
||
116 | } |
||
118 | } |