@@ -109,15 +109,15 @@ |
||
109 | 109 | if (substr($linha, 0, 2) == 'A|') { |
110 | 110 | $resp[$xCount]['init'] = $iCount; |
111 | 111 | if ($xCount > 0) { |
112 | - $resp[$xCount -1]['fim'] = $iCount; |
|
112 | + $resp[$xCount - 1]['fim'] = $iCount; |
|
113 | 113 | } |
114 | 114 | $xCount += 1; |
115 | 115 | } |
116 | 116 | $iCount += 1; |
117 | 117 | } |
118 | - $resp[$xCount-1]['fim'] = $iCount; |
|
118 | + $resp[$xCount - 1]['fim'] = $iCount; |
|
119 | 119 | foreach ($resp as $marc) { |
120 | - $length = $marc['fim']-$marc['init']; |
|
120 | + $length = $marc['fim'] - $marc['init']; |
|
121 | 121 | $aNotas[] = array_slice($array, $marc['init'], $length, false); |
122 | 122 | } |
123 | 123 | return $aNotas; |
@@ -75,7 +75,7 @@ |
||
75 | 75 | $cNF |
76 | 76 | ); |
77 | 77 | $ide->getElementsByTagName('cDV')->item(0)->nodeValue = substr($chave, -1); |
78 | - $infNFe->setAttribute('Id', 'NFe'.$chave); |
|
78 | + $infNFe->setAttribute('Id', 'NFe' . $chave); |
|
79 | 79 | return Strings::clearXmlString($dom->saveXML(), true); |
80 | 80 | } |
81 | 81 | } |
@@ -66,7 +66,7 @@ |
||
66 | 66 | $html .= '<h2>body</h2>'; |
67 | 67 | $html .= str_replace( |
68 | 68 | ['<', '>'], |
69 | - ['<','>'], |
|
69 | + ['<', '>'], |
|
70 | 70 | str_replace( |
71 | 71 | '<?xml version="1.0"?>', |
72 | 72 | '<?xml version="1.0" encoding="UTF-8"?>', |
@@ -144,16 +144,16 @@ discard block |
||
144 | 144 | $tpEmis, |
145 | 145 | $cDest |
146 | 146 | ) { |
147 | - $ver = $versao/100; |
|
147 | + $ver = $versao / 100; |
|
148 | 148 | $cscId = (int) $idToken; |
149 | 149 | $csc = $token; |
150 | 150 | if (strpos($url, '?p=') === false) { |
151 | - $url = $url.'?p='; |
|
151 | + $url = $url . '?p='; |
|
152 | 152 | } |
153 | 153 | if ($tpEmis != 9) { |
154 | 154 | //emissão on-line |
155 | 155 | $seq = "$chNFe|$ver|$tpAmb|$cscId"; |
156 | - $hash = strtoupper(sha1($seq.$csc)); |
|
156 | + $hash = strtoupper(sha1($seq . $csc)); |
|
157 | 157 | return "$url$seq|$hash"; |
158 | 158 | } |
159 | 159 | //emissão off-line |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $valor = number_format($vNF, 2, '.', ''); |
163 | 163 | $digHex = self::str2Hex($digVal); |
164 | 164 | $seq = "$chNFe|$ver|$tpAmb|$dia|$valor|$digHex|$cscId"; |
165 | - $hash = strtoupper(sha1($seq.$csc)); |
|
165 | + $hash = strtoupper(sha1($seq . $csc)); |
|
166 | 166 | return "$url$seq|$hash"; |
167 | 167 | } |
168 | 168 |
@@ -46,9 +46,9 @@ |
||
46 | 46 | */ |
47 | 47 | protected static function validInputData($data) |
48 | 48 | { |
49 | - $filejsonschema = __DIR__. "/../../storage/config.schema"; |
|
49 | + $filejsonschema = __DIR__ . "/../../storage/config.schema"; |
|
50 | 50 | $validator = new JsonValid(); |
51 | - $validator->check($data, (object)['$ref' => 'file://' . $filejsonschema]); |
|
51 | + $validator->check($data, (object) ['$ref' => 'file://' . $filejsonschema]); |
|
52 | 52 | if (!$validator->isValid()) { |
53 | 53 | $msg = ""; |
54 | 54 | foreach ($validator->getErrors() as $error) { |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * Canonical conversion options |
98 | 98 | * @var array |
99 | 99 | */ |
100 | - protected $canonical = [true,false,null,null]; |
|
100 | + protected $canonical = [true, false, null, null]; |
|
101 | 101 | /** |
102 | 102 | * Model of NFe 55 or 65 |
103 | 103 | * @var int |
@@ -299,8 +299,8 @@ discard block |
||
299 | 299 | $this->versao = $version; |
300 | 300 | $this->config->schemes = $this->availableVersions[$version]; |
301 | 301 | $this->pathschemes = realpath( |
302 | - __DIR__ . '/../../schemes/'. $this->config->schemes |
|
303 | - ).'/'; |
|
302 | + __DIR__ . '/../../schemes/' . $this->config->schemes |
|
303 | + ) . '/'; |
|
304 | 304 | |
305 | 305 | return $this->versao; |
306 | 306 | } |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | */ |
401 | 401 | protected function isValid($version, $body, $method) |
402 | 402 | { |
403 | - $schema = $this->pathschemes.$method."_v$version.xsd"; |
|
403 | + $schema = $this->pathschemes . $method . "_v$version.xsd"; |
|
404 | 404 | if (!is_file($schema)) { |
405 | 405 | return true; |
406 | 406 | } |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | } |
548 | 548 | |
549 | 549 | $path = $this->pathwsfiles . $file; |
550 | - if (! file_exists($path)) { |
|
550 | + if (!file_exists($path)) { |
|
551 | 551 | return ''; |
552 | 552 | } |
553 | 553 | return file_get_contents($path); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $comp = "_v1.2"; |
122 | 122 | } |
123 | 123 | $this->baselayout = $baselayout; |
124 | - $path = realpath(__DIR__."/../../storage/txtstructure$ver" . $comp . ".json"); |
|
124 | + $path = realpath(__DIR__ . "/../../storage/txtstructure$ver" . $comp . ".json"); |
|
125 | 125 | $this->structure = json_decode(file_get_contents($path), true); |
126 | 126 | $this->make = new Make(); |
127 | 127 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | if (empty($fields)) { |
153 | 153 | continue; |
154 | 154 | } |
155 | - $metodo = strtolower(str_replace(' ', '', $fields[0])).'Entity'; |
|
155 | + $metodo = strtolower(str_replace(' ', '', $fields[0])) . 'Entity'; |
|
156 | 156 | if (!method_exists(__CLASS__, $metodo)) { |
157 | 157 | throw DocumentsException::wrongDocument(16, $lin); //campo não definido |
158 | 158 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | protected static function fieldsToStd($dfls, $struct) |
172 | 172 | { |
173 | 173 | $sfls = explode('|', $struct); |
174 | - $len = count($sfls)-1; |
|
174 | + $len = count($sfls) - 1; |
|
175 | 175 | $std = new \stdClass(); |
176 | 176 | for ($i = 1; $i < $len; $i++) { |
177 | 177 | $name = $sfls[$i]; |
@@ -1222,7 +1222,7 @@ discard block |
||
1222 | 1222 | $this->stdPIS->CST = $std->CST; |
1223 | 1223 | $this->stdPIS->vPIS = $std->vPIS; |
1224 | 1224 | $this->stdPIS->qBCProd = $std->qBCProd; |
1225 | - $this->stdPIS->vAliqProd = $std->vAliqProd; |
|
1225 | + $this->stdPIS->vAliqProd = $std->vAliqProd; |
|
1226 | 1226 | $this->buildQEntity(); |
1227 | 1227 | } |
1228 | 1228 | |
@@ -1273,7 +1273,7 @@ discard block |
||
1273 | 1273 | protected function q10Entity($std) |
1274 | 1274 | { |
1275 | 1275 | $this->stdPIS->qBCProd = $std->qBCProd; |
1276 | - $this->stdPIS->vAliqProd = $std->vAliqProd; |
|
1276 | + $this->stdPIS->vAliqProd = $std->vAliqProd; |
|
1277 | 1277 | $this->buildQEntity(); |
1278 | 1278 | } |
1279 | 1279 |
@@ -17,9 +17,9 @@ discard block |
||
17 | 17 | |
18 | 18 | class ValidTXT |
19 | 19 | { |
20 | - const LOCAL="LOCAL"; |
|
20 | + const LOCAL = "LOCAL"; |
|
21 | 21 | const LOCAL_V12 = "LOCAL_V12"; |
22 | - const SEBRAE="SEBRAE"; |
|
22 | + const SEBRAE = "SEBRAE"; |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Loads structure of txt from json file in storage folder |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | } elseif (strtoupper($baselayout) === 'LOCAL_V12') { |
38 | 38 | $comp = '_v1.2'; |
39 | 39 | } |
40 | - $file = $path . '/txtstructure' . ($version*100) . $comp . '.json'; |
|
40 | + $file = $path . '/txtstructure' . ($version * 100) . $comp . '.json'; |
|
41 | 41 | if (!is_file($file)) { |
42 | 42 | throw new \InvalidArgumentException("O arquivo de estrutura para a " |
43 | 43 | . "versão de layout indicada no TXT, não foi encontrado [$file]."); |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | $errors[] = "ERRO: ($num) Essa referência não está definida. [$row]"; |
103 | 103 | continue; |
104 | 104 | } |
105 | - $count = count($fields)-1; |
|
106 | - $default = count(explode('|', $entities[$ref]))-1; |
|
105 | + $count = count($fields) - 1; |
|
106 | + $default = count(explode('|', $entities[$ref])) - 1; |
|
107 | 107 | if ($default !== $count) { |
108 | 108 | $errors[] = "ERRO: ($num) O número de parâmetros na linha " |
109 | 109 | . "está errado (esperado #$default) -> (encontrado #$count). [ $row ] Esperado [ " |
110 | - . $entities[$ref]." ]"; |
|
110 | + . $entities[$ref] . " ]"; |
|
111 | 111 | continue; |
112 | 112 | } |
113 | 113 | foreach ($fields as $field) { |
@@ -129,15 +129,15 @@ discard block |
||
129 | 129 | continue; |
130 | 130 | } |
131 | 131 | $newfield = preg_replace( |
132 | - '/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]'. |
|
133 | - '|[\x00-\x7F][\x80-\xBF]+'. |
|
134 | - '|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*'. |
|
135 | - '|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})'. |
|
132 | + '/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]' . |
|
133 | + '|[\x00-\x7F][\x80-\xBF]+' . |
|
134 | + '|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*' . |
|
135 | + '|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})' . |
|
136 | 136 | '|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/S', |
137 | 137 | '?', |
138 | 138 | $field |
139 | 139 | ); |
140 | - $newfield = preg_replace('/\xE0[\x80-\x9F][\x80-\xBF]'. |
|
140 | + $newfield = preg_replace('/\xE0[\x80-\x9F][\x80-\xBF]' . |
|
141 | 141 | '|\xED[\xA0-\xBF][\x80-\xBF]/S', '?', $newfield); |
142 | 142 | if ($field != $newfield) { |
143 | 143 | $errors[] = "ERRO: ($num) Existem caracteres não UTF-8, não permitidos, " |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | . "</infCons>" |
278 | 278 | . "</ConsCad>"; |
279 | 279 | if (strtoupper($uf) == 'MT') { |
280 | - $request = "<nfeDadosMsg>$request</nfeDadosMsg>" ; |
|
280 | + $request = "<nfeDadosMsg>$request</nfeDadosMsg>"; |
|
281 | 281 | } |
282 | 282 | $this->isValid($this->urlVersion, $request, 'consCad'); |
283 | 283 | $this->lastRequest = $request; |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | } |
353 | 353 | //monta a consulta |
354 | 354 | $consulta = "<distDFeInt xmlns=\"$this->urlPortal\" versao=\"$this->urlVersion\">" |
355 | - . "<tpAmb>".$this->tpAmb."</tpAmb>" |
|
355 | + . "<tpAmb>" . $this->tpAmb . "</tpAmb>" |
|
356 | 356 | . "<cUFAutor>$cUF</cUFAutor>"; |
357 | 357 | if ($this->typePerson === 'J') { |
358 | 358 | $consulta .= "<CNPJ>$cnpj</CNPJ>"; |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | foreach ($interessados as $aut) { |
435 | 435 | $obj = (object) $aut; |
436 | 436 | $tagAdic .= "<autXML>"; |
437 | - $tagAdic .= !empty($obj->CNPJ) |
|
437 | + $tagAdic .= !empty($obj->CNPJ) |
|
438 | 438 | ? "<CNPJ>{$obj->CNPJ}</CNPJ>" |
439 | 439 | : "<CPF>{$obj->CPF}</CPF>"; |
440 | 440 | $tagAdic .= "<tpAutorizacao>{$obj->tpAutorizacao}</tpAutorizacao>" |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | $dt = new \DateTime('now', new \DateTimeZone($this->timezone)); |
669 | 669 | $dhEvento = $dt->format('Y-m-d\TH:i:sP'); |
670 | 670 | $sSeqEvento = str_pad($evt->nSeqEvento, 2, "0", STR_PAD_LEFT); |
671 | - $eventId = "ID".$evt->tpEvento.$evt->chave.$sSeqEvento; |
|
671 | + $eventId = "ID" . $evt->tpEvento . $evt->chave . $sSeqEvento; |
|
672 | 672 | $cOrgao = UFList::getCodeByUF($uf); |
673 | 673 | $request = "<evento xmlns=\"$this->urlPortal\" versao=\"$this->urlVersion\">" |
674 | 674 | . "<infEvento Id=\"$eventId\">" |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | $dt = new \DateTime(date("Y-m-d H:i:sP"), new \DateTimeZone($this->timezone)); |
816 | 816 | $dhEvento = $dt->format('Y-m-d\TH:i:sP'); |
817 | 817 | $sSeqEvento = str_pad($nSeqEvento, 2, "0", STR_PAD_LEFT); |
818 | - $eventId = "ID".$tpEvento.$chave.$sSeqEvento; |
|
818 | + $eventId = "ID" . $tpEvento . $chave . $sSeqEvento; |
|
819 | 819 | $cOrgao = UFList::getCodeByUF($uf); |
820 | 820 | $request = "<evento xmlns=\"$this->urlPortal\" versao=\"$this->urlVersion\">" |
821 | 821 | . "<infEvento Id=\"$eventId\">" |
@@ -847,7 +847,7 @@ discard block |
||
847 | 847 | $this->canonical |
848 | 848 | ); |
849 | 849 | $request = Strings::clearXmlString($request, true); |
850 | - $lote = $dt->format('YmdHis').rand(0, 9); |
|
850 | + $lote = $dt->format('YmdHis') . rand(0, 9); |
|
851 | 851 | $request = "<envEvento xmlns=\"$this->urlPortal\" versao=\"$this->urlVersion\">" |
852 | 852 | . "<idLote>$lote</idLote>" |
853 | 853 | . $request |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | $cnpj = $this->config->cnpj; |
884 | 884 | //monta a consulta |
885 | 885 | $request = "<distDFeInt xmlns=\"$this->urlPortal\" versao=\"$this->urlVersion\">" |
886 | - . "<tpAmb>".$this->tpAmb."</tpAmb>" |
|
886 | + . "<tpAmb>" . $this->tpAmb . "</tpAmb>" |
|
887 | 887 | . "<cUFAutor>$cUF</cUFAutor>"; |
888 | 888 | if ($this->typePerson === 'J') { |
889 | 889 | $request .= "<CNPJ>$cnpj</CNPJ>"; |
@@ -941,8 +941,8 @@ discard block |
||
941 | 941 | . "<indOp>$indOp</indOp>" |
942 | 942 | . "<raizCNPJ>$raizCNPJ</raizCNPJ>" |
943 | 943 | . "<dadosCsc>" |
944 | - . "<idCsc>".$this->config->CSCid."</idCsc>" |
|
945 | - . "<codigoCsc>".$this->config->CSC."</codigoCsc>" |
|
944 | + . "<idCsc>" . $this->config->CSCid . "</idCsc>" |
|
945 | + . "<codigoCsc>" . $this->config->CSC . "</codigoCsc>" |
|
946 | 946 | . "</dadosCsc>" |
947 | 947 | . "</admCscNFCe>"; |
948 | 948 | } |
@@ -974,7 +974,7 @@ discard block |
||
974 | 974 | $dom->loadXML($nfe); |
975 | 975 | //verifica a validade no webservice da SEFAZ |
976 | 976 | $tpAmb = $dom->getElementsByTagName('tpAmb')->item(0)->nodeValue; |
977 | - $infNFe = $dom->getElementsByTagName('infNFe')->item(0); |
|
977 | + $infNFe = $dom->getElementsByTagName('infNFe')->item(0); |
|
978 | 978 | $chNFe = preg_replace('/[^0-9]/', '', $infNFe->getAttribute("Id")); |
979 | 979 | $protocol = $dom->getElementsByTagName('nProt')->item(0)->nodeValue; |
980 | 980 | $digval = $dom->getElementsByTagName('DigestValue')->item(0)->nodeValue; |