Completed
Push — master ( 597d43...84d880 )
by Esteban De La Fuente
04:26
created
lib/Sii/LibroBoleta.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -170,13 +170,13 @@
 block discarded – undo
170 170
                 }
171 171
                 // determinar neto e iva
172 172
                 $tasa = \sasco\LibreDTE\Sii::getIVA();
173
-                $neto = round(($d['MntTotal'] - $d['MntExe']) / (1 + $tasa/100));
173
+                $neto = round(($d['MntTotal']-$d['MntExe']) / (1+$tasa / 100));
174 174
                 if ($neto) {
175 175
                     $resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TotMntNeto'] += $neto;
176 176
                     $resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TasaIVA'] = $tasa;
177 177
                     // WARNING: problema por aproximaciones al calcular el NETO e IVA a partir del BRUTO
178 178
                     //$resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TotMntIVA'] = round($resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TotMntNeto'] * ($tasa/100));
179
-                    $resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TotMntIVA'] = $resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TotMntTotal'] - $resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TotMntExe'] - $resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TotMntNeto'];
179
+                    $resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TotMntIVA'] = $resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TotMntTotal']-$resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TotMntExe']-$resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TotMntNeto'];
180 180
                 }
181 181
             }
182 182
             // documento anulado
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -91,8 +91,9 @@
 block discarded – undo
91 91
     public function generar()
92 92
     {
93 93
         // si ya se había generado se entrega directamente
94
-        if ($this->xml_data)
95
-            return $this->xml_data;
94
+        if ($this->xml_data) {
95
+                    return $this->xml_data;
96
+        }
96 97
         // generar XML del envío
97 98
         $xmlEnvio = (new \sasco\LibreDTE\XML())->generate([
98 99
             'LibroBoleta' => [
Please login to merge, or discard this patch.
lib/Sii/ConsumoFolio.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
     {
126 126
         $fecha = '9999-12-31';
127 127
         foreach ($this->detalles as &$d) {
128
-            if ($d['FchDoc'] < $fecha)
128
+            if ($d['FchDoc']<$fecha)
129 129
                 $fecha = $d['FchDoc'];
130 130
         }
131 131
         return $fecha;
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
     {
142 142
         $fecha = '0000-01-01';
143 143
         foreach ($this->detalles as &$d) {
144
-            if ($d['FchDoc'] > $fecha)
144
+            if ($d['FchDoc']>$fecha)
145 145
                 $fecha = $d['FchDoc'];
146 146
         }
147 147
         return $fecha;
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
         // ajustes post agregar detalles
200 200
         foreach ($Resumen as &$r) {
201 201
             // obtener folios utilizados = emitidos + anulados
202
-            $r['FoliosUtilizados'] = $r['FoliosEmitidos'] + $r['FoliosAnulados'];
202
+            $r['FoliosUtilizados'] = $r['FoliosEmitidos']+$r['FoliosAnulados'];
203 203
             $r['RangoUtilizados'] = $this->getRangos($RangoUtilizados[$r['TipoDocumento']]);
204 204
         }
205 205
         // completar con los resumenes que no se colocaron
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
         $aux = [];
232 232
         $inicial = $folios[0];
233 233
         $i = $inicial;
234
-        foreach($folios as $f) {
234
+        foreach ($folios as $f) {
235 235
             if ($i!=$f) {
236 236
                 $inicial = $f;
237 237
                 $i = $inicial;
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -90,8 +90,9 @@  discard block
 block discarded – undo
90 90
     public function generar()
91 91
     {
92 92
         // si ya se había generado se entrega directamente
93
-        if ($this->xml_data)
94
-            return $this->xml_data;
93
+        if ($this->xml_data) {
94
+                    return $this->xml_data;
95
+        }
95 96
         // generar XML del envío
96 97
         $xmlEnvio = (new \sasco\LibreDTE\XML())->generate([
97 98
             'ConsumoFolios' => [
@@ -125,8 +126,9 @@  discard block
 block discarded – undo
125 126
     {
126 127
         $fecha = '9999-12-31';
127 128
         foreach ($this->detalles as &$d) {
128
-            if ($d['FchDoc'] < $fecha)
129
-                $fecha = $d['FchDoc'];
129
+            if ($d['FchDoc'] < $fecha) {
130
+                            $fecha = $d['FchDoc'];
131
+            }
130 132
         }
131 133
         return $fecha;
132 134
     }
@@ -141,8 +143,9 @@  discard block
 block discarded – undo
141 143
     {
142 144
         $fecha = '0000-01-01';
143 145
         foreach ($this->detalles as &$d) {
144
-            if ($d['FchDoc'] > $fecha)
145
-                $fecha = $d['FchDoc'];
146
+            if ($d['FchDoc'] > $fecha) {
147
+                            $fecha = $d['FchDoc'];
148
+            }
146 149
         }
147 150
         return $fecha;
148 151
     }
Please login to merge, or discard this patch.
lib/I18n.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
 {
37 37
 
38 38
     private static $idioma = 'es'; ///< Idioma por defecto de los mensajes
39
-    private static $locales = [ ///< Mapeo de idioma a locales
39
+    private static $locales = [///< Mapeo de idioma a locales
40 40
         'es' => 'es_CL.utf8',
41 41
         'en' => 'en_US.utf8',
42 42
     ];
Please login to merge, or discard this patch.
lib/Chile.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,8 +53,9 @@
 block discarded – undo
53 53
      */
54 54
     public static function getCiudad($comuna)
55 55
     {
56
-        if (!$comuna)
57
-            return false;
56
+        if (!$comuna) {
57
+                    return false;
58
+        }
58 59
         $comuna = mb_strtoupper($comuna, 'UTF-8');
59 60
         return isset(self::$ciudades[$comuna]) ? self::$ciudades[$comuna] : false;
60 61
     }
Please login to merge, or discard this patch.
lib/Arreglo.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
     public static function mergeRecursiveDistinct(array $array1, array $array2)
43 43
     {
44 44
         $merged = $array1;
45
-        foreach ( $array2 as $key => &$value ) {
45
+        foreach ($array2 as $key => &$value) {
46 46
             if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
47 47
                 $merged [$key] = self::mergeRecursiveDistinct(
48 48
                     $merged [$key],
Please login to merge, or discard this patch.
lib/FirmaElectronica.php 3 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -317,10 +317,10 @@  discard block
 block discarded – undo
317 317
      */
318 318
     public function verify($data, $signature, $pub_key = null, $signature_alg = OPENSSL_ALGO_SHA1)
319 319
     {
320
-        if ($pub_key === null)
320
+        if ($pub_key===null)
321 321
             $pub_key = $this->certs['cert'];
322 322
         $pub_key = $this->normalizeCert($pub_key);
323
-        return openssl_verify($data, base64_decode($signature), $pub_key, $signature_alg) == 1 ? true : false;
323
+        return openssl_verify($data, base64_decode($signature), $pub_key, $signature_alg)==1 ? true : false;
324 324
     }
325 325
 
326 326
     /**
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
         } else {
452 452
             $digest_calculado = base64_encode(sha1($doc->C14N(), true));
453 453
         }
454
-        return $digest_original == $digest_calculado;
454
+        return $digest_original==$digest_calculado;
455 455
     }
456 456
 
457 457
     /**
Please login to merge, or discard this patch.
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -164,8 +164,9 @@  discard block
 block discarded – undo
164 164
      */
165 165
     public function getName()
166 166
     {
167
-        if (isset($this->data['subject']['CN']))
168
-            return $this->data['subject']['CN'];
167
+        if (isset($this->data['subject']['CN'])) {
168
+                    return $this->data['subject']['CN'];
169
+        }
169 170
         return $this->error('No fue posible obtener el Name (subject.CN) de la firma');
170 171
     }
171 172
 
@@ -177,8 +178,9 @@  discard block
 block discarded – undo
177 178
      */
178 179
     public function getEmail()
179 180
     {
180
-        if (isset($this->data['subject']['emailAddress']))
181
-            return $this->data['subject']['emailAddress'];
181
+        if (isset($this->data['subject']['emailAddress'])) {
182
+                    return $this->data['subject']['emailAddress'];
183
+        }
182 184
         return $this->error('No fue posible obtener el Email (subject.emailAddress) de la firma');
183 185
     }
184 186
 
@@ -317,8 +319,9 @@  discard block
 block discarded – undo
317 319
      */
318 320
     public function verify($data, $signature, $pub_key = null, $signature_alg = OPENSSL_ALGO_SHA1)
319 321
     {
320
-        if ($pub_key === null)
321
-            $pub_key = $this->certs['cert'];
322
+        if ($pub_key === null) {
323
+                    $pub_key = $this->certs['cert'];
324
+        }
322 325
         $pub_key = $this->normalizeCert($pub_key);
323 326
         return openssl_verify($data, base64_decode($signature), $pub_key, $signature_alg) == 1 ? true : false;
324 327
     }
@@ -409,8 +412,9 @@  discard block
 block discarded – undo
409 412
         // calcular SignatureValue
410 413
         $SignedInfo = $doc->saveHTML($Signature->getElementsByTagName('SignedInfo')->item(0));
411 414
         $firma = $this->sign($SignedInfo);
412
-        if (!$firma)
413
-            return false;
415
+        if (!$firma) {
416
+                    return false;
417
+        }
414 418
         $signature = wordwrap($firma, $this->config['wordwrap'], "\n", true);
415 419
         // reemplazar valores en la firma de
416 420
         $Signature->getElementsByTagName('SignatureValue')->item(0)->nodeValue = $signature;
@@ -442,8 +446,9 @@  discard block
 block discarded – undo
442 446
         $signature = $Signature->getElementsByTagName('SignatureValue')->item(0)->nodeValue;
443 447
         $pub_key = $Signature->getElementsByTagName('X509Certificate')->item(0)->nodeValue;
444 448
         // verificar firma
445
-        if (!$this->verify($signed_info, $signature, $pub_key))
446
-            return false;
449
+        if (!$this->verify($signed_info, $signature, $pub_key)) {
450
+                    return false;
451
+        }
447 452
         // verificar digest
448 453
         $digest_original = $Signature->getElementsByTagName('DigestValue')->item(0)->nodeValue;
449 454
         if ($tag) {
Please login to merge, or discard this patch.
Doc Comments   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     /**
101 101
      * Método para generar un error usando una excepción de SowerPHP o terminar
102 102
      * el script si no se está usando el framework
103
-     * @param msg Mensaje del error
103
+     * @param msg string del error
104 104
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
105 105
      * @version 2017-08-04
106 106
      */
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 
189 189
     /**
190 190
      * Método que entrega desde cuando es válida la firma
191
-     * @return validFrom_time_t
191
+     * @return string
192 192
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
193 193
      * @version 2015-09-22
194 194
      */
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 
200 200
     /**
201 201
      * Método que entrega hasta cuando es válida la firma
202
-     * @return validTo_time_t
202
+     * @return string
203 203
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
204 204
      * @version 2015-09-22
205 205
      */
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 
233 233
     /**
234 234
      * Método que obtiene el módulo de la clave privada
235
-     * @return Módulo en base64
235
+     * @return string en base64
236 236
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
237 237
      * @version 2014-12-07
238 238
      */
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 
245 245
     /**
246 246
      * Método que obtiene el exponente público de la clave privada
247
-     * @return Exponente público en base64
247
+     * @return string público en base64
248 248
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
249 249
      * @version 2014-12-06
250 250
      */
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
 
295 295
     /**
296 296
      * Método para realizar la firma de datos
297
-     * @param data Datos que se desean firmar
297
+     * @param data string que se desean firmar
298 298
      * @param signature_alg Algoritmo que se utilizará para firmar (por defect SHA1)
299
-     * @return Firma digital de los datos en base64 o =false si no se pudo firmar
299
+     * @return boolean|string digital de los datos en base64 o =false si no se pudo firmar
300 300
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
301 301
      * @version 2014-12-08
302 302
      */
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 
312 312
     /**
313 313
      * Método que verifica la firma digital de datos
314
-     * @param data Datos que se desean verificar
314
+     * @param data string que se desean verificar
315 315
      * @param signature Firma digital de los datos en base64
316 316
      * @param pub_key Certificado digital, clave pública, de la firma
317 317
      * @param signature_alg Algoritmo que se usó para firmar (por defect SHA1)
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
      *
335 335
      * @param xml Datos XML que se desean firmar
336 336
      * @param reference Referencia a la que hace la firma
337
-     * @return XML firmado o =false si no se pudo fimar
337
+     * @return boolean|string firmado o =false si no se pudo fimar
338 338
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
339 339
      * @version 2017-10-22
340 340
      */
Please login to merge, or discard this patch.
lib/CSV.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public static function read($archivo, $separador = ';', $delimitadortexto = '"')
48 48
     {
49
-        if (($handle = fopen($archivo, 'r')) !== FALSE) {
49
+        if (($handle = fopen($archivo, 'r'))!==FALSE) {
50 50
             $data = array();
51 51
             $i = 0;
52
-            while (($row = fgetcsv($handle, 0, $separador, $delimitadortexto)) !== FALSE) {
52
+            while (($row = fgetcsv($handle, 0, $separador, $delimitadortexto))!==FALSE) {
53 53
                 $j = 0;
54 54
                 foreach ($row as &$col) {
55 55
                     $data[$i][$j++] = $col;
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
         header('Content-Disposition: attachment; filename='.$archivo.'.csv');
78 78
         header('Pragma: no-cache');
79 79
         header('Expires: 0');
80
-        foreach($data as &$row) {
81
-            foreach($row as &$col) {
80
+        foreach ($data as &$row) {
81
+            foreach ($row as &$col) {
82 82
                 $col = $delimitadortexto.rtrim(str_replace('<br />', ', ', strip_tags($col, '<br>')), " \t\n\r\0\x0B,").$delimitadortexto;
83 83
             }
84
-            echo implode($separador, $row),"\r\n";
84
+            echo implode($separador, $row), "\r\n";
85 85
             unset($row);
86 86
         }
87 87
         unset($data);
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
     public static function save(array $data, $archivo, $separador = ';', $delimitadortexto = '"')
101 101
     {
102 102
         $fd = fopen($archivo, 'w');
103
-        foreach($data as &$row) {
104
-            foreach($row as &$col) {
103
+        foreach ($data as &$row) {
104
+            foreach ($row as &$col) {
105 105
                 $col = $delimitadortexto.rtrim(str_replace('<br />', ', ', strip_tags($col, '<br>')), " \t\n\r\0\x0B,").$delimitadortexto;
106 106
             }
107 107
             fwrite($fd, implode($separador, $row)."\r\n");
Please login to merge, or discard this patch.
lib/Estado.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -174,12 +174,14 @@
 block discarded – undo
174 174
     public static function get($codigo, $args = null)
175 175
     {
176 176
         // si no hay glosa asociada al código se entrega el mismo código
177
-        if (!isset(self::$glosas[(int)$codigo]))
178
-            return (int)$codigo;
177
+        if (!isset(self::$glosas[(int)$codigo])) {
178
+                    return (int)$codigo;
179
+        }
179 180
         // si los argumentos no son un arreglo se obtiene arreglo a partir
180 181
         // de los argumentos pasados a la función
181
-        if (!is_array($args))
182
-            $args = array_slice(func_get_args(), 1);
182
+        if (!is_array($args)) {
183
+                    $args = array_slice(func_get_args(), 1);
184
+        }
183 185
         // entregar glosa
184 186
         return vsprintf(I18n::translate(self::$glosas[(int)$codigo], 'estados'), $args);
185 187
     }
Please login to merge, or discard this patch.
lib/Sii/Factoring/DteCedido.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
68 68
 
69 69
     /**
70 70
      * Método que realiza la firma del DTE cedido
71
-     * @param Firma objeto que representa la Firma Electrónca
71
+     * @param Firma \sasco\LibreDTE\FirmaElectronica que representa la Firma Electrónca
72 72
      * @return =true si el DTE pudo ser fimado o =false si no se pudo firmar
73 73
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
74 74
      * @version 2016-12-10
Please login to merge, or discard this patch.