Completed
Branch master (96d5ac)
by Esteban De La Fuente
38s
created
src/Signature/SignatureValidator.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
         string $data,
47 47
         string $signature,
48 48
         string $publicKey,
49
-        string|int $signatureAlgorithm = OPENSSL_ALGO_SHA1
49
+        string | int $signatureAlgorithm = OPENSSL_ALGO_SHA1
50 50
     ): bool
51 51
     {
52 52
         $publicKey = CertificateUtils::normalizePublicKey($publicKey);
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
             $signatureAlgorithm
59 59
         );
60 60
 
61
-        if ($result === -1) {
61
+        if ($result===-1) {
62 62
             throw new SignatureException(
63 63
                 'Ocurrió un error al verificar la firma electrónica de los datos.'
64 64
             );
65 65
         }
66 66
 
67
-        return $result === 1;
67
+        return $result===1;
68 68
     }
69 69
 
70 70
     /**
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      * @return void
75 75
      * @throws SignatureException Si hubo un error al hacer la verificación.
76 76
      */
77
-    public static function validateXml(XmlDocument|string $xml): void
77
+    public static function validateXml(XmlDocument | string $xml): void
78 78
     {
79 79
         // Si se pasó un objeto XmlDocument se convierte a string.
80 80
         if (!is_string($xml)) {
Please login to merge, or discard this patch.
src/Signature/CertificateLoader.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     {
75 75
         $certs = [];
76 76
 
77
-        if (openssl_pkcs12_read($data, $certs, $password) === false) {
77
+        if (openssl_pkcs12_read($data, $certs, $password)===false) {
78 78
             throw new CertificateException(sprintf(
79 79
                 'No fue posible leer los datos del certificado digital.',
80 80
             ));
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
         $publicKey = $data['publicKey'] ?? $data['cert'] ?? null;
98 98
         $privateKey = $data['privateKey'] ?? $data['pkey'] ?? null;
99 99
 
100
-        if ($publicKey === null) {
100
+        if ($publicKey===null) {
101 101
             throw new CertificateException(
102 102
                 'La clave pública del certificado no fue encontrada.'
103 103
             );
104 104
         }
105 105
 
106
-        if ($privateKey === null) {
106
+        if ($privateKey===null) {
107 107
             throw new CertificateException(
108 108
                 'La clave privada del certificado no fue encontrada.'
109 109
             );
Please login to merge, or discard this patch.
src/Signature/CertificateFaker.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
      */
167 167
     public function setValidity(string $validTo = null): self
168 168
     {
169
-        $validFrom = (int) date('U');
169
+        $validFrom = (int)date('U');
170 170
 
171
-        if ($validTo === null) {
171
+        if ($validTo===null) {
172 172
             $validTo = date('Y-m-d', strtotime('+1 year', $validFrom));
173 173
         }
174 174
         $validTo = strtotime($validTo);
175 175
 
176
-        $days = (int) (($validTo - $validFrom) / (60 * 60 * 24));
176
+        $days = (int)(($validTo-$validFrom) / (60 * 60 * 24));
177 177
 
178 178
         $this->validity = [
179 179
             'from' => $validFrom,
@@ -222,11 +222,11 @@  discard block
 block discarded – undo
222 222
 
223 223
         // Crear certificado autofirmado para el emisor.
224 224
         $issuerCert = openssl_csr_sign(
225
-            $issuerCsr,         // CSR del emisor.
226
-            null,               // Certificado emisor (null indica que es autofirmado).
227
-            $issuerPrivateKey,  // Clave privada del emisor.
228
-            $days,              // Número de días de validez (misma sujeto).
229
-            [],                 // Opciones adicionales.
225
+            $issuerCsr, // CSR del emisor.
226
+            null, // Certificado emisor (null indica que es autofirmado).
227
+            $issuerPrivateKey, // Clave privada del emisor.
228
+            $days, // Número de días de validez (misma sujeto).
229
+            [], // Opciones adicionales.
230 230
             666                 // Número de serie del certificado.
231 231
         );
232 232
 
@@ -236,11 +236,11 @@  discard block
 block discarded – undo
236 236
 
237 237
         // Usar el certificado del emisor para firmar el CSR del sujeto.
238 238
         $subjectCert = openssl_csr_sign(
239
-            $subjectCsr,        // La solicitud de firma del certificado (CSR).
240
-            $issuerCert,        // Certificado emisor.
241
-            $issuerPrivateKey,  // Clave privada del emisor.
242
-            $days,              // Número de días de validez.
243
-            [],                 // Opciones adicionales.
239
+            $subjectCsr, // La solicitud de firma del certificado (CSR).
240
+            $issuerCert, // Certificado emisor.
241
+            $issuerPrivateKey, // Clave privada del emisor.
242
+            $days, // Número de días de validez.
243
+            [], // Opciones adicionales.
244 244
             69                  // Número de serie del certificado.
245 245
         );
246 246
 
Please login to merge, or discard this patch.
src/Signature/XmlSignatureNode.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
     public function setReference(?string $reference = null): self
189 189
     {
190 190
         // Asignar URI de la referencia (o vacia si se firma todo el XML).
191
-        $uri = $reference ? ('#' . ltrim($reference, '#')) : '';
191
+        $uri = $reference ? ('#'.ltrim($reference, '#')) : '';
192 192
         $this->data['Signature']['SignedInfo']['Reference']['@attributes']['URI'] = $uri;
193 193
 
194 194
         // Asignar algoritmo de transformación al momento de obtener el C14N.
@@ -290,17 +290,17 @@  discard block
 block discarded – undo
290 290
     public function sign(?Certificate $certificate = null): self
291 291
     {
292 292
         // Si se pasó un certificado digital se asigna.
293
-        if ($certificate !== null) {
293
+        if ($certificate!==null) {
294 294
             $this->setCertificate($certificate);
295 295
         }
296 296
 
297 297
         // Validar que esté asignado el DigestValue.
298
-        if ($this->getDigestValue() === null) {
298
+        if ($this->getDigestValue()===null) {
299 299
             throw new SignatureException('No es posible generar la firma del nodo Signature si aun no se asigna el DigestValue.');
300 300
         }
301 301
 
302 302
         // Validar que esté asignado el certificado digital.
303
-        if ($this->getCertificate() === null) {
303
+        if ($this->getCertificate()===null) {
304 304
             throw new SignatureException('No es posible generar la firma del nodo Signature si aun no se asigna el certificado digital.');
305 305
         }
306 306
 
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
      * @return void
368 368
      * @throws SignatureException En caso de error de DigestValue o firma.
369 369
      */
370
-    public function validate(XmlDocument|string $xml): void
370
+    public function validate(XmlDocument | string $xml): void
371 371
     {
372 372
         $this->validateDigestValue($xml);
373 373
         $this->validateSignatureValue();
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
      * @return void
381 381
      * @throws SignatureException Si el DigestValue no es válido.
382 382
      */
383
-    public function validateDigestValue(XmlDocument|string $xml): void
383
+    public function validateDigestValue(XmlDocument | string $xml): void
384 384
     {
385 385
         // Si se pasó un objeto XmlDocument se convierte a string.
386 386
         if (!is_string($xml)) {
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
         );
407 407
 
408 408
         // Si los digest no coinciden no es válido.
409
-        if ($digestValueXml !== $digestValueCalculated) {
409
+        if ($digestValueXml!==$digestValueCalculated) {
410 410
             throw new SignatureException(sprintf(
411 411
                 'El DigestValue que viene en el XML "%s" para la referencia "%s" no coincide con el valor calculado al validar "%s". Los datos de la referencia podrían haber sido manipulados después de haber sido firmados.',
412 412
                 $digestValueXml,
Please login to merge, or discard this patch.
resources/data/documentos.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
  * En caso contrario, consulte <http://www.gnu.org/licenses/agpl.html>.
21 21
  */
22 22
 
23
- return [
23
+    return [
24 24
     // Documentos tributarios oficiales del SII.
25 25
     29 => [
26 26
         'nombre' => 'Factura de inicio',
Please login to merge, or discard this patch.
php-cs-fixer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,6 +75,6 @@
 block discarded – undo
75 75
         'indentation_type' => true,
76 76
     ])
77 77
     ->setLineEnding("\n")
78
-    ->setCacheFile($dir . '/var/cache/php-cs-fixer.cache')
78
+    ->setCacheFile($dir.'/var/cache/php-cs-fixer.cache')
79 79
     ->setFinder($finder)
80 80
 ;
Please login to merge, or discard this patch.