@@ -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 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | public static function prettyPrint($response, $save = '') |
| 14 | 14 | { |
| 15 | 15 | $std = json_decode($response); |
| 16 | - if (! empty($save)) { |
|
| 16 | + if (!empty($save)) { |
|
| 17 | 17 | file_put_contents( |
| 18 | 18 | "$save.xml", |
| 19 | 19 | $std->body |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $html .= $std->header; |
| 47 | 47 | $html .= "<br>"; |
| 48 | 48 | $html .= '<h2>namespaces</h2>'; |
| 49 | - $an = json_decode(json_encode($std->namespaces), true); |
|
| 49 | + $an = json_decode(json_encode($std->namespaces), true); |
|
| 50 | 50 | foreach ($an as $key => $nam) { |
| 51 | 51 | $html .= "[$key] => $nam <br>"; |
| 52 | 52 | } |
@@ -194,7 +194,7 @@ |
||
| 194 | 194 | } |
| 195 | 195 | foreach ($eventos as $evt) { |
| 196 | 196 | //verifica se o evento pertence ao grupo indicado |
| 197 | - if (! in_array($evt->alias(), $this->grupos[$grupo])) { |
|
| 197 | + if (!in_array($evt->alias(), $this->grupos[$grupo])) { |
|
| 198 | 198 | throw new RuntimeException( |
| 199 | 199 | 'O evento ' . $evt->alias() . ' não pertence a este grupo [ ' |
| 200 | 200 | . $this->eventGroup[$grupo] . ' ].' |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function toStd($xml = null) |
| 59 | 59 | { |
| 60 | - if (! empty($xml)) { |
|
| 60 | + if (!empty($xml)) { |
|
| 61 | 61 | $this->whichIs($xml); |
| 62 | 62 | } |
| 63 | 63 | $sxml = simplexml_load_string($this->node); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public function whichIs($xml) |
| 79 | 79 | { |
| 80 | - if (! Validator::isXML($xml)) { |
|
| 80 | + if (!Validator::isXML($xml)) { |
|
| 81 | 81 | throw new InvalidArgumentException( |
| 82 | 82 | "O argumento passado não é um XML válido." |
| 83 | 83 | ); |
@@ -87,10 +87,10 @@ discard block |
||
| 87 | 87 | $dom->formatOutput = false; |
| 88 | 88 | $dom->loadXML($xml); |
| 89 | 89 | foreach ($this->rootTagList as $key) { |
| 90 | - $node = ! empty($dom->getElementsByTagName($key)->item(0)) |
|
| 90 | + $node = !empty($dom->getElementsByTagName($key)->item(0)) |
|
| 91 | 91 | ? $dom->getElementsByTagName($key)->item(0) |
| 92 | 92 | : ''; |
| 93 | - if (! empty($node)) { |
|
| 93 | + if (!empty($node)) { |
|
| 94 | 94 | $this->node = $dom->saveXML($node); |
| 95 | 95 | return $key; |
| 96 | 96 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public function toJson($xml = null) |
| 118 | 118 | { |
| 119 | - if (! empty($xml)) { |
|
| 119 | + if (!empty($xml)) { |
|
| 120 | 120 | $this->toStd($xml); |
| 121 | 121 | } |
| 122 | 122 | return $this->json; |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | public function toArray($xml = null) |
| 131 | 131 | { |
| 132 | - if (! empty($xml)) { |
|
| 132 | + if (!empty($xml)) { |
|
| 133 | 133 | $this->toStd($xml); |
| 134 | 134 | } |
| 135 | 135 | return json_decode($this->json, true); |
@@ -123,14 +123,14 @@ |
||
| 123 | 123 | $orig .= "$p->"; |
| 124 | 124 | } |
| 125 | 125 | $exist = false; |
| 126 | - $test = "\$exist = (!empty(".substr($orig, 0, strlen($orig) - 2).")) ? true : false;"; |
|
| 126 | + $test = "\$exist = (!empty(" . substr($orig, 0, strlen($orig) - 2) . ")) ? true : false;"; |
|
| 127 | 127 | eval($test); |
| 128 | 128 | } |
| 129 | 129 | $orig .= $name; |
| 130 | 130 | $resp = null; |
| 131 | 131 | eval("\$resp = $orig;"); |
| 132 | 132 | if (!empty($resp) || $resp === 0) { |
| 133 | - $comm .= $name.'= $resp'; |
|
| 133 | + $comm .= $name . '= $resp'; |
|
| 134 | 134 | } else { |
| 135 | 135 | $comm .= "$name = null"; |
| 136 | 136 | } |
@@ -171,7 +171,7 @@ |
||
| 171 | 171 | $this->dom->addChild( |
| 172 | 172 | $nova, |
| 173 | 173 | "fimValid", |
| 174 | - ! empty($this->std->novavalidade->fimvalid) |
|
| 174 | + !empty($this->std->novavalidade->fimvalid) |
|
| 175 | 175 | ? $this->std->novavalidade->fimvalid |
| 176 | 176 | : null, |
| 177 | 177 | false |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $this->dom->addChild( |
| 106 | 106 | $ide, |
| 107 | 107 | "fimValid", |
| 108 | - ! empty($this->std->fimvalid) ? $this->std->fimvalid : null, |
|
| 108 | + !empty($this->std->fimvalid) ? $this->std->fimvalid : null, |
|
| 109 | 109 | false |
| 110 | 110 | ); |
| 111 | 111 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | $this->dom->addChild( |
| 172 | 172 | $nova, |
| 173 | 173 | "fimValid", |
| 174 | - ! empty($this->std->novavalidade->fimvalid) |
|
| 174 | + !empty($this->std->novavalidade->fimvalid) |
|
| 175 | 175 | ? $this->std->novavalidade->fimvalid |
| 176 | 176 | : null, |
| 177 | 177 | false |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @var array |
| 87 | 87 | */ |
| 88 | 88 | protected $grupos = [ |
| 89 | - 1 => [ //EVENTOS INICIAIS grupo [1] |
|
| 89 | + 1 => [//EVENTOS INICIAIS grupo [1] |
|
| 90 | 90 | 'S-1000', |
| 91 | 91 | 'S-1005', |
| 92 | 92 | 'S-1010', |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | 'S-1070', |
| 100 | 100 | 'S-1080', |
| 101 | 101 | ], |
| 102 | - 2 => [ //EVENTOS NÃO PERIÓDICOS grupo [2] |
|
| 102 | + 2 => [//EVENTOS NÃO PERIÓDICOS grupo [2] |
|
| 103 | 103 | 'S-2190', |
| 104 | 104 | 'S-2200', |
| 105 | 105 | 'S-2205', |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | 'S-5012', |
| 128 | 128 | 'S-5013', |
| 129 | 129 | ], |
| 130 | - 3 => [ //EVENTOS PERIÓDICOS grupo [3] |
|
| 130 | + 3 => [//EVENTOS PERIÓDICOS grupo [3] |
|
| 131 | 131 | 'S-1200', |
| 132 | 132 | 'S-1202', |
| 133 | 133 | 'S-1207', |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | $this->certificate = $certificate; |
| 170 | 170 | $this->path = realpath(__DIR__ . '/../../') . '/'; |
| 171 | 171 | $this->serviceXsd = XsdSeeker::seek( |
| 172 | - $this->path."schemes/comunicacao/$this->serviceStr/" |
|
| 172 | + $this->path . "schemes/comunicacao/$this->serviceStr/" |
|
| 173 | 173 | ); |
| 174 | 174 | } |
| 175 | 175 | |
@@ -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\">"; |