Completed
Push — master ( 16d8fe...3ff991 )
by Esteban De La Fuente
37s
created
lib/Sii/Certificacion/SetPruebas.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
                         // buscar el caso y copiar sus columnas que no estén
263 263
                         $detalle_r = $documentos[$caso['referencia']['caso']]['Detalle'];
264 264
                         $n_detalle_r = count($detalle_r);
265
-                        for ($i=0; $i<$n_detalle_r; $i++) {
265
+                        for ($i = 0; $i<$n_detalle_r; $i++) {
266 266
                             if ($detalle_r[$i]['NmbItem']==$detalle['NmbItem']) {
267 267
                                 foreach ($detalle_r[$i] as $attr => $val) {
268 268
                                     if (!isset($detalle[$attr]))
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
                 $documento['DscRcgGlobal'][] = [
326 326
                     'TpoMov' => 'R',
327 327
                     'TpoValor' => '$',
328
-                    'ValorDR' => round((substr($caso['recargo-total-clausula'], 0, -1)/100) * $documento['Encabezado']['Transporte']['Aduana']['TotClauVenta'], 2),
328
+                    'ValorDR' => round((substr($caso['recargo-total-clausula'], 0, -1) / 100) * $documento['Encabezado']['Transporte']['Aduana']['TotClauVenta'], 2),
329 329
                 ];
330 330
             }
331 331
             // agregar recargo por flete y/o seguro, se agrega sólo en factura
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
         $casos = explode($separador, $archivo);
467 467
         $separador_len = strlen($separador);
468 468
         $n_casos = count($casos);
469
-        for ($i=1; $i<$n_casos; $i++) {
469
+        for ($i = 1; $i<$n_casos; $i++) {
470 470
             $caso = trim($casos[$i]);
471 471
             $caso_anterior = trim($casos[$i-1]);
472 472
             $caso_titulo = substr($caso_anterior, -$separador_len);
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
                 $titulos = array_slice(array_filter(explode("\t", $lineas[$linea_titulos_detalles])), 0);
524 524
                 // extraer detalles
525 525
                 $datos['detalle'] = [];
526
-                $i = $linea_titulos_detalles + 1;
526
+                $i = $linea_titulos_detalles+1;
527 527
                 while (!empty($lineas[$i])) {
528 528
                     $item = array_slice(array_filter(explode("\t", $lineas[$i])), 0);
529 529
                     $n_item = count($item);
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
                 // sólo continuar si hay más líneas, será, por ej, el descuento global
538 538
                 if (isset($lineas[$i])) {
539 539
                     $n_lineas = count($lineas);
540
-                    for ($i=$i; $i<$n_lineas; $i++) {
540
+                    for ($i = $i; $i<$n_lineas; $i++) {
541 541
                         // si la línea está vacía se omite
542 542
                         if (!$lineas[$i])
543 543
                             continue;
Please login to merge, or discard this patch.
Braces   +46 added lines, -32 removed lines patch added patch discarded remove patch
@@ -154,8 +154,9 @@  discard block
 block discarded – undo
154 154
         foreach ($casos as $caso) {
155 155
             // determinar tipo documento y folio
156 156
             $TipoDTE = self::$tipos[$caso['documento']];
157
-            if (!isset($folios[$TipoDTE]))
158
-                $folios[$TipoDTE] = 1;
157
+            if (!isset($folios[$TipoDTE])) {
158
+                            $folios[$TipoDTE] = 1;
159
+            }
159 160
             $Folio = $folios[$TipoDTE];
160 161
             // crear encabezado del documento
161 162
             $documento = [
@@ -257,14 +258,17 @@  discard block
 block discarded – undo
257 258
                     foreach ($item as $col => $val) {
258 259
                         $col = self::$item_cols[$col];
259 260
                         // procesar cada valor de acuerdo al nombre de la columna
260
-                        if (in_array($col, ['DescuentoPct', 'RecargoPct']))
261
-                            $detalle[$col] = substr($val, 0, -1);
262
-                        else
263
-                            $detalle[$col] = utf8_encode($val); // se convierte de ISO-8859-1 a UTF-8
261
+                        if (in_array($col, ['DescuentoPct', 'RecargoPct'])) {
262
+                                                    $detalle[$col] = substr($val, 0, -1);
263
+                        } else {
264
+                                                    $detalle[$col] = utf8_encode($val);
265
+                        }
266
+                        // se convierte de ISO-8859-1 a UTF-8
264 267
                     }
265 268
                     // si el item es EXENTO se agrega campo que lo indica
266
-                    if (strpos($detalle['NmbItem'], 'EXENTO'))
267
-                        $detalle['IndExe'] = 1;
269
+                    if (strpos($detalle['NmbItem'], 'EXENTO')) {
270
+                                            $detalle['IndExe'] = 1;
271
+                    }
268 272
                     // si hay una referencia se completa con los campos del
269 273
                     // detalle de la referencia que no estén en este detalle
270 274
                     if (!empty($caso['referencia'])) {
@@ -274,8 +278,9 @@  discard block
 block discarded – undo
274 278
                         for ($i=0; $i<$n_detalle_r; $i++) {
275 279
                             if ($detalle_r[$i]['NmbItem']==$detalle['NmbItem']) {
276 280
                                 foreach ($detalle_r[$i] as $attr => $val) {
277
-                                    if (!isset($detalle[$attr]))
278
-                                        $detalle[$attr] = $val;
281
+                                    if (!isset($detalle[$attr])) {
282
+                                                                            $detalle[$attr] = $val;
283
+                                    }
279 284
                                 }
280 285
                             }
281 286
                         }
@@ -359,8 +364,9 @@  discard block
 block discarded – undo
359 364
                     'ValorDR' => substr($caso['recargo'], 0, -1),
360 365
                 ];
361 366
             }
362
-            if (empty($documento['DscRcgGlobal']))
363
-                unset($documento['DscRcgGlobal']);
367
+            if (empty($documento['DscRcgGlobal'])) {
368
+                            unset($documento['DscRcgGlobal']);
369
+            }
364 370
             // agregar descuento del documento de la referencia
365 371
             else if (!empty($caso['referencia'])) {
366 372
                 $referencia = self::getReferencia($caso['referencia']['razon']);
@@ -392,14 +398,16 @@  discard block
 block discarded – undo
392 398
                 // agregar totales
393 399
                 $documento['Encabezado']['Totales'] = $referencia['Totales'];
394 400
                 // agregar tasa de IVA si corresponde
395
-                if (isset($documento['Encabezado']['Totales']['TasaIVA']))
396
-                    $documento['Encabezado']['Totales']['TasaIVA'] = \sasco\LibreDTE\Sii::getIVA();
401
+                if (isset($documento['Encabezado']['Totales']['TasaIVA'])) {
402
+                                    $documento['Encabezado']['Totales']['TasaIVA'] = \sasco\LibreDTE\Sii::getIVA();
403
+                }
397 404
                 // si el documento referenciado es factura exenta y hay MntExe
398 405
                 if (isset($documento['Encabezado']['Totales']['MntExe'])) {
399
-                    if ($documentos[$caso['referencia']['caso']]['Encabezado']['IdDoc']['TipoDTE']==34)
400
-                        $documento['Encabezado']['Totales']['MntExe'] = 0;
401
-                    else
402
-                        unset($documento['Encabezado']['Totales']['MntExe']);
406
+                    if ($documentos[$caso['referencia']['caso']]['Encabezado']['IdDoc']['TipoDTE']==34) {
407
+                                            $documento['Encabezado']['Totales']['MntExe'] = 0;
408
+                    } else {
409
+                                            unset($documento['Encabezado']['Totales']['MntExe']);
410
+                    }
403 411
                 }
404 412
                 // si es documento de exportación se resetean los totales y se copia el tipo de moneda si no existe
405 413
                 if (in_array($documento['Encabezado']['IdDoc']['TipoDTE'], [111, 112])) {
@@ -412,8 +420,9 @@  discard block
 block discarded – undo
412 420
             }
413 421
             // agregar referencia de exportación si existe
414 422
             if (!empty($caso['exportacion']['REFERENCIA'])) {
415
-                if (!is_array($caso['exportacion']['REFERENCIA']))
416
-                    $caso['exportacion']['REFERENCIA'] = [$caso['exportacion']['REFERENCIA']];
423
+                if (!is_array($caso['exportacion']['REFERENCIA'])) {
424
+                                    $caso['exportacion']['REFERENCIA'] = [$caso['exportacion']['REFERENCIA']];
425
+                }
417 426
                 foreach ($caso['exportacion']['REFERENCIA'] as $ref) {
418 427
                     $documento['Referencia'][] = [
419 428
                         'TpoDocRef' => self::$referencias_exportacion[$ref],
@@ -433,14 +442,16 @@  discard block
 block discarded – undo
433 442
             if (isset($documento['Encabezado']['Totales'])) {
434 443
                 $hayValor = false;
435 444
                 foreach ($documento['Detalle'] as $d) {
436
-                    if (!empty($d['PrcItem']))
437
-                        $hayValor = true;
445
+                    if (!empty($d['PrcItem'])) {
446
+                                            $hayValor = true;
447
+                    }
438 448
                 }
439 449
                 if (!$hayValor) {
440
-                    if (isset($documento['Encabezado']['Totales']['MntExe']))
441
-                        $documento['Encabezado']['Totales'] = ['MntExe'=>0];
442
-                    else
443
-                        $documento['Encabezado']['Totales'] = [];
450
+                    if (isset($documento['Encabezado']['Totales']['MntExe'])) {
451
+                                            $documento['Encabezado']['Totales'] = ['MntExe'=>0];
452
+                    } else {
453
+                                            $documento['Encabezado']['Totales'] = [];
454
+                    }
444 455
                     $documento['Encabezado']['Totales']['MntTotal'] = 0;
445 456
                 }
446 457
             }
@@ -548,8 +559,9 @@  discard block
 block discarded – undo
548 559
                     $n_lineas = count($lineas);
549 560
                     for ($i=$i; $i<$n_lineas; $i++) {
550 561
                         // si la línea está vacía se omite
551
-                        if (!$lineas[$i])
552
-                            continue;
562
+                        if (!$lineas[$i]) {
563
+                                                    continue;
564
+                        }
553 565
                         // si hay descuento global se guarda
554 566
                         if (strpos($lineas[$i], 'DESCUENTO GLOBAL ITEMES AFECTOS')===0) {
555 567
                             $aux = explode("\t", $lineas[$i]);
@@ -585,13 +597,15 @@  discard block
 block discarded – undo
585 597
                                 }
586 598
                                 // agregar a los datos de aduanas
587 599
                                 else {
588
-                                    if (!isset($datos['exportacion']))
589
-                                        $datos['exportacion'] = [];
600
+                                    if (!isset($datos['exportacion'])) {
601
+                                                                            $datos['exportacion'] = [];
602
+                                    }
590 603
                                     if (!isset($datos['exportacion'][$var])) {
591 604
                                         $datos['exportacion'][$var] = $val;
592 605
                                     } else {
593
-                                        if (!is_array($datos['exportacion'][$var]))
594
-                                            $datos['exportacion'][$var] = [$datos['exportacion'][$var]];
606
+                                        if (!is_array($datos['exportacion'][$var])) {
607
+                                                                                    $datos['exportacion'][$var] = [$datos['exportacion'][$var]];
608
+                                        }
595 609
                                         $datos['exportacion'][$var][] = $val;
596 610
                                     }
597 611
                                 }
Please login to merge, or discard this patch.
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/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 2 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   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -168,8 +168,9 @@  discard block
 block discarded – undo
168 168
      */
169 169
     public function getName()
170 170
     {
171
-        if (isset($this->data['subject']['CN']))
172
-            return $this->data['subject']['CN'];
171
+        if (isset($this->data['subject']['CN'])) {
172
+                    return $this->data['subject']['CN'];
173
+        }
173 174
         return $this->error('No fue posible obtener el Name (subject.CN) de la firma');
174 175
     }
175 176
 
@@ -353,8 +354,9 @@  discard block
 block discarded – undo
353 354
      */
354 355
     public function verify($data, $signature, $pub_key = null, $signature_alg = OPENSSL_ALGO_SHA1)
355 356
     {
356
-        if ($pub_key === null)
357
-            $pub_key = $this->certs['cert'];
357
+        if ($pub_key === null) {
358
+                    $pub_key = $this->certs['cert'];
359
+        }
358 360
         $pub_key = $this->normalizeCert($pub_key);
359 361
         return openssl_verify($data, base64_decode($signature), $pub_key, $signature_alg) == 1 ? true : false;
360 362
     }
@@ -453,8 +455,9 @@  discard block
 block discarded – undo
453 455
         // calcular SignatureValue
454 456
         $SignedInfo = $doc->saveHTML($Signature->getElementsByTagName('SignedInfo')->item(0));
455 457
         $firma = $this->sign($SignedInfo);
456
-        if (!$firma)
457
-            return false;
458
+        if (!$firma) {
459
+                    return false;
460
+        }
458 461
         $signature = wordwrap($firma, $this->config['wordwrap'], "\n", true);
459 462
         // reemplazar valores en la firma de
460 463
         $Signature->getElementsByTagName('SignatureValue')->item(0)->nodeValue = $signature;
@@ -486,8 +489,9 @@  discard block
 block discarded – undo
486 489
         $signature = $Signature->getElementsByTagName('SignatureValue')->item(0)->nodeValue;
487 490
         $pub_key = $Signature->getElementsByTagName('X509Certificate')->item(0)->nodeValue;
488 491
         // verificar firma
489
-        if (!$this->verify($signed_info, $signature, $pub_key))
490
-            return false;
492
+        if (!$this->verify($signed_info, $signature, $pub_key)) {
493
+                    return false;
494
+        }
491 495
         // verificar digest
492 496
         $digest_original = $Signature->getElementsByTagName('DigestValue')->item(0)->nodeValue;
493 497
         if ($tag) {
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/File.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -49,18 +49,18 @@  discard block
 block discarded – undo
49 49
     public static function rmdir($dir)
50 50
     {
51 51
         // List the contents of the directory table
52
-        $dir_content = scandir ($dir);
52
+        $dir_content = scandir($dir);
53 53
         // Is it a directory?
54 54
         if ($dir_content!==false) {
55 55
             // For each directory entry
56 56
             foreach ($dir_content as &$entry) {
57 57
                 // Unix symbolic shortcuts, we go
58
-                if (!in_array ($entry, array ('.','..'))) {
58
+                if (!in_array($entry, array('.', '..'))) {
59 59
                     // We find the path from the beginning
60
-                    $entry = $dir.DIRECTORY_SEPARATOR. $entry;
60
+                    $entry = $dir.DIRECTORY_SEPARATOR.$entry;
61 61
                     // This entry is not an issue: it clears
62 62
                     if (!is_dir($entry)) {
63
-                        unlink ($entry);
63
+                        unlink($entry);
64 64
                     } else { // This entry is a folder, it again on this issue
65 65
                         self::rmdir($entry);
66 66
                     }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
             }
69 69
         }
70 70
         // It has erased all entries in the folder, we can now erase
71
-        rmdir ($dir);
71
+        rmdir($dir);
72 72
     }
73 73
 
74 74
     /**
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
         // enviar archivo
161 161
         if ($options['download']) {
162 162
             ob_clean();
163
-            header ('Content-Disposition: attachment; filename='.$file_compressed);
163
+            header('Content-Disposition: attachment; filename='.$file_compressed);
164 164
             $mimetype = self::mimetype($dir.DIRECTORY_SEPARATOR.$file_compressed);
165 165
             if ($mimetype)
166
-                header ('Content-Type: '.$mimetype);
167
-            header ('Content-Length: '.filesize($dir.DIRECTORY_SEPARATOR.$file_compressed));
166
+                header('Content-Type: '.$mimetype);
167
+            header('Content-Length: '.filesize($dir.DIRECTORY_SEPARATOR.$file_compressed));
168 168
             readfile($dir.DIRECTORY_SEPARATOR.$file_compressed);
169 169
             unlink($dir.DIRECTORY_SEPARATOR.$file_compressed);
170 170
         }
Please login to merge, or discard this patch.
Braces   +16 added lines, -8 removed lines patch added patch discarded remove patch
@@ -80,8 +80,9 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public static function mimetype($file)
82 82
     {
83
-        if (!function_exists('finfo_open'))
84
-            return false;
83
+        if (!function_exists('finfo_open')) {
84
+                    return false;
85
+        }
85 86
         $finfo = finfo_open(FILEINFO_MIME_TYPE);
86 87
         $mimetype = finfo_file($finfo, $file);
87 88
         finfo_close($finfo);
@@ -121,8 +122,11 @@  discard block
 block discarded – undo
121 122
         }
122 123
         // si es formato gz y es directorio se cambia a tgz
123 124
         if (is_dir($file)) {
124
-            if ($options['format']=='gz') $options['format'] = 'tar.gz';
125
-            else if ($options['format']=='bz2') $options['format'] = 'tar.bz2';
125
+            if ($options['format']=='gz') {
126
+                $options['format'] = 'tar.gz';
127
+            } else if ($options['format']=='bz2') {
128
+                $options['format'] = 'tar.bz2';
129
+            }
126 130
         }
127 131
         // obtener directorio que contiene al archivo/directorio y el nombre de este
128 132
         $filepath = $file;
@@ -162,8 +166,9 @@  discard block
 block discarded – undo
162 166
             ob_clean();
163 167
             header ('Content-Disposition: attachment; filename='.$file_compressed);
164 168
             $mimetype = self::mimetype($dir.DIRECTORY_SEPARATOR.$file_compressed);
165
-            if ($mimetype)
166
-                header ('Content-Type: '.$mimetype);
169
+            if ($mimetype) {
170
+                            header ('Content-Type: '.$mimetype);
171
+            }
167 172
             header ('Content-Length: '.filesize($dir.DIRECTORY_SEPARATOR.$file_compressed));
168 173
             readfile($dir.DIRECTORY_SEPARATOR.$file_compressed);
169 174
             unlink($dir.DIRECTORY_SEPARATOR.$file_compressed);
@@ -171,8 +176,11 @@  discard block
 block discarded – undo
171 176
         // borrar directorio o archivo que se está comprimiendo si así se ha
172 177
         // solicitado
173 178
         if ($options['delete']) {
174
-            if (is_dir($filepath)) self::rmdir($filepath);
175
-            else unlink($filepath);
179
+            if (is_dir($filepath)) {
180
+                self::rmdir($filepath);
181
+            } else {
182
+                unlink($filepath);
183
+            }
176 184
         }
177 185
     }
178 186
 
Please login to merge, or discard this patch.