Completed
Branch master (96d5ac)
by Esteban De La Fuente
38s
created
src/Sii/HttpClient/WebService/DocumentUploadStatusResponse.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
             // RUT de la empresa que realizó la consulta del envío.
120 120
             $company = isset($this->requestData['Rut']) && isset($this->requestData['Dv'])
121
-                ? $this->requestData['Rut'] . '-' . $this->requestData['Dv']
121
+                ? $this->requestData['Rut'].'-'.$this->requestData['Dv']
122 122
                 : null
123 123
             ;
124 124
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     {
158 158
         $data = $this->getData();
159 159
 
160
-        if ($data['status'] === 'EPR') {
160
+        if ($data['status']==='EPR') {
161 161
             if ($this->hasRejectedDocuments()) {
162 162
                 return 'RCH - DTE Rechazado';
163 163
             }
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         }
169 169
 
170 170
         return $data['description']
171
-            ? ($data['status'] . ' - ' . $data['description'])
171
+            ? ($data['status'].' - '.$data['description'])
172 172
             : $data['status']
173 173
         ;
174 174
     }
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
     {
183 183
         $data = $this->getData();
184 184
 
185
-        if ($data['status'] === 'EPR') {
185
+        if ($data['status']==='EPR') {
186 186
             if ($this->allDocumentsAreAccepted()) {
187 187
                 return 'DTE aceptado';
188 188
             }
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
     {
201 201
         $data = $this->getData();
202 202
 
203
-        return $data['resume']['reported'] === $data['resume']['accepted'];
203
+        return $data['resume']['reported']===$data['resume']['accepted'];
204 204
     }
205 205
 
206 206
     /**
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
     {
213 213
         $data = $this->getData();
214 214
 
215
-        return $data['resume']['rejected'] > 0;
215
+        return $data['resume']['rejected']>0;
216 216
     }
217 217
 
218 218
     /**
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
     {
225 225
         $data = $this->getData();
226 226
 
227
-        return $data['resume']['repairs'] > 0;
227
+        return $data['resume']['repairs']>0;
228 228
     }
229 229
 
230 230
     /**
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
         // es un estado de error en el envío. Se valida esto primero pues es lo
246 246
         // que normalmente debería entregar el SII en la respuesta.
247 247
         if (isset(self::STATUSES[$status])) {
248
-            $error = $status[0] === 'R';
248
+            $error = $status[0]==='R';
249 249
             $description = $headers['GLOSA'] ?? null;
250 250
         }
251 251
 
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 
258 258
         // El error es uno de los números negativos. Donde hay 3 opciones:
259 259
         // El error es -11 y puede ser uno de los 3 que detalla -11.
260
-        else if ($status == '-11') {
260
+        else if ($status=='-11') {
261 261
             $errors = [];
262 262
             foreach (['SRV_CODE', 'SQL_CODE', 'ERR_CODE'] as $errorType) {
263 263
                 if (isset($headers[$errorType])) {
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
         // Iterar y armar estado de los documentos.
324 324
         $n_documents = count($body[$keys[0]]);
325 325
         $documents = [];
326
-        for ($i = 0; $i < $n_documents; $i++) {
326
+        for ($i = 0; $i<$n_documents; $i++) {
327 327
             $document = [];
328 328
             foreach ($keysMap as $source => $destination) {
329 329
                 $document[$destination] = $body[$source][$i];
Please login to merge, or discard this patch.
src/Sii/HttpClient/WebService/DocumentUploadStatusEmailResponse.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@
 block discarded – undo
75 75
             ;
76 76
             $company = $rutExists
77 77
                 ? $this->requestData['RutEmpresa']
78
-                    . '-' . $this->requestData['DvEmpresa']
78
+                    . '-'.$this->requestData['DvEmpresa']
79 79
                 : null
80 80
             ;
81 81
 
Please login to merge, or discard this patch.
src/Sii/HttpClient/WebService/DocumentSignatureStatusResponse.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
             ;
125 125
             $company = $rutExists
126 126
                 ? $this->requestData['RutCompania']
127
-                    . '-' . $this->requestData['DvCompania']
127
+                    . '-'.$this->requestData['DvCompania']
128 128
                 : null
129 129
             ;
130 130
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
             ;
135 135
             $recipient = $rutExists
136 136
                 ? $this->requestData['RutReceptor']
137
-                    . '-' . $this->requestData['DvReceptor']
137
+                    . '-'.$this->requestData['DvReceptor']
138 138
                 : null
139 139
             ;
140 140
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
         // Asignar el código del estado y asumir que hubo error en la
179 179
         // validación del documento por parte del SII.
180 180
         $status = $headers['ESTADO'] ?? $body['ESTADO'] ?? $headers['SII:ESTADO'];
181
-        $received = ($body['RECIBIDO'] ?? 'NO') === 'SI';
181
+        $received = ($body['RECIBIDO'] ?? 'NO')==='SI';
182 182
         $description = null;
183 183
 
184 184
         // Verificar si el estado es uno de los estados "normales", o sea, no
Please login to merge, or discard this patch.
src/Sii/HttpClient/WebService/AbstractWebServiceResponse.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -150,12 +150,12 @@
 block discarded – undo
150 150
             $number = $matches[1];
151 151
 
152 152
             // Formato ISO: YYYY/MM/DDTHH:MM:SS
153
-            $datetime = $matches[2] . 'T' . $matches[3];
153
+            $datetime = $matches[2].'T'.$matches[3];
154 154
 
155 155
             // Convertir la fecha al formato ISO con guiones en vez de barras
156 156
             $datetimeISO = str_replace('/', '-', $datetime);
157 157
 
158
-            return [(int) $number, $datetimeISO];
158
+            return [(int)$number, $datetimeISO];
159 159
         }
160 160
 
161 161
         // Si el formato es incorrecto, lanzar una excepción.
Please login to merge, or discard this patch.
src/Sii/HttpClient/WebService/DocumentValidator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 
226 226
         // Validar fecha y convertir al formato del SII.
227 227
         $dateSii = Date::validateAndConvert($date, 'dmY');
228
-        if ($dateSii === null) {
228
+        if ($dateSii===null) {
229 229
             throw new SiiClientException(sprintf(
230 230
                 'La fecha %s del documento no es válida, debe tener formato AAAA-MM-DD.',
231 231
                 $date
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 
313 313
         // Validar fecha y convertir al formato del SII.
314 314
         $dateSii = Date::validateAndConvert($date, 'dmY');
315
-        if ($dateSii === null) {
315
+        if ($dateSii===null) {
316 316
             throw new SiiClientException(sprintf(
317 317
                 'La fecha %s del documento no es válida, debe tener formato AAAA-MM-DD.',
318 318
                 $date
Please login to merge, or discard this patch.
src/Sii/HttpClient/WebService/DocumentUploader.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     {
100 100
         // Crear string del documento XML.
101 101
         $xml = $doc->saveXML();
102
-        if (empty($xml) || $xml == '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n") {
102
+        if (empty($xml) || $xml=='<?xml version="1.0" encoding="ISO-8859-1"?>'."\n") {
103 103
             throw new SiiClientException(
104 104
                 'El XML que se desea enviar al SII no puede ser vacío.'
105 105
             );
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
         // Crear el archivo que se enviará en el sistema de archivos para poder
116 116
         // adjuntarlo en la solicitud mediante curl al SII.
117 117
         [$filepath, $mimetype] = $this->createXmlFile($xml, $compress);
118
-        $filename = $company . '_' . basename($filepath);
118
+        $filename = $company.'_'.basename($filepath);
119 119
 
120 120
         // Preparar los datos que se enviarán mediante POST al SII.
121 121
         $data = [
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 
145 145
         // Entregar el número de seguimiendo (Track ID) del envío al SII.
146 146
         $trackId = $response['RECEPCIONDTE']['TRACKID'] ?? 0;
147
-        return (int) $trackId;
147
+        return (int)$trackId;
148 148
     }
149 149
 
150 150
     /**
@@ -162,14 +162,14 @@  discard block
 block discarded – undo
162 162
         // indicaría que el SII no contestó correctamente a la solicitud o bien
163 163
         // la misma solicitud se hizo de manera incorrecta produciendo que el
164 164
         // SII no contestase adecuadamente.
165
-        if ($status === null) {
165
+        if ($status===null) {
166 166
             throw new SiiClientException(
167 167
                 'La respuesta del envío del XML al SII no trae un código de estado válido.'
168 168
             );
169 169
         }
170 170
 
171 171
         // Si el estado es 0, el envío fue OK.
172
-        if ($status == 0) {
172
+        if ($status==0) {
173 173
             return;
174 174
         }
175 175
 
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
 
219 219
         // Ver si vienen detalles del error.
220 220
         $error = $response['DETAIL']['ERROR'] ?? null;
221
-        if ($error !== null) {
222
-            $message .= ' ' . implode(' ',  $error);
221
+        if ($error!==null) {
222
+            $message .= ' '.implode(' ', $error);
223 223
         }
224 224
 
225 225
         // Lanzar una excepción con el mensaje de error determinado.
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
         $headers = [
254 254
             'User-Agent: Mozilla/4.0 (compatible; PROG 1.0; LibreDTE)',
255 255
             'Referer: https://www.libredte.cl',
256
-            'Cookie: TOKEN=' . $token,
256
+            'Cookie: TOKEN='.$token,
257 257
         ];
258 258
 
259 259
         // Inicializar curl.
@@ -273,14 +273,14 @@  discard block
 block discarded – undo
273 273
 
274 274
         // Realizar el envío del XML al SII con $retry intentos.
275 275
         $responseBody = null;
276
-        for ($i = 0; $i < $retry; $i++) {
276
+        for ($i = 0; $i<$retry; $i++) {
277 277
             // Realizar consulta al SII enviando el XML.
278 278
             $responseBody = curl_exec($curl);
279 279
 
280 280
             // Si se logró obtener una respuesta, y no es un "Error 500",
281 281
             // entonces se logró enviar el XML al SII y se rompe el ciclo para
282 282
             // parar los reintentos.
283
-            if ($responseBody && $responseBody !== 'Error 500') {
283
+            if ($responseBody && $responseBody!=='Error 500') {
284 284
                 break;
285 285
             }
286 286
 
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
         }
292 292
 
293 293
         // Validar si hubo un error en la respuesta.
294
-        if (!$responseBody || $responseBody === 'Error 500') {
294
+        if (!$responseBody || $responseBody==='Error 500') {
295 295
             $message = 'Falló el envío del XML al SII. ';
296 296
             $message = !$responseBody
297 297
                 ? curl_error($curl)
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
         // asume (y no valida) que el contenido del XML en $xml viene ya
325 325
         // codificado en ISO-8859-1.
326 326
         if (!str_contains($xml, '<?xml')) {
327
-            $xml = '<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n" . $xml;
327
+            $xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n".$xml;
328 328
         }
329 329
 
330 330
         // Comprimir el XML si es necesario. En caso de error al comprimir se
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
         // compresión al ser una funcionalidad opcional del SII.
334 334
         if ($compress) {
335 335
             $xmlGzEncoded = gzencode($xml);
336
-            if ($xmlGzEncoded !== false) {
336
+            if ($xmlGzEncoded!==false) {
337 337
                 $xml = $xmlGzEncoded;
338 338
             } else {
339 339
                 $compress = false;
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
         $filepath = tempnam($tempDir, $prefix);
368 368
 
369 369
         // Renombrar la ruta asignando la extensión al archivo.
370
-        $realFilepath = $filepath . ($compress ? '.xml.gz' : '.xml');
370
+        $realFilepath = $filepath.($compress ? '.xml.gz' : '.xml');
371 371
         rename($filepath, $realFilepath);
372 372
 
373 373
         // Entregar la ruta que se determinó para el archivo.
Please login to merge, or discard this patch.
src/Sii/Contribuyente/Contribuyente.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      * @param DataProviderInterface|null $dataProvider Proveedor de datos.
127 127
      */
128 128
     public function __construct(
129
-        string|int|null $rut = null,
129
+        string | int | null $rut = null,
130 130
         ?string $razon_social = null,
131 131
         ?string $giro = null,
132 132
         ?int $actividad_economica = null,
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     )
140 140
     {
141 141
         // Asignar datos pasados en variable $data como arreglo.
142
-        if ($data !== null) {
142
+        if ($data!==null) {
143 143
             $this->setData($data);
144 144
         }
145 145
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
      */
241 241
     public function getRut(): string
242 242
     {
243
-        return $this->rut . '-' . $this->dv;
243
+        return $this->rut.'-'.$this->dv;
244 244
     }
245 245
 
246 246
     /**
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
         ?int $folioHasta = null
347 347
     ): Caf
348 348
     {
349
-        if ($folioHasta === null) {
349
+        if ($folioHasta===null) {
350 350
             $folioHasta = $folioDesde;
351 351
         }
352 352
 
Please login to merge, or discard this patch.
src/Repository/CiudadesRepository.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
      * @return string|false Nombre de la ciudad asociada o `false` si no se
60 60
      * encuentra.
61 61
      */
62
-    public function getCiudad(string $comuna): string|false
62
+    public function getCiudad(string $comuna): string | false
63 63
     {
64 64
         return $this->dataProvider->getValue(
65 65
             'ciudades',
Please login to merge, or discard this patch.
src/Repository/AbstractRepository.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      * @return string|int Valor asociado al código o el propio código si no se
68 68
      * encuentra.
69 69
      */
70
-    public function getValor(string|int $codigo): string|int
70
+    public function getValor(string | int $codigo): string | int
71 71
     {
72 72
         return $this->dataProvider->getValue($this->dataKey, $codigo);
73 73
     }
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
      * @return string|int Código asociado al valor o el propio valor si no se
80 80
      * encuentra.
81 81
      */
82
-    public function getCodigo(string|int $valor): string|int
82
+    public function getCodigo(string | int $valor): string | int
83 83
     {
84 84
         $data = $this->dataProvider->getData($this->dataKey);
85 85
         return array_search($valor, $data, true) ?: $valor;
Please login to merge, or discard this patch.