@@ -22,7 +22,7 @@ |
||
| 22 | 22 | { |
| 23 | 23 | public static function info($code) |
| 24 | 24 | { |
| 25 | - $codes = (array) json_decode(file_get_contents(__DIR__.'/httpcodes.json'), true); |
|
| 25 | + $codes = (array) json_decode(file_get_contents(__DIR__ . '/httpcodes.json'), true); |
|
| 26 | 26 | if (array_key_exists($code, $codes)) { |
| 27 | 27 | return $codes[$code]; |
| 28 | 28 | } |
@@ -348,7 +348,7 @@ |
||
| 348 | 348 | * |
| 349 | 349 | * @param int $protocol |
| 350 | 350 | * |
| 351 | - * @return type Description |
|
| 351 | + * @return integer Description |
|
| 352 | 352 | */ |
| 353 | 353 | public function protocol($protocol = self::SSL_DEFAULT) |
| 354 | 354 | { |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | ) { |
| 157 | 157 | $this->logger = $logger; |
| 158 | 158 | $this->certificate = $this->checkCertValidity($certificate); |
| 159 | - $this->setTemporaryFolder(sys_get_temp_dir().'/sped/'); |
|
| 159 | + $this->setTemporaryFolder(sys_get_temp_dir() . '/sped/'); |
|
| 160 | 160 | } |
| 161 | 161 | /** |
| 162 | 162 | * Check if certificate is valid |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | if ($this->disableCertValidation) { |
| 172 | 172 | return $certificate; |
| 173 | 173 | } |
| 174 | - if (! empty($certificate)) { |
|
| 174 | + if (!empty($certificate)) { |
|
| 175 | 175 | if ($certificate->isExpired()) { |
| 176 | 176 | throw new RuntimeException( |
| 177 | 177 | 'The validity of the certificate has expired.' |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | //utilize a API. Outra solução para remover arquivos "perdidos" pode ser |
| 226 | 226 | //encontrada oportunamente. |
| 227 | 227 | $dt = new \DateTime(); |
| 228 | - $tint = new \DateInterval("PT".$this->waitingTime."M"); |
|
| 228 | + $tint = new \DateInterval("PT" . $this->waitingTime . "M"); |
|
| 229 | 229 | $tint->invert = true; |
| 230 | 230 | $tsLimit = $dt->add($tint)->getTimestamp(); |
| 231 | 231 | foreach ($contents as $item) { |
@@ -380,15 +380,15 @@ discard block |
||
| 380 | 380 | */ |
| 381 | 381 | public function saveTemporarilyKeyFiles() |
| 382 | 382 | { |
| 383 | - if (! is_object($this->certificate)) { |
|
| 383 | + if (!is_object($this->certificate)) { |
|
| 384 | 384 | throw new RuntimeException( |
| 385 | 385 | 'Certificate not found.' |
| 386 | 386 | ); |
| 387 | 387 | } |
| 388 | - $this->certsdir = $this->certificate->getCnpj().'/certs/'; |
|
| 389 | - $this->prifile = $this->certsdir.Strings::randomString(10).'.pem'; |
|
| 390 | - $this->pubfile = $this->certsdir.Strings::randomString(10).'.pem'; |
|
| 391 | - $this->certfile = $this->certsdir.Strings::randomString(10).'.pem'; |
|
| 388 | + $this->certsdir = $this->certificate->getCnpj() . '/certs/'; |
|
| 389 | + $this->prifile = $this->certsdir . Strings::randomString(10) . '.pem'; |
|
| 390 | + $this->pubfile = $this->certsdir . Strings::randomString(10) . '.pem'; |
|
| 391 | + $this->certfile = $this->certsdir . Strings::randomString(10) . '.pem'; |
|
| 392 | 392 | $ret = true; |
| 393 | 393 | $private = $this->certificate->privateKey; |
| 394 | 394 | if ($this->encriptPrivateKey) { |
@@ -413,9 +413,9 @@ discard block |
||
| 413 | 413 | ); |
| 414 | 414 | $ret &= $this->filesystem->put( |
| 415 | 415 | $this->certfile, |
| 416 | - $private."{$this->certificate}" |
|
| 416 | + $private . "{$this->certificate}" |
|
| 417 | 417 | ); |
| 418 | - if (! $ret) { |
|
| 418 | + if (!$ret) { |
|
| 419 | 419 | throw new RuntimeException( |
| 420 | 420 | 'Unable to save temporary key files in folder.' |
| 421 | 421 | ); |
@@ -432,19 +432,19 @@ discard block |
||
| 432 | 432 | */ |
| 433 | 433 | public function saveDebugFiles($operation, $request, $response) |
| 434 | 434 | { |
| 435 | - if (! $this->debugmode) { |
|
| 435 | + if (!$this->debugmode) { |
|
| 436 | 436 | return; |
| 437 | 437 | } |
| 438 | - $this->debugdir = $this->certificate->getCnpj().'/debug/'; |
|
| 438 | + $this->debugdir = $this->certificate->getCnpj() . '/debug/'; |
|
| 439 | 439 | $now = \DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', '')); |
| 440 | 440 | $time = substr($now->format("ymdHisu"), 0, 16); |
| 441 | 441 | try { |
| 442 | 442 | $this->filesystem->put( |
| 443 | - $this->debugdir.$time."_".$operation."_sol.txt", |
|
| 443 | + $this->debugdir . $time . "_" . $operation . "_sol.txt", |
|
| 444 | 444 | $request |
| 445 | 445 | ); |
| 446 | 446 | $this->filesystem->put( |
| 447 | - $this->debugdir.$time."_".$operation."_res.txt", |
|
| 447 | + $this->debugdir . $time . "_" . $operation . "_res.txt", |
|
| 448 | 448 | $response |
| 449 | 449 | ); |
| 450 | 450 | } catch (Exception $e) { |
@@ -473,10 +473,10 @@ discard block |
||
| 473 | 473 | foreach ($namespaces as $key => $value) { |
| 474 | 474 | $envelope .= " $key=\"$value\""; |
| 475 | 475 | } |
| 476 | - $envelope .= ">"; |
|
| 476 | + $envelope .= ">"; |
|
| 477 | 477 | $soapheader = "<$prefix:Header/>"; |
| 478 | - if (! empty($header)) { |
|
| 479 | - $ns = ! empty($header->namespace) ? $header->namespace : ''; |
|
| 478 | + if (!empty($header)) { |
|
| 479 | + $ns = !empty($header->namespace) ? $header->namespace : ''; |
|
| 480 | 480 | $name = $header->name; |
| 481 | 481 | $soapheader = "<$prefix:Header>"; |
| 482 | 482 | $soapheader .= "<$name xmlns=\"$ns\">"; |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | * @param string $action |
| 81 | 81 | * @param string $envelope |
| 82 | 82 | * @param array $parameters |
| 83 | - */ |
|
| 83 | + */ |
|
| 84 | 84 | public function send( |
| 85 | 85 | $operation, |
| 86 | 86 | $url, |
@@ -63,20 +63,20 @@ discard block |
||
| 63 | 63 | curl_setopt($oCurl, CURLOPT_HEADER, 1); |
| 64 | 64 | curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, 0); |
| 65 | 65 | curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, 0); |
| 66 | - if (! $this->disablesec) { |
|
| 66 | + if (!$this->disablesec) { |
|
| 67 | 67 | curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, 2); |
| 68 | 68 | if (is_file($this->casefaz)) { |
| 69 | 69 | curl_setopt($oCurl, CURLOPT_CAINFO, $this->casefaz); |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | curl_setopt($oCurl, CURLOPT_SSLVERSION, $this->soapprotocol); |
| 73 | - curl_setopt($oCurl, CURLOPT_SSLCERT, $this->tempdir.$this->certfile); |
|
| 74 | - curl_setopt($oCurl, CURLOPT_SSLKEY, $this->tempdir.$this->prifile); |
|
| 75 | - if (! empty($this->temppass)) { |
|
| 73 | + curl_setopt($oCurl, CURLOPT_SSLCERT, $this->tempdir . $this->certfile); |
|
| 74 | + curl_setopt($oCurl, CURLOPT_SSLKEY, $this->tempdir . $this->prifile); |
|
| 75 | + if (!empty($this->temppass)) { |
|
| 76 | 76 | curl_setopt($oCurl, CURLOPT_KEYPASSWD, $this->temppass); |
| 77 | 77 | } |
| 78 | 78 | curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, true); |
| 79 | - if (! empty($envelope)) { |
|
| 79 | + if (!empty($envelope)) { |
|
| 80 | 80 | curl_setopt($oCurl, CURLOPT_POST, true); |
| 81 | 81 | curl_setopt($oCurl, CURLOPT_POSTFIELDS, $envelope); |
| 82 | 82 | curl_setopt($oCurl, CURLOPT_HTTPHEADER, $parameters); |
@@ -94,14 +94,14 @@ discard block |
||
| 94 | 94 | $this->responseBody = trim(substr($response, $headsize)); |
| 95 | 95 | $this->saveDebugFiles( |
| 96 | 96 | $operation, |
| 97 | - $this->requestHead."\n".$this->requestBody, |
|
| 98 | - $this->responseHead."\n".$this->responseBody |
|
| 97 | + $this->requestHead . "\n" . $this->requestBody, |
|
| 98 | + $this->responseHead . "\n" . $this->responseBody |
|
| 99 | 99 | ); |
| 100 | 100 | } catch (\Exception $e) { |
| 101 | 101 | throw SoapException::unableToLoadCurl($e->getMessage()); |
| 102 | 102 | } |
| 103 | 103 | if ($this->soaperror != '') { |
| 104 | - throw SoapException::soapFault($this->soaperror." [$url]"); |
|
| 104 | + throw SoapException::soapFault($this->soaperror . " [$url]"); |
|
| 105 | 105 | } |
| 106 | 106 | if ($httpcode != 200) { |
| 107 | 107 | throw SoapException::soapFault( |
@@ -121,9 +121,9 @@ discard block |
||
| 121 | 121 | if ($this->proxyIP != '') { |
| 122 | 122 | curl_setopt($oCurl, CURLOPT_HTTPPROXYTUNNEL, 1); |
| 123 | 123 | curl_setopt($oCurl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); |
| 124 | - curl_setopt($oCurl, CURLOPT_PROXY, $this->proxyIP.':'.$this->proxyPort); |
|
| 124 | + curl_setopt($oCurl, CURLOPT_PROXY, $this->proxyIP . ':' . $this->proxyPort); |
|
| 125 | 125 | if ($this->proxyUser != '') { |
| 126 | - curl_setopt($oCurl, CURLOPT_PROXYUSERPWD, $this->proxyUser.':'.$this->proxyPass); |
|
| 126 | + curl_setopt($oCurl, CURLOPT_PROXYUSERPWD, $this->proxyUser . ':' . $this->proxyPass); |
|
| 127 | 127 | curl_setopt($oCurl, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | $dom->preserveWhiteSpace = false; |
| 145 | 145 | $dom->loadXML($body); |
| 146 | 146 | $faultstring = ''; |
| 147 | - $nodefault = ! empty($dom->getElementsByTagName('faultstring')->item(0)) |
|
| 147 | + $nodefault = !empty($dom->getElementsByTagName('faultstring')->item(0)) |
|
| 148 | 148 | ? $dom->getElementsByTagName('faultstring')->item(0) |
| 149 | 149 | : ''; |
| 150 | 150 | if (!empty($nodefault)) { |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, 0); |
| 172 | 172 | curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, 0); |
| 173 | 173 | curl_setopt($oCurl, CURLOPT_SSLVERSION, $this->soapprotocol); |
| 174 | - curl_setopt($oCurl, CURLOPT_SSLCERT, $this->tempdir.$this->certfile); |
|
| 175 | - curl_setopt($oCurl, CURLOPT_SSLKEY, $this->tempdir.$this->prifile); |
|
| 176 | - if (! empty($this->temppass)) { |
|
| 174 | + curl_setopt($oCurl, CURLOPT_SSLCERT, $this->tempdir . $this->certfile); |
|
| 175 | + curl_setopt($oCurl, CURLOPT_SSLKEY, $this->tempdir . $this->prifile); |
|
| 176 | + if (!empty($this->temppass)) { |
|
| 177 | 177 | curl_setopt($oCurl, CURLOPT_KEYPASSWD, $this->temppass); |
| 178 | 178 | } |
| 179 | 179 | curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, true); |