@@ -36,7 +36,7 @@ |
||
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 | ]; |
@@ -53,8 +53,9 @@ |
||
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 | } |
@@ -42,7 +42,7 @@ |
||
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], |
@@ -317,10 +317,10 @@ discard block |
||
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 |
||
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 | /** |
@@ -164,8 +164,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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) { |
@@ -100,7 +100,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | */ |
@@ -46,10 +46,10 @@ discard block |
||
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 |
||
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 |
||
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"); |
@@ -174,12 +174,14 @@ |
||
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 | } |
@@ -68,7 +68,7 @@ |
||
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 |
@@ -66,4 +66,4 @@ |
||
66 | 66 | |
67 | 67 | // si hubo errores mostrar |
68 | 68 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
69 | - echo $error,"\n"; |
|
69 | + echo $error, "\n"; |
@@ -98,5 +98,6 @@ |
||
98 | 98 | } |
99 | 99 | |
100 | 100 | // si hubo errores mostrar |
101 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
101 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
102 | 102 | echo $error,"\n"; |
103 | +} |
@@ -66,4 +66,4 @@ |
||
66 | 66 | |
67 | 67 | // si hubo errores mostrar |
68 | 68 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
69 | - echo $error,"\n"; |
|
69 | + echo $error, "\n"; |
@@ -65,5 +65,6 @@ |
||
65 | 65 | var_dump($track_id); |
66 | 66 | |
67 | 67 | // si hubo errores mostrar |
68 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
68 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
69 | 69 | echo $error,"\n"; |
70 | +} |