@@ -10,6 +10,6 @@ |
||
10 | 10 | public function __construct(Certificate $certificate) |
11 | 11 | { |
12 | 12 | $invalidDate = $certificate->getValidFrom()->format('Y-m-d H:i'); |
13 | - parent::__construct('Certificate invalid from '.$invalidDate, 0, null); |
|
13 | + parent::__construct('Certificate invalid from ' . $invalidDate, 0, null); |
|
14 | 14 | } |
15 | 15 | } |
@@ -27,7 +27,6 @@ |
||
27 | 27 | use NFePHP\Common\Certificate; |
28 | 28 | use NFePHP\Common\Certificate\PublicKey; |
29 | 29 | use NFePHP\Common\Exception\SignerException; |
30 | -use NFePHP\Common\Strings; |
|
31 | 30 | use NFePHP\Common\Validator; |
32 | 31 | use DOMDocument; |
33 | 32 | use DOMNode; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | class Signer |
37 | 37 | { |
38 | - private static $canonical = [true,false,null,null]; |
|
38 | + private static $canonical = [true, false, null, null]; |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Make Signature tag |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $tagname, |
56 | 56 | $mark = 'Id', |
57 | 57 | $algorithm = OPENSSL_ALGO_SHA1, |
58 | - $canonical = [true,false,null,null], |
|
58 | + $canonical = [true, false, null, null], |
|
59 | 59 | $rootname = '' |
60 | 60 | ) { |
61 | 61 | if (!empty($canonical)) { |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | if (empty($content)) { |
65 | 65 | throw SignerException::isNotXml(); |
66 | 66 | } |
67 | - if (! Validator::isXML($content)) { |
|
67 | + if (!Validator::isXML($content)) { |
|
68 | 68 | throw SignerException::isNotXml(); |
69 | 69 | } |
70 | 70 | $dom = new DOMDocument('1.0', 'UTF-8'); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | if (empty($node) || empty($root)) { |
80 | 80 | throw SignerException::tagNotFound($tagname); |
81 | 81 | } |
82 | - if (! self::existsSignature($content)) { |
|
82 | + if (!self::existsSignature($content)) { |
|
83 | 83 | $dom = self::createSignature( |
84 | 84 | $certificate, |
85 | 85 | $dom, |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | DOMElement $node, |
113 | 113 | $mark, |
114 | 114 | $algorithm = OPENSSL_ALGO_SHA1, |
115 | - $canonical = [true,false,null,null] |
|
115 | + $canonical = [true, false, null, null] |
|
116 | 116 | ) { |
117 | 117 | $nsDSIG = 'http://www.w3.org/2000/09/xmldsig#'; |
118 | 118 | $nsCannonMethod = 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315'; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $nsSignatureMethod = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'; |
125 | 125 | $nsDigestMethod = 'http://www.w3.org/2001/04/xmlenc#sha256'; |
126 | 126 | } |
127 | - $nsTransformMethod1 ='http://www.w3.org/2000/09/xmldsig#enveloped-signature'; |
|
127 | + $nsTransformMethod1 = 'http://www.w3.org/2000/09/xmldsig#enveloped-signature'; |
|
128 | 128 | $nsTransformMethod2 = 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315'; |
129 | 129 | $idSigned = trim($node->getAttribute($mark)); |
130 | 130 | $digestValue = self::makeDigest($node, $digestAlgorithm, $canonical); |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public static function removeSignature($content) |
181 | 181 | { |
182 | - if (! self::existsSignature($content)) { |
|
182 | + if (!self::existsSignature($content)) { |
|
183 | 183 | return $content; |
184 | 184 | } |
185 | 185 | $dom = new \DOMDocument('1.0', 'utf-8'); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | public static function isSigned( |
208 | 208 | $content, |
209 | 209 | $tagname = '', |
210 | - $canonical = [true,false,null,null] |
|
210 | + $canonical = [true, false, null, null] |
|
211 | 211 | ) { |
212 | 212 | if (self::existsSignature($content)) { |
213 | 213 | if (self::digestCheck($content, $tagname, $canonical)) { |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | */ |
227 | 227 | public static function existsSignature($content) |
228 | 228 | { |
229 | - if (! Validator::isXML($content)) { |
|
229 | + if (!Validator::isXML($content)) { |
|
230 | 230 | throw SignerException::isNotXml(); |
231 | 231 | } |
232 | 232 | $dom = new \DOMDocument('1.0', 'utf-8'); |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | */ |
249 | 249 | private static function signatureCheck( |
250 | 250 | $xml, |
251 | - $canonical = [true,false,null,null] |
|
251 | + $canonical = [true, false, null, null] |
|
252 | 252 | ) { |
253 | 253 | $dom = new \DOMDocument('1.0', 'utf-8'); |
254 | 254 | $dom->formatOutput = false; |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | $decodedSignature = base64_decode( |
275 | 275 | str_replace(array("\r", "\n"), '', $signatureValue) |
276 | 276 | ); |
277 | - if (! $publicKey->verify($signInfoNode, $decodedSignature, $algorithm)) { |
|
277 | + if (!$publicKey->verify($signInfoNode, $decodedSignature, $algorithm)) { |
|
278 | 278 | throw SignerException::signatureComparisonFailed(); |
279 | 279 | } |
280 | 280 | return true; |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | private static function digestCheck( |
291 | 291 | $xml, |
292 | 292 | $tagname = '', |
293 | - $canonical = [true,false,null,null] |
|
293 | + $canonical = [true, false, null, null] |
|
294 | 294 | ) { |
295 | 295 | $dom = new \DOMDocument('1.0', 'utf-8'); |
296 | 296 | $dom->formatOutput = false; |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | private static function makeDigest( |
347 | 347 | DOMNode $node, |
348 | 348 | $algorithm, |
349 | - $canonical = [true,false,null,null] |
|
349 | + $canonical = [true, false, null, null] |
|
350 | 350 | ) { |
351 | 351 | //calcular o hash dos dados |
352 | 352 | $c14n = self::canonize($node, $canonical); |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | */ |
363 | 363 | private static function canonize( |
364 | 364 | DOMNode $node, |
365 | - $canonical = [true,false,null,null] |
|
365 | + $canonical = [true, false, null, null] |
|
366 | 366 | ) { |
367 | 367 | return $node->C14N( |
368 | 368 | $canonical[0], |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | //get length of OID data |
75 | 75 | $len = self::getLength($data); |
76 | 76 | //get only a string with bytes belongs to OID |
77 | - $oidData = substr($data, 2 + $bytes, $len-($bytes)); |
|
77 | + $oidData = substr($data, 2 + $bytes, $len - ($bytes)); |
|
78 | 78 | //parse OID data many possibel formats and structures |
79 | 79 | $head = strlen($oidData) - strlen($xcv) - 2; |
80 | 80 | $ret = substr($oidData, -$head); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | if ($num == 0) { |
119 | 119 | $bun = 40 * $partes[$num]; |
120 | 120 | } elseif ($num == 1) { |
121 | - $bun += $partes[$num]; |
|
121 | + $bun += $partes[$num]; |
|
122 | 122 | $abBinary[] = $bun; |
123 | 123 | } else { |
124 | 124 | $abBinary = self::xBase128($abBinary, (integer) $partes[$num], true); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | { |
143 | 143 | $abc = $abIn; |
144 | 144 | if ($qIn > 127) { |
145 | - $abc = self::xBase128($abc, floor($qIn/128), false); |
|
145 | + $abc = self::xBase128($abc, floor($qIn / 128), false); |
|
146 | 146 | } |
147 | 147 | $qIn2 = $qIn % 128; |
148 | 148 | if ($flag) { |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | */ |
170 | 170 | private function isCertificateExpired(Certificate $certificate = null) |
171 | 171 | { |
172 | - if (! $this->disableCertValidation) { |
|
172 | + if (!$this->disableCertValidation) { |
|
173 | 173 | if (null !== $certificate && $certificate->isExpired()) { |
174 | 174 | throw new Certificate\Exception\Expired($certificate); |
175 | 175 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | $bodyContent = '' |
392 | 392 | ) { |
393 | 393 | return sprintf( |
394 | - '<%s:Envelope %s>'.$header.'<%s:Body>%s</%s:Body></%s:Envelope>', |
|
394 | + '<%s:Envelope %s>' . $header . '<%s:Body>%s</%s:Body></%s:Envelope>', |
|
395 | 395 | $envelopPrefix, |
396 | 396 | $envelopAttributes, |
397 | 397 | $envelopPrefix, |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | } |
415 | 415 | $headerItems = ''; |
416 | 416 | foreach ($header->data as $key => $value) { |
417 | - $headerItems .= '<'.$key.'>'.$value.'</'.$key.'>'; |
|
417 | + $headerItems .= '<' . $key . '>' . $value . '</' . $key . '>'; |
|
418 | 418 | } |
419 | 419 | return sprintf( |
420 | 420 | '<%s:Header><%s xmlns="%s">%s</%s></%s:Header>', |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | { |
437 | 437 | $envelopeAttributes = ''; |
438 | 438 | foreach ($namespaces as $key => $value) { |
439 | - $envelopeAttributes = $key.'="'.$value.'"'; |
|
439 | + $envelopeAttributes = $key . '="' . $value . '"'; |
|
440 | 440 | } |
441 | 441 | return $envelopeAttributes; |
442 | 442 | } |
@@ -454,9 +454,9 @@ discard block |
||
454 | 454 | ); |
455 | 455 | } |
456 | 456 | $this->certsdir = $this->certificate->getCnpj() . '/certs/'; |
457 | - $this->prifile = $this->certsdir. Strings::randomString(10).'.pem'; |
|
458 | - $this->pubfile = $this->certsdir . Strings::randomString(10).'.pem'; |
|
459 | - $this->certfile = $this->certsdir . Strings::randomString(10).'.pem'; |
|
457 | + $this->prifile = $this->certsdir . Strings::randomString(10) . '.pem'; |
|
458 | + $this->pubfile = $this->certsdir . Strings::randomString(10) . '.pem'; |
|
459 | + $this->certfile = $this->certsdir . Strings::randomString(10) . '.pem'; |
|
460 | 460 | $ret = true; |
461 | 461 | $private = $this->certificate->privateKey; |
462 | 462 | if ($this->encriptPrivateKey) { |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | ); |
482 | 482 | $ret &= $this->filesystem->put( |
483 | 483 | $this->certfile, |
484 | - $private."{$this->certificate}" |
|
484 | + $private . "{$this->certificate}" |
|
485 | 485 | ); |
486 | 486 | if (!$ret) { |
487 | 487 | throw new RuntimeException( |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | //utilize a API. Outra solução para remover arquivos "perdidos" pode ser |
509 | 509 | //encontrada oportunamente. |
510 | 510 | $dt = new \DateTime(); |
511 | - $tint = new \DateInterval("PT".$this->waitingTime."M"); |
|
511 | + $tint = new \DateInterval("PT" . $this->waitingTime . "M"); |
|
512 | 512 | $tint->invert = 1; |
513 | 513 | $tsLimit = $dt->add($tint)->getTimestamp(); |
514 | 514 | foreach ($contents as $item) { |