Completed
Branch master (96d5ac)
by Esteban De La Fuente
38s
created
src/Sii/Dte/Documento/Builder/DocumentoFactory.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
         ;
110 110
 
111 111
         // Si el XML no tiene los tags válidos se lanza una excepción.
112
-        if ($documentoData === null) {
112
+        if ($documentoData===null) {
113 113
             throw new DocumentoException(
114 114
                 'El nodo raíz del XML del documento debe ser el tag "DTE". Dentro de este nodo raíz debe existir un tag "Documento", "Exportaciones" o "Liquidacion". Este segundo nodo es el que debe contener los datos del documento.'
115 115
             );
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
     {
218 218
         // Obtener el código del tipo de documento que se debe generar.
219 219
         $TipoDTE = $data['Encabezado']['IdDoc']['TipoDTE'] ?? null;
220
-        if ($TipoDTE === null) {
220
+        if ($TipoDTE===null) {
221 221
             throw new DocumentoException(sprintf(
222 222
                 'No se encontró el campo %s en el documento, el cual es obligatorio.',
223 223
                 'TipoDTE'
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         }
226 226
 
227 227
         // Determinar clase del "builder" en base al tipo de documento.
228
-        switch ((int) $TipoDTE) {
228
+        switch ((int)$TipoDTE) {
229 229
             case 33:
230 230
                 return FacturaAfectaBuilder::class;
231 231
             case 34:
Please login to merge, or discard this patch.
src/Sii/Dte/Documento/SobreEnvio.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -196,9 +196,9 @@  discard block
 block discarded – undo
196 196
     public function getXmlSignatureNode(): XmlSignatureNode
197 197
     {
198 198
         $tag = $this->getXmlDocument()->documentElement->tagName;
199
-        $xpath = '/*[local-name()="' . $tag . '"]/*[local-name()="Signature"]';
199
+        $xpath = '/*[local-name()="'.$tag.'"]/*[local-name()="Signature"]';
200 200
         $signatureElement = XmlUtils::xpath($this->getXmlDocument(), $xpath)->item(0);
201
-        if ($signatureElement === null) {
201
+        if ($signatureElement===null) {
202 202
             throw new SignatureException('El sobre del envío del XML no se encuentra firmado (no se encontró el nodo "Signature").');
203 203
         }
204 204
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
         }
259 259
 
260 260
         // Validar que el tipo de documento sea del tipo que se espera.
261
-        else if ($esBoleta !== (bool) $this->tipo) {
261
+        else if ($esBoleta!==(bool)$this->tipo) {
262 262
             throw new DocumentoException(
263 263
                 'No es posible mezclar DTE con BOLETA en el envío al SII.'
264 264
             );
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
         }
271 271
 
272 272
         // Validar que no se haya llenado la lista.
273
-        if (isset($this->documentos[self::CONFIG[$this->tipo]['DTE_max'] - 1])) {
273
+        if (isset($this->documentos[self::CONFIG[$this->tipo]['DTE_max']-1])) {
274 274
             throw new DocumentoException(sprintf(
275 275
                 'No es posible agregar nuevos documentos al envío al SII, límite de %d.',
276 276
                 self::CONFIG[$this->tipo]['DTE_max']
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
                         'xmlns' => 'http://www.sii.cl/SiiDte',
366 366
                         'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
367 367
                         'xsi:schemaLocation' => 'http://www.sii.cl/SiiDte '
368
-                            . self::CONFIG[$this->tipo]['schema'] . '.xsd'
368
+                            . self::CONFIG[$this->tipo]['schema'].'.xsd'
369 369
                         ,
370 370
                         'version' => '1.0',
371 371
                     ],
Please login to merge, or discard this patch.
src/Sii/Dte/Documento/AbstractDocumento.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
     {
227 227
         $data = $this->getData();
228 228
 
229
-        return (int) $data['Encabezado']['IdDoc']['Folio'];
229
+        return (int)$data['Encabezado']['IdDoc']['Folio'];
230 230
     }
231 231
 
232 232
     /**
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
      *
304 304
      * @return int|float Monto total del documento.
305 305
      */
306
-    public function getMontoTotal(): int|float
306
+    public function getMontoTotal(): int | float
307 307
     {
308 308
         $data = $this->getData();
309 309
 
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
     {
325 325
         $data = $this->getData();
326 326
 
327
-        return $index !== null
327
+        return $index!==null
328 328
             ? $data['Detalle'][$index] ?? []
329 329
             : $data['Detalle'] ?? []
330 330
         ;
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
         }
378 378
 
379 379
         // Asignar marca de tiempo si no se pasó una.
380
-        if ($timestamp === null) {
380
+        if ($timestamp===null) {
381 381
             $timestamp = date('Y-m-d\TH:i:s');
382 382
         }
383 383
 
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
     public function firmar(Certificate $certificate, ?string $timestamp = null): string
446 446
     {
447 447
         // Asignar marca de tiempo si no se pasó una.
448
-        if ($timestamp === null) {
448
+        if ($timestamp===null) {
449 449
             $timestamp = date('Y-m-d\TH:i:s');
450 450
         }
451 451
 
@@ -487,9 +487,9 @@  discard block
 block discarded – undo
487 487
     public function getXmlSignatureNode(): XmlSignatureNode
488 488
     {
489 489
         $tag = $this->getXmlDocument()->documentElement->tagName;
490
-        $xpath = '/*[local-name()="' . $tag . '"]/*[local-name()="Signature"]';
490
+        $xpath = '/*[local-name()="'.$tag.'"]/*[local-name()="Signature"]';
491 491
         $signatureElement = XmlUtils::xpath($this->getXmlDocument(), $xpath)->item(0);
492
-        if ($signatureElement === null) {
492
+        if ($signatureElement===null) {
493 493
             throw new SignatureException('El documento XML del DTE no se encuentra firmado (no se encontró el nodo "Signature").');
494 494
         }
495 495
 
Please login to merge, or discard this patch.
src/Sii/Dte/Documento/DocumentoTipo.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      *
42 42
      * @var int|string
43 43
      */
44
-    private int|string $codigo;
44
+    private int | string $codigo;
45 45
 
46 46
     /**
47 47
      * Nombre del tipo de documento.
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      * @param DataProviderInterface|null $dataProvider Proveedor de datos.
132 132
      */
133 133
     public function __construct(
134
-        int|string $codigo,
134
+        int | string $codigo,
135 135
         ?DataProviderInterface $dataProvider = null
136 136
     )
137 137
     {
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
      *
157 157
      * @return int|string
158 158
      */
159
-    public function getCodigo(): int|string
159
+    public function getCodigo(): int | string
160 160
     {
161 161
         return $this->codigo;
162 162
     }
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
      */
213 213
     public function esExportacion(): bool
214 214
     {
215
-        return $this->tag_xml === 'Exportaciones';
215
+        return $this->tag_xml==='Exportaciones';
216 216
     }
217 217
 
218 218
     /**
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
      *
254 254
      * @return integer|false
255 255
      */
256
-    public function getDefaultIndServicio(): int|false
256
+    public function getDefaultIndServicio(): int | false
257 257
     {
258 258
         return $this->esBoleta() ? 3 : false;
259 259
     }
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
      *
267 267
      * @return float|false
268 268
      */
269
-    public function getDefaultTasaIVA(): float|false
269
+    public function getDefaultTasaIVA(): float | false
270 270
     {
271 271
         $TasaIVA = 19;
272 272
         return !in_array($this->codigo, [41, 110, 111, 112]) ? $TasaIVA : false;
Please login to merge, or discard this patch.
src/Sii/Dte/AutorizacionFolio/CafFaker.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@
 block discarded – undo
140 140
      */
141 141
     public function setRangoFolios(int $desde, int $hasta): self
142 142
     {
143
-        if ($desde > $hasta) {
143
+        if ($desde>$hasta) {
144 144
             throw new CafException(sprintf(
145 145
                 'Al crear un CAF el folio desde (%d) no puede ser mayor que el folio hasta (%d).',
146 146
                 $desde,
Please login to merge, or discard this patch.
src/Sii/Dte/AutorizacionFolio/Caf.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
     {
164 164
         // Verificar firma del CAF con la clave pública del SII.
165 165
         $public_key_sii = $this->getCertificateSII();
166
-        if ($public_key_sii !== null) {
166
+        if ($public_key_sii!==null) {
167 167
             $firma = $this->getFirma();
168 168
             $signed_da = $this->xmlDocument->C14NWithIsoEncodingFlattened('/AUTORIZACION/CAF/DA');
169
-            if (openssl_verify($signed_da, base64_decode($firma), $public_key_sii) !== 1) {
169
+            if (openssl_verify($signed_da, base64_decode($firma), $public_key_sii)!==1) {
170 170
                 throw new CafException(sprintf(
171 171
                     'La firma del CAF %s no es válida (no está autorizado por el SII).',
172 172
                     $this->getID()
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
                 $this->getID()
192 192
             ));
193 193
         }
194
-        if ($test_plain !== $test_decrypted) {
194
+        if ($test_plain!==$test_decrypted) {
195 195
             throw new CafException(sprintf(
196 196
                 'El CAF %s no logró encriptar y desencriptar correctamente un texto de prueba (posible archivo CAF corrupto).',
197 197
                 $this->getID()
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         if (!isset($this->tipoDocumento)) {
245 245
             $data = $this->getData();
246 246
             $this->tipoDocumento = new DocumentoTipo(
247
-                codigo: (int) $data['AUTORIZACION']['CAF']['DA']['TD'],
247
+                codigo: (int)$data['AUTORIZACION']['CAF']['DA']['TD'],
248 248
                 dataProvider: $this->dataProvider
249 249
             );
250 250
         }
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
     {
262 262
         $data = $this->getData();
263 263
 
264
-        return (int) $data['AUTORIZACION']['CAF']['DA']['RNG']['D'];
264
+        return (int)$data['AUTORIZACION']['CAF']['DA']['RNG']['D'];
265 265
     }
266 266
 
267 267
     /**
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
     {
274 274
         $data = $this->getData();
275 275
 
276
-        return (int) $data['AUTORIZACION']['CAF']['DA']['RNG']['H'];
276
+        return (int)$data['AUTORIZACION']['CAF']['DA']['RNG']['H'];
277 277
     }
278 278
 
279 279
     /**
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
         $desde = $this->getFolioDesde();
287 287
         $hasta = $this->getFolioHasta();
288 288
 
289
-        return $hasta - $desde + 1;
289
+        return $hasta-$desde+1;
290 290
     }
291 291
 
292 292
     /**
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
      */
302 302
     public function enRango(int $folio): bool
303 303
     {
304
-        return $folio >= $this->getFolioDesde() && $folio <= $this->getFolioHasta();
304
+        return $folio>=$this->getFolioDesde() && $folio<=$this->getFolioHasta();
305 305
     }
306 306
 
307 307
     /**
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
         }
338 338
 
339 339
         // Los folios vencen en 6 meses (6 * 30 días).
340
-        return date('Y-m-d', strtotime($fecha_autorizacion. ' + 180 days'));
340
+        return date('Y-m-d', strtotime($fecha_autorizacion.' + 180 days'));
341 341
     }
342 342
 
343 343
     /**
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
         $d1 = new DateTime($this->getFechaAutorizacion());
351 351
         $d2 = new DateTime(date('Y-m-d'));
352 352
         $diff = $d1->diff($d2);
353
-        $meses = $diff->m + ($diff->y * 12);
353
+        $meses = $diff->m+($diff->y * 12);
354 354
 
355 355
         if ($diff->d) {
356 356
             $meses += round($diff->d / 30, 2);
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
             return true;
374 374
         }
375 375
 
376
-        if ($timestamp === null) {
376
+        if ($timestamp===null) {
377 377
             $timestamp = date('Y-m-d\TH:i:s');
378 378
         }
379 379
 
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
             $timestamp .= 'T00:00:00';
382 382
         }
383 383
 
384
-        return $timestamp < ($this->getFechaVencimiento() . 'T00:00:00');
384
+        return $timestamp<($this->getFechaVencimiento().'T00:00:00');
385 385
     }
386 386
 
387 387
     /**
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
     {
413 413
         $idk = $this->getIDK();
414 414
 
415
-        return $idk === CafFaker::IDK ? null : self::AMBIENTES[$idk];
415
+        return $idk===CafFaker::IDK ? null : self::AMBIENTES[$idk];
416 416
     }
417 417
 
418 418
     /**
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
     {
502 502
         $data = $this->getData();
503 503
 
504
-        return (int) $data['AUTORIZACION']['CAF']['DA']['IDK'];
504
+        return (int)$data['AUTORIZACION']['CAF']['DA']['IDK'];
505 505
     }
506 506
 
507 507
     /**
@@ -568,14 +568,14 @@  discard block
 block discarded – undo
568 568
     private function getCertificateSII(): ?string
569 569
     {
570 570
         $idk = $this->getIDK();
571
-        if ($idk === CafFaker::IDK) {
571
+        if ($idk===CafFaker::IDK) {
572 572
             return null;
573 573
         }
574 574
 
575
-        $filename = $idk . '.cer';
575
+        $filename = $idk.'.cer';
576 576
         $filepath = PathManager::getCertificatesPath($filename);
577 577
 
578
-        if ($filepath === null) {
578
+        if ($filepath===null) {
579 579
             throw new CafException(sprintf(
580 580
                 'No fue posible obtener el certificado del SII %s para validar el CAF.',
581 581
                 $filename
Please login to merge, or discard this patch.
src/Sii/HttpClient/ConnectionConfig.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
      */
123 123
     public function getAmbiente(): int
124 124
     {
125
-        return (int) $this->config['ambiente'];
125
+        return (int)$this->config['ambiente'];
126 126
     }
127 127
 
128 128
     /**
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
      */
240 240
     public function getUrl(string $recurso): string
241 241
     {
242
-        $servidor = $recurso === '/anulacionMsvDteInternet'
242
+        $servidor = $recurso==='/anulacionMsvDteInternet'
243 243
             ? $this->getServidor('www4')
244 244
             : $this->getServidor()
245 245
         ;
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
      */
255 255
     public function getDefaultCache(): string
256 256
     {
257
-        return $this->config['cache']['default'] === 'filesystem'
257
+        return $this->config['cache']['default']==='filesystem'
258 258
             ? 'filesystem'
259 259
             : 'memory'
260 260
         ;
Please login to merge, or discard this patch.
src/Sii/HttpClient/SiiClient.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -183,7 +183,7 @@
 block discarded – undo
183 183
             $defaultCache = $this->config->getDefaultCache();
184 184
 
185 185
             // Asignar una implementación de caché en el sistema de archivos.
186
-            if ($defaultCache === 'filesystem') {
186
+            if ($defaultCache==='filesystem') {
187 187
                 $adapter = new FilesystemAdapter(
188 188
                     'libredte_lib',
189 189
                     3600, // TTL por defecto a una hora (3600 segundos).
Please login to merge, or discard this patch.
src/Sii/HttpClient/WsdlConsumer.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         $token = $response['SII:RESPUESTA']['SII:RESP_BODY']['TOKEN'] ?? null;
124 124
 
125 125
         // Validar respuesta de la solicitud del token.
126
-        if ($estado !== '00' || $token === null) {
126
+        if ($estado!=='00' || $token===null) {
127 127
             $glosa = $response['SII:RESPUESTA']['SII:RESP_HDR']['GLOSA'] ?? null;
128 128
             throw new SiiClientException(sprintf(
129 129
                 'No fue posible obtener el token para autenticar en el SII al usuario %s. %s',
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
         $estado = $response['SII:RESPUESTA']['SII:RESP_HDR']['ESTADO'] ?? null;
161 161
         $semilla = $response['SII:RESPUESTA']['SII:RESP_BODY']['SEMILLA'] ?? null;
162 162
 
163
-        if ($estado !== '00' || $semilla === null) {
163
+        if ($estado!=='00' || $semilla===null) {
164 164
             throw new SiiClientException('No fue posible obtener la semilla.');
165 165
         }
166 166
 
167
-        return (int) $semilla;
167
+        return (int)$semilla;
168 168
     }
169 169
 
170 170
     /**
@@ -189,10 +189,10 @@  discard block
 block discarded – undo
189 189
         // con el servidor de pruebas (maullin.sii.cl). Estos WSDL se usan
190 190
         // siempre al solicitar el WSDL del ambiente de certificación.
191 191
         // Cambios basados en: http://stackoverflow.com/a/28464354/3333009
192
-        if ($ambiente === ConnectionConfig::CERTIFICACION) {
192
+        if ($ambiente===ConnectionConfig::CERTIFICACION) {
193 193
             $servidor = $this->config->getServidor();
194 194
             $wsdl = PathManager::getWsdlPath($servidor, $servicio);
195
-            if ($wsdl !== null) {
195
+            if ($wsdl!==null) {
196 196
                 return $wsdl;
197 197
             }
198 198
         }
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
     public function sendRequest(
224 224
         string $service,
225 225
         string $function,
226
-        array|int $args = [],
226
+        array | int $args = [],
227 227
         ?int $retry = null
228 228
     ): XmlDocument
229 229
     {
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
                 isset($e->getTrace()[0]['args'][1])
276 276
                 && is_string($e->getTrace()[0]['args'][1])
277 277
             ) {
278
-                $message .= ': ' . $e->getTrace()[0]['args'][1];
278
+                $message .= ': '.$e->getTrace()[0]['args'][1];
279 279
             }
280 280
             throw new SiiClientException(sprintf(
281 281
                 'Ocurrió un error al crear el cliente SOAP para la API del SII con el WSDL %s. %s',
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
         // del cliente SOAP preparado previamente.
305 305
         // Se realizarán $retry intentos de consulta. O sea, si $retry > 0 se
306 306
         // hará una consulta más $retry - 1 reintentos.
307
-        for ($i = 0; $i < $retry; $i++) {
307
+        for ($i = 0; $i<$retry; $i++) {
308 308
             try {
309 309
                 // Se realiza la llamada a la función en el servicio web.
310 310
                 $responseBody = $soap->__soapCall(
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
                     isset($e->getTrace()[0]['args'][1])
324 324
                     && is_string($e->getTrace()[0]['args'][1])
325 325
                 ) {
326
-                    $message .= ': ' . $e->getTrace()[0]['args'][1];
326
+                    $message .= ': '.$e->getTrace()[0]['args'][1];
327 327
                 }
328 328
                 $errors[] = sprintf(
329 329
                     'Error al ejecutar la función %s en el servicio web SOAP del SII ($i = %d): %s',
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 
342 342
         // Si la respuesta es `null` significa que ninguno de los intentos de
343 343
         // llamadas a la función del servicio web fue exitoso.
344
-        if ($responseBody === null) {
344
+        if ($responseBody===null) {
345 345
             throw new SiiClientException(sprintf(
346 346
                 'No se obtuvo respuesta de la función %s del servicio web SOAP del SII después de %d intentos. %s',
347 347
                 $function,
Please login to merge, or discard this patch.