@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | public function __construct($version = '3.10') |
108 | 108 | { |
109 | 109 | $ver = str_replace('.', '', $version); |
110 | - $path = realpath(__DIR__."/../../storage/txtstructure$ver.json"); |
|
110 | + $path = realpath(__DIR__ . "/../../storage/txtstructure$ver.json"); |
|
111 | 111 | $this->structure = json_decode(file_get_contents($path), true); |
112 | 112 | $this->make = new Make(); |
113 | 113 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | if (empty($fields)) { |
139 | 139 | continue; |
140 | 140 | } |
141 | - $metodo = strtolower(str_replace(' ', '', $fields[0])).'Entity'; |
|
141 | + $metodo = strtolower(str_replace(' ', '', $fields[0])) . 'Entity'; |
|
142 | 142 | if (!method_exists(__CLASS__, $metodo)) { |
143 | 143 | //campo não definido |
144 | 144 | throw DocumentsException::wrongDocument(16, $lin); |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | protected static function fieldsToStd($dfls, $struct) |
159 | 159 | { |
160 | 160 | $sfls = explode('|', $struct); |
161 | - $len = count($sfls)-1; |
|
161 | + $len = count($sfls) - 1; |
|
162 | 162 | $std = new \stdClass(); |
163 | 163 | for ($i = 1; $i < $len; $i++) { |
164 | 164 | $name = $sfls[$i]; |
@@ -1231,7 +1231,7 @@ discard block |
||
1231 | 1231 | $this->stdPIS->CST = $std->CST; |
1232 | 1232 | $this->stdPIS->vPIS = $std->vPIS; |
1233 | 1233 | $this->stdPIS->qBCProd = $std->qBCProd; |
1234 | - $this->stdPIS->vAliqProd = $std->vAliqProd; |
|
1234 | + $this->stdPIS->vAliqProd = $std->vAliqProd; |
|
1235 | 1235 | $this->buildQEntity(); |
1236 | 1236 | } |
1237 | 1237 | |
@@ -1282,7 +1282,7 @@ discard block |
||
1282 | 1282 | protected function q10Entity($std) |
1283 | 1283 | { |
1284 | 1284 | $this->stdPIS->qBCProd = $std->qBCProd; |
1285 | - $this->stdPIS->vAliqProd = $std->vAliqProd; |
|
1285 | + $this->stdPIS->vAliqProd = $std->vAliqProd; |
|
1286 | 1286 | $this->buildQEntity(); |
1287 | 1287 | } |
1288 | 1288 |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * Canonical conversion options |
97 | 97 | * @var array |
98 | 98 | */ |
99 | - protected $canonical = [true,false,null,null]; |
|
99 | + protected $canonical = [true, false, null, null]; |
|
100 | 100 | /** |
101 | 101 | * Model of CTe 57 or 67 |
102 | 102 | * @var int |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | $this->config = json_decode($configJson); |
184 | 184 | $this->pathwsfiles = realpath( |
185 | 185 | __DIR__ . '/../../storage' |
186 | - ).'/'; |
|
186 | + ) . '/'; |
|
187 | 187 | $this->version($this->config->versao); |
188 | 188 | $this->setEnvironmentTimeZone($this->config->siglaUF); |
189 | 189 | $this->certificate = $certificate; |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | $this->versao = $version; |
262 | 262 | $this->config->schemes = $this->availableVersions[$version]; |
263 | 263 | $this->pathschemes = realpath( |
264 | - __DIR__ . '/../../schemes/'. $this->config->schemes |
|
265 | - ).'/'; |
|
264 | + __DIR__ . '/../../schemes/' . $this->config->schemes |
|
265 | + ) . '/'; |
|
266 | 266 | } |
267 | 267 | return $this->versao; |
268 | 268 | } |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | */ |
358 | 358 | protected function isValid($version, $body, $method) |
359 | 359 | { |
360 | - $schema = $this->pathschemes.$method."_v$version.xsd"; |
|
360 | + $schema = $this->pathschemes . $method . "_v$version.xsd"; |
|
361 | 361 | if (!is_file($schema)) { |
362 | 362 | return true; |
363 | 363 | } |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | * @param array $opt |
424 | 424 | * @return array |
425 | 425 | */ |
426 | - public function canonicalOptions($opt = [true,false,null,null]) |
|
426 | + public function canonicalOptions($opt = [true, false, null, null]) |
|
427 | 427 | { |
428 | 428 | if (!empty($opt) && is_array($opt)) { |
429 | 429 | $this->canonical = $opt; |
@@ -539,8 +539,8 @@ discard block |
||
539 | 539 | { |
540 | 540 | $file = $this->pathwsfiles |
541 | 541 | . DIRECTORY_SEPARATOR |
542 | - . "wscte_".$this->versao."_mod57.xml"; |
|
543 | - if (! file_exists($file)) { |
|
542 | + . "wscte_" . $this->versao . "_mod57.xml"; |
|
543 | + if (!file_exists($file)) { |
|
544 | 544 | return ''; |
545 | 545 | } |
546 | 546 | return file_get_contents($file); |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | //os URI estão em storage/uri_consulta_nfce.json |
591 | 591 | $std = json_decode( |
592 | 592 | file_get_contents( |
593 | - $this->pathwsfiles.'uri_consulta_nfce.json' |
|
593 | + $this->pathwsfiles . 'uri_consulta_nfce.json' |
|
594 | 594 | ) |
595 | 595 | ); |
596 | 596 | return $std->$uf; |
@@ -48,9 +48,9 @@ |
||
48 | 48 | */ |
49 | 49 | protected static function validInputData(stdClass $data) |
50 | 50 | { |
51 | - $filejsonschema = __DIR__. "/../../storage/config_json.schema"; |
|
51 | + $filejsonschema = __DIR__ . "/../../storage/config_json.schema"; |
|
52 | 52 | $validator = new JsonValid(); |
53 | - $validator->check($data, (object)['$ref' => 'file://' . $filejsonschema]); |
|
53 | + $validator->check($data, (object) ['$ref' => 'file://' . $filejsonschema]); |
|
54 | 54 | if (!$validator->isValid()) { |
55 | 55 | $msg = ""; |
56 | 56 | foreach ($validator->getErrors() as $error) { |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | { |
31 | 31 | $path = realpath(__DIR__ . "/../../storage"); |
32 | 32 | $json = file_get_contents( |
33 | - $path . '/txtstructure' . ($version*100) . '.json' |
|
33 | + $path . '/txtstructure' . ($version * 100) . '.json' |
|
34 | 34 | ); |
35 | 35 | self::$entities = json_decode($json, true); |
36 | 36 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | if ($default != $count) { |
82 | 82 | self::$errors[] = "ERRO: O número de parâmetros na linha " |
83 | 83 | . "está errado (esperado #$default) -> (encontrado #$count). [ $row ] Esperado [ " |
84 | - . self::$entities[$ref]." ]"; |
|
84 | + . self::$entities[$ref] . " ]"; |
|
85 | 85 | } |
86 | 86 | foreach ($fields as $field) { |
87 | 87 | if ($field != trim($field)) { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | //wrong document, this document is not able to recieve a protocol |
26 | 26 | throw DocumentsException::wrongDocument(0, $key); |
27 | 27 | } |
28 | - $func = "add".$key."Protocol"; |
|
28 | + $func = "add" . $key . "Protocol"; |
|
29 | 29 | return self::$func($request, $response); |
30 | 30 | } |
31 | 31 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | throw DocumentsException::wrongDocument(3, "<protCTe>"); |
129 | 129 | } |
130 | 130 | $infProt = $ret->getElementsByTagName('infProt')->item(0); |
131 | - $cStat = $infProt->getElementsByTagName('cStat')->item(0)->nodeValue; |
|
131 | + $cStat = $infProt->getElementsByTagName('cStat')->item(0)->nodeValue; |
|
132 | 132 | $xMotivo = $infProt->getElementsByTagName('xMotivo')->item(0)->nodeValue; |
133 | 133 | $dig = $infProt->getElementsByTagName("digVal")->item(0); |
134 | 134 | $digProt = '000'; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | throw DocumentsException::wrongDocument(3, "<protCTe>"); |
186 | 186 | } |
187 | 187 | $infProt = $ret->getElementsByTagName('infProt')->item(0); |
188 | - $cStat = $infProt->getElementsByTagName('cStat')->item(0)->nodeValue; |
|
188 | + $cStat = $infProt->getElementsByTagName('cStat')->item(0)->nodeValue; |
|
189 | 189 | $xMotivo = $infProt->getElementsByTagName('xMotivo')->item(0)->nodeValue; |
190 | 190 | $dig = $infProt->getElementsByTagName("digVal")->item(0); |
191 | 191 | $digProt = '000'; |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | // $resLote = $ret->getElementsByTagName('idLote')->item(0)->nodeValue; |
239 | 239 | //extrai a rag retEvento da resposta (retorno da SEFAZ) |
240 | 240 | $retEv = $ret->getElementsByTagName('retEventoCTe')->item(0); |
241 | - $cStat = $retEv->getElementsByTagName('cStat')->item(0)->nodeValue; |
|
241 | + $cStat = $retEv->getElementsByTagName('cStat')->item(0)->nodeValue; |
|
242 | 242 | $xMotivo = $retEv->getElementsByTagName('xMotivo')->item(0)->nodeValue; |
243 | 243 | $tpEvento = $retEv->getElementsByTagName('tpEvento')->item(0)->nodeValue; |
244 | 244 | $cStatValids = ['135', '136']; |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | { |
270 | 270 | $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" |
271 | 271 | . "<$nodename versao=\"$versao\" " |
272 | - . "xmlns=\"".self::$urlPortal."\">"; |
|
272 | + . "xmlns=\"" . self::$urlPortal . "\">"; |
|
273 | 273 | $xml .= $first; |
274 | 274 | $xml .= $second; |
275 | 275 | $xml .= "</$nodename>"; |
@@ -652,12 +652,12 @@ discard block |
||
652 | 652 | } |
653 | 653 | |
654 | 654 | $this->dom->appChild($this->infCTeNorm, $this->infModal, 'Falta tag "infModal"'); |
655 | - if ($this->modal=='01') { |
|
655 | + if ($this->modal == '01') { |
|
656 | 656 | $this->dom->appChild($this->infModal, $this->rodo, 'Falta tag "rodo"'); |
657 | 657 | foreach ($this->veic as $veic) { |
658 | 658 | $this->dom->appChild($this->rodo, $veic, 'Falta tag "veic"'); |
659 | 659 | } |
660 | - } elseif ($this->modal=='02') { |
|
660 | + } elseif ($this->modal == '02') { |
|
661 | 661 | $this->dom->appChild($this->infModal, $this->aereo, 'Falta tag "aereo"'); |
662 | 662 | } else { |
663 | 663 | throw new Exception('Modal não informado ou não suportado.'); |
@@ -1226,7 +1226,7 @@ discard block |
||
1226 | 1226 | { |
1227 | 1227 | $identificador = '#4 <infPercurso> - '; |
1228 | 1228 | $this->infPercurso[] = $this->dom->createElement('infPercurso'); |
1229 | - $posicao = (integer)count($this->infPercurso) - 1; |
|
1229 | + $posicao = (integer) count($this->infPercurso) - 1; |
|
1230 | 1230 | $this->dom->addChild( |
1231 | 1231 | $this->infPercurso[$posicao], |
1232 | 1232 | 'UFPer', |
@@ -2863,7 +2863,7 @@ discard block |
||
2863 | 2863 | { |
2864 | 2864 | $identificador = '#65 <pass> - '; |
2865 | 2865 | $this->comp[] = $this->dom->createElement('Comp'); |
2866 | - $posicao = (integer)count($this->comp) - 1; |
|
2866 | + $posicao = (integer) count($this->comp) - 1; |
|
2867 | 2867 | $this->dom->addChild( |
2868 | 2868 | $this->comp[$posicao], |
2869 | 2869 | 'xNome', |
@@ -3260,7 +3260,7 @@ discard block |
||
3260 | 3260 | { |
3261 | 3261 | $identificador = '#257 <infQ> - '; |
3262 | 3262 | $this->infQ[] = $this->dom->createElement('infQ'); |
3263 | - $posicao = (integer)count($this->infQ) - 1; |
|
3263 | + $posicao = (integer) count($this->infQ) - 1; |
|
3264 | 3264 | $this->dom->addChild($this->infQ[$posicao], 'cUnid', $std->cUnid, true, $identificador . 'Código da |
3265 | 3265 | Unidade de Medida'); |
3266 | 3266 | $this->dom->addChild($this->infQ[$posicao], 'tpMed', $std->tpMed, true, $identificador . 'Tipo da Medida'); |
@@ -3305,7 +3305,7 @@ discard block |
||
3305 | 3305 | { |
3306 | 3306 | $identificador = '#262 <infNF> - '; |
3307 | 3307 | $this->infNF[] = $this->dom->createElement('infNF'); |
3308 | - $posicao = (integer)count($this->infNF) - 1; |
|
3308 | + $posicao = (integer) count($this->infNF) - 1; |
|
3309 | 3309 | |
3310 | 3310 | $this->dom->addChild($this->infNF[$posicao], 'nRoma', $std->nRoma, false, $identificador . 'Número do |
3311 | 3311 | Romaneio da NF'); |
@@ -3346,7 +3346,7 @@ discard block |
||
3346 | 3346 | { |
3347 | 3347 | $identificador = '#297 <infNFe> - '; |
3348 | 3348 | $this->infNFe[] = $this->dom->createElement('infNFe'); |
3349 | - $posicao = (integer)count($this->infNFe) - 1; |
|
3349 | + $posicao = (integer) count($this->infNFe) - 1; |
|
3350 | 3350 | $this->dom->addChild( |
3351 | 3351 | $this->infNFe[$posicao], |
3352 | 3352 | 'chave', |
@@ -3381,7 +3381,7 @@ discard block |
||
3381 | 3381 | { |
3382 | 3382 | $ident = '#319 <infOutros> - '; |
3383 | 3383 | $this->infOutros[] = $this->dom->createElement('infOutros'); |
3384 | - $posicao = (integer)count($this->infOutros) - 1; |
|
3384 | + $posicao = (integer) count($this->infOutros) - 1; |
|
3385 | 3385 | $this->dom->addChild($this->infOutros[$posicao], 'tpDoc', $std->tpDoc, true, $ident . 'Tipo ' |
3386 | 3386 | . 'de documento originário'); |
3387 | 3387 | $this->dom->addChild($this->infOutros[$posicao], 'descOutros', $std->descOutros, false, $ident . 'Descrição ' |
@@ -3406,7 +3406,7 @@ discard block |
||
3406 | 3406 | { |
3407 | 3407 | $ident = '#319 <infDocRef> - '; |
3408 | 3408 | $this->infDocRef[] = $this->dom->createElement('infDocRef'); |
3409 | - $posicao = (integer)count($this->infDocRef) - 1; |
|
3409 | + $posicao = (integer) count($this->infDocRef) - 1; |
|
3410 | 3410 | $this->dom->addChild($this->infDocRef[$posicao], 'nDoc', $std->nDoc, false, $ident . 'Número ' |
3411 | 3411 | . 'do documento'); |
3412 | 3412 | $this->dom->addChild($this->infDocRef[$posicao], 'serie', $std->serie, false, $ident . 'Série ' |
@@ -3429,7 +3429,7 @@ discard block |
||
3429 | 3429 | { |
3430 | 3430 | $identificador = '#345 <emiDocAnt> - '; |
3431 | 3431 | $this->emiDocAnt[] = $this->dom->createElement('emiDocAnt'); |
3432 | - $posicao = (integer)count($this->emiDocAnt) - 1; |
|
3432 | + $posicao = (integer) count($this->emiDocAnt) - 1; |
|
3433 | 3433 | if ($std->CNPJ != '') { |
3434 | 3434 | $this->dom->addChild( |
3435 | 3435 | $this->emiDocAnt[$posicao], |
@@ -3470,7 +3470,7 @@ discard block |
||
3470 | 3470 | { |
3471 | 3471 | $identificador = '#358 <idDocAntEle> - '; |
3472 | 3472 | $this->idDocAntEle[] = $this->dom->createElement('idDocAntEle'); |
3473 | - $posicao = (integer)count($this->idDocAntEle) - 1; |
|
3473 | + $posicao = (integer) count($this->idDocAntEle) - 1; |
|
3474 | 3474 | $this->dom->addChild($this->idDocAntEle[$posicao], 'chCTe', $std->chCTe, true, $identificador . 'Chave de ' |
3475 | 3475 | . 'Acesso do CT-e'); |
3476 | 3476 | |
@@ -3488,7 +3488,7 @@ discard block |
||
3488 | 3488 | { |
3489 | 3489 | $identificador = '#360 <seg> - '; |
3490 | 3490 | $this->seg[] = $this->dom->createElement('seg'); |
3491 | - $posicao = (integer)count($this->seg) - 1; |
|
3491 | + $posicao = (integer) count($this->seg) - 1; |
|
3492 | 3492 | |
3493 | 3493 | $this->dom->addChild($this->seg[$posicao], 'respSeg', $std->respSeg, true, $identificador . 'Responsável |
3494 | 3494 | pelo Seguro'); |
@@ -3780,7 +3780,7 @@ discard block |
||
3780 | 3780 | { |
3781 | 3781 | $identificador = '#21 <veic> - '; |
3782 | 3782 | $this->veic[] = $this->dom->createElement('veic'); |
3783 | - $posicao = (integer)count($this->veic) - 1; |
|
3783 | + $posicao = (integer) count($this->veic) - 1; |
|
3784 | 3784 | if ($std->cInt != '') { |
3785 | 3785 | $this->dom->addChild( |
3786 | 3786 | $this->veic[$posicao], |
@@ -3862,7 +3862,7 @@ discard block |
||
3862 | 3862 | ); |
3863 | 3863 | if ($std->tpProp == 'T') { // CASO FOR VEICULO DE TERCEIRO |
3864 | 3864 | $this->prop[] = $this->dom->createElement('prop'); |
3865 | - $p = (integer)count($this->prop) - 1; |
|
3865 | + $p = (integer) count($this->prop) - 1; |
|
3866 | 3866 | if ($std->CNPJ != '') { |
3867 | 3867 | $this->dom->addChild( |
3868 | 3868 | $this->prop[$p], |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | if ($compactar) { |
82 | 82 | $gzdata = base64_encode(gzencode($cons, 9, FORCE_GZIP)); |
83 | 83 | $body = "<cteDadosMsgZip xmlns=\"$this->urlNamespace\">$gzdata</cteDadosMsgZip>"; |
84 | - $method = $this->urlMethod."Zip"; |
|
84 | + $method = $this->urlMethod . "Zip"; |
|
85 | 85 | $parameters = ['cteDadosMsgZip' => $gzdata]; |
86 | 86 | $body = "<cteDadosMsgZip xmlns=\"$this->urlNamespace\">$gzdata</cteDadosMsgZip>"; |
87 | 87 | } |
@@ -374,9 +374,9 @@ discard block |
||
374 | 374 | } |
375 | 375 | //monta a consulta |
376 | 376 | $consulta = "<distDFeInt xmlns=\"$this->urlPortal\" versao=\"$this->urlVersion\">" |
377 | - . "<tpAmb>".$this->tpAmb."</tpAmb>" |
|
377 | + . "<tpAmb>" . $this->tpAmb . "</tpAmb>" |
|
378 | 378 | . "<cUFAutor>$cUF</cUFAutor>" |
379 | - . "<CNPJ>".$this->config->cnpj."</CNPJ>$tagNSU</distDFeInt>"; |
|
379 | + . "<CNPJ>" . $this->config->cnpj . "</CNPJ>$tagNSU</distDFeInt>"; |
|
380 | 380 | //valida o xml da requisição |
381 | 381 | $this->isValid($this->urlVersion, $consulta, 'distDFeInt'); |
382 | 382 | $this->lastRequest = $consulta; |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | $dt = new \DateTime(); |
667 | 667 | $dhEvento = $dt->format('Y-m-d\TH:i:sP'); |
668 | 668 | $sSeqEvento = str_pad($nSeqEvento, 2, "0", STR_PAD_LEFT); |
669 | - $eventId = "ID".$tpEvento.$chave.$sSeqEvento; |
|
669 | + $eventId = "ID" . $tpEvento . $chave . $sSeqEvento; |
|
670 | 670 | $cOrgao = UFList::getCodeByUF($uf); |
671 | 671 | |
672 | 672 | $request = "<eventoCTe xmlns=\"$this->urlPortal\" versao=\"$this->urlVersion\">" |
@@ -731,9 +731,9 @@ discard block |
||
731 | 731 | $tagChave = "<consChNFe><chNFe>$chave</chNFe></consChNFe>"; |
732 | 732 | //monta a consulta |
733 | 733 | $consulta = "<distDFeInt xmlns=\"$this->urlPortal\" versao=\"$this->urlVersion\">" |
734 | - . "<tpAmb>".$this->tpAmb."</tpAmb>" |
|
734 | + . "<tpAmb>" . $this->tpAmb . "</tpAmb>" |
|
735 | 735 | . "<cUFAutor>$cUF</cUFAutor>" |
736 | - . "<CNPJ>".$this->config->cnpj."</CNPJ>$tagChave</distDFeInt>"; |
|
736 | + . "<CNPJ>" . $this->config->cnpj . "</CNPJ>$tagChave</distDFeInt>"; |
|
737 | 737 | //valida o xml da requisição |
738 | 738 | $this->isValid($this->urlVersion, $consulta, 'distDFeInt'); |
739 | 739 | $this->lastRequest = $consulta; |
@@ -785,8 +785,8 @@ discard block |
||
785 | 785 | . "<indOp>$indOp</indOp>" |
786 | 786 | . "<raizCNPJ>$raizCNPJ</raizCNPJ>" |
787 | 787 | . "<dadosCsc>" |
788 | - . "<idCsc>".$this->config->CSCid."</idCsc>" |
|
789 | - . "<codigoCsc>".$this->config->CSC."</codigoCsc>" |
|
788 | + . "<idCsc>" . $this->config->CSCid . "</idCsc>" |
|
789 | + . "<codigoCsc>" . $this->config->CSC . "</codigoCsc>" |
|
790 | 790 | . "</dadosCsc>" |
791 | 791 | . "</admCscNFCe>"; |
792 | 792 | } |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | $dom->loadXML($cte); |
818 | 818 | //verifica a validade no webservice da SEFAZ |
819 | 819 | $tpAmb = $dom->getElementsByTagName('tpAmb')->item(0)->nodeValue; |
820 | - $infCTe = $dom->getElementsByTagName('infCte')->item(0); |
|
820 | + $infCTe = $dom->getElementsByTagName('infCte')->item(0); |
|
821 | 821 | $chCTe = preg_replace('/[^0-9]/', '', $infCTe->getAttribute("Id")); |
822 | 822 | $protocol = $dom->getElementsByTagName('nProt')->item(0)->nodeValue; |
823 | 823 | $digval = $dom->getElementsByTagName('DigestValue')->item(0)->nodeValue; |