| Total Complexity | 40 | 
| Total Lines | 564 | 
| Duplicated Lines | 0 % | 
| Changes | 2 | ||
| Bugs | 0 | Features | 0 | 
Complex classes like NFePHP often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use NFePHP, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 16 | class NFePHP  | 
            ||
| 17 | { | 
            ||
| 18 | protected $make;  | 
            ||
| 19 | protected $model;  | 
            ||
| 20 | protected $tools;  | 
            ||
| 21 | protected $version;  | 
            ||
| 22 | |||
| 23 | public function __construct(  | 
            ||
| 24 | protected EntityManagerInterface $manager,  | 
            ||
| 25 | protected Security $security,  | 
            ||
| 26 | protected KernelInterface $appKernel  | 
            ||
| 27 |     ) { | 
            ||
| 28 | }  | 
            ||
| 29 | |||
| 30 | //ide OBRIGATÓRIA  | 
            ||
| 31 | protected function makeIde(Order $order)  | 
            ||
| 32 |     { | 
            ||
| 33 | $provider = $order->getProvider();  | 
            ||
| 34 | $document = $provider->getOneDocument();  | 
            ||
| 35 |         //$dhEmi = date("Y-m-d\TH:i:s-03:00"); Para obter a data com diferença de fuso usar 'P' | 
            ||
| 36 |         $dhEmi = date("Y-m-d\TH:i:sP"); | 
            ||
| 37 | |||
| 38 | $numeroCTE = $this->getLastDacte();  | 
            ||
| 39 | |||
| 40 | // CUIDADO: Observe que mesmo os parâmetros fixados abaixo devem ser preenchidos conforme os dados do CT-e, estude a composição da CHAVE para saber o que vai em cada campo  | 
            ||
| 41 | $chave = $this->montaChave(  | 
            ||
| 42 | '43',  | 
            ||
| 43 |             date('y', strtotime($dhEmi)), | 
            ||
| 44 |             date('m', strtotime($dhEmi)), | 
            ||
| 45 | $document->getDOcument(),  | 
            ||
| 46 | $this->tools->model(),  | 
            ||
| 47 | '1',  | 
            ||
| 48 | $numeroCTE,  | 
            ||
| 49 | '1',  | 
            ||
| 50 | '10'  | 
            ||
| 51 | );  | 
            ||
| 52 | |||
| 53 | $cDV = substr($chave, -1); //Digito Verificador  | 
            ||
| 54 | |||
| 55 | /**  | 
            ||
| 56 | * @todo  | 
            ||
| 57 | */  | 
            ||
| 58 | $ide = new \stdClass();  | 
            ||
| 59 | $ide->cUF = '43'; // Codigo da UF da tabela do IBGE  | 
            ||
| 60 | $ide->cCT = '99999999'; // Codigo numerico que compoe a chave de acesso  | 
            ||
| 61 | $ide->CFOP = '6932'; // Codigo fiscal de operacoes e prestacoes  | 
            ||
| 62 | $ide->natOp = 'PRESTACAO DE SERVICO DE TRANSPORTE A ESTABELECIMENTO FORA DO ESTADO DE ORIGEM'; // Natureza da operacao  | 
            ||
| 63 | |||
| 64 | /**  | 
            ||
| 65 | * @todo  | 
            ||
| 66 | */  | 
            ||
| 67 | |||
| 68 | //$ide->forPag = ''; // 0-Pago; 1-A pagar; 2-Outros  | 
            ||
| 69 | $ide->mod = '57'; // Modelo do documento fiscal: 57 para identificação do CT-e  | 
            ||
| 70 | $ide->serie = '1'; // Serie do CTe  | 
            ||
| 71 | $ide->nCT = $numeroCTE; // Numero do CTe  | 
            ||
| 72 | $ide->dhEmi = $dhEmi; // Data e hora de emissão do CT-e: Formato AAAA-MM-DDTHH:MM:DD  | 
            ||
| 73 | $ide->tpImp = '1'; // Formato de impressao do DACTE: 1-Retrato; 2-Paisagem.  | 
            ||
| 74 | $ide->tpEmis = '1'; // Forma de emissao do CTe: 1-Normal; 4-EPEC pela SVC; 5-Contingência  | 
            ||
| 75 | $ide->cDV = $cDV; // Codigo verificador  | 
            ||
| 76 | $ide->tpAmb = '2'; // 1- Producao; 2-homologacao  | 
            ||
| 77 | $ide->tpCTe = '0'; // 0- CT-e Normal; 1 - CT-e de Complemento de Valores;  | 
            ||
| 78 | // 2 -CT-e de Anulação; 3 - CT-e Substituto  | 
            ||
| 79 | $ide->procEmi = '0'; // Descricao no comentario acima  | 
            ||
| 80 | $ide->verProc = '3.0'; // versao do aplicativo emissor  | 
            ||
| 81 | $ide->indGlobalizado = '';  | 
            ||
| 82 | //$ide->refCTE = ''; // Chave de acesso do CT-e referenciado  | 
            ||
| 83 | $ide->xMunEnv = 'FOZ DO IGUACU'; // Informar PAIS/Municipio para as operações com o exterior.  | 
            ||
| 84 | $ide->UFEnv = 'RS'; // Informar 'EX' para operações com o exterior.  | 
            ||
| 85 | $ide->modal = '01'; // Preencher com:01-Rodoviário; 02-Aéreo; 03-Aquaviário;04-  | 
            ||
| 86 | $ide->tpServ = '0'; // 0- Normal; 1- Subcontratação; 2- Redespacho;  | 
            ||
| 87 | $ide->cMunEnv = $this->getCodMunicipio($ide->xMunEnv, $ide->UFEnv); // Código do município (utilizar a tabela do IBGE)  | 
            ||
| 88 | |||
| 89 | |||
| 90 | /**  | 
            ||
| 91 | * @todo  | 
            ||
| 92 | */  | 
            ||
| 93 | // 3- Redespacho Intermediário; 4- Serviço Vinculado a Multimodal  | 
            ||
| 94 | $ide->xMunIni = 'FOZ DO IGUACU'; // Informar 'EXTERIOR' para operações com o exterior.  | 
            ||
| 95 | $ide->UFIni = 'RS'; // Informar 'EX' para operações com o exterior.  | 
            ||
| 96 | $ide->cMunFim = '3523909'; // Utilizar a tabela do IBGE. Informar 9999999 para operações com o exterior.  | 
            ||
| 97 | $ide->cMunFim = $this->getCodMunicipio($ide->xMunIni, $ide->UFIni); // Código do município (utilizar a tabela do IBGE)  | 
            ||
| 98 | |||
| 99 | |||
| 100 | /**  | 
            ||
| 101 | * @todo  | 
            ||
| 102 | */  | 
            ||
| 103 | $ide->xMunFim = 'ITU'; // Informar 'EXTERIOR' para operações com o exterior.  | 
            ||
| 104 | $ide->UFFim = 'SP'; // Informar 'EX' para operações com o exterior.  | 
            ||
| 105 | $ide->cMunIni = $this->getCodMunicipio($ide->xMunFim, $ide->UFFim); // Código do município (utilizar a tabela do IBGE)  | 
            ||
| 106 | |||
| 107 | $ide->retira = '1'; // Indicador se o Recebedor retira no Aeroporto; Filial,  | 
            ||
| 108 | // Porto ou Estação de Destino? 0-sim; 1-não  | 
            ||
| 109 | $ide->xDetRetira = ''; // Detalhes do retira  | 
            ||
| 110 | $ide->indIEToma = '1';  | 
            ||
| 111 | $ide->dhCont = ''; // Data e Hora da entrada em contingência; no formato AAAAMM-DDTHH:MM:SS  | 
            ||
| 112 | $ide->xJust = ''; // Justificativa da entrada em contingência  | 
            ||
| 113 | |||
| 114 | $this->make->tagide($ide);  | 
            ||
| 115 | }  | 
            ||
| 116 | |||
| 117 | |||
| 118 | //toma OBRIGATÓRIA  | 
            ||
| 119 | protected function makeTomador(Order $order)  | 
            ||
| 120 |     { | 
            ||
| 121 | |||
| 122 | |||
| 123 | |||
| 124 | // Indica o "papel" do tomador: 0-Remetente; 1-Expedidor; 2-Recebedor; 3-Destinatário  | 
            ||
| 125 | $toma3 = new \stdClass();  | 
            ||
| 126 | $toma3->toma = '3';  | 
            ||
| 127 | $this->make->tagtoma3($toma3);  | 
            ||
| 128 | //  | 
            ||
| 129 | //$toma4 = new stdClass();  | 
            ||
| 130 | //$toma4->toma = '4'; // 4-Outros; informar os dados cadastrais do tomador quando ele for outros  | 
            ||
| 131 | //$toma4->CNPJ = '11509962000197'; // CNPJ  | 
            ||
| 132 | //$toma4->CPF = ''; // CPF  | 
            ||
| 133 | //$toma4->IE = 'ISENTO'; // Iscricao estadual  | 
            ||
| 134 | //$toma4->xNome = 'RAZAO SOCIAL'; // Razao social ou Nome  | 
            ||
| 135 | //$toma4->xFant = 'NOME FANTASIA'; // Nome fantasia  | 
            ||
| 136 | //$toma4->fone = '5532128202'; // Telefone  | 
            ||
| 137 | //$toma4->email = '[email protected]'; // email  | 
            ||
| 138 | //$cte->tagtoma4($toma4);  | 
            ||
| 139 | |||
| 140 | //endertoma OBRIGATÓRIA  | 
            ||
| 141 | $this->makeTomadorAddress($order);  | 
            ||
| 142 | }  | 
            ||
| 143 | |||
| 144 | protected function makeTomadorAddress(Order $order)  | 
            ||
| 145 |     { | 
            ||
| 146 | |||
| 147 | /**  | 
            ||
| 148 | * @todo  | 
            ||
| 149 | */  | 
            ||
| 150 | $enderToma = new \stdClass();  | 
            ||
| 151 | $enderToma->xLgr = 'Avenida Independência'; // Logradouro  | 
            ||
| 152 | $enderToma->nro = '482'; // Numero  | 
            ||
| 153 | $enderToma->xCpl = ''; // COmplemento  | 
            ||
| 154 | $enderToma->xBairro = 'Centro'; // Bairro  | 
            ||
| 155 | $enderToma->cMun = '4308607'; // Codigo do municipio do IBEGE Informar 9999999 para operações com o exterior  | 
            ||
| 156 | $enderToma->xMun = 'Garibaldi'; // Nome do município (Informar EXTERIOR para operações com o exterior.  | 
            ||
| 157 | $enderToma->CEP = '95720000'; // CEP  | 
            ||
| 158 | $enderToma->UF = 'SP'; //$arr['siglaUF']; // Sigla UF (Informar EX para operações com o exterior.)  | 
            ||
| 159 | $enderToma->cPais = '1058'; // Codigo do país ( Utilizar a tabela do BACEN )  | 
            ||
| 160 | $enderToma->xPais = 'Brasil'; // Nome do pais  | 
            ||
| 161 | $this->make->tagenderToma($enderToma);  | 
            ||
| 162 | }  | 
            ||
| 163 | |||
| 164 | //emit OBRIGATÓRIA  | 
            ||
| 165 | protected function makeEmit(Order $order)  | 
            ||
| 166 |     { | 
            ||
| 167 | $provider = $order->getProvider();  | 
            ||
| 168 | $document = $provider->getOneDocument();  | 
            ||
| 169 | |||
| 170 | $std = new \stdClass();  | 
            ||
| 171 | $std->IE = '111111111';  | 
            ||
| 172 | $std->IEST = null;  | 
            ||
| 173 | //$std->IM = '95095870';  | 
            ||
| 174 | $std->CNAE = '4642701';  | 
            ||
| 175 | $std->CRT = 1;  | 
            ||
| 176 | $std->CNPJ = '99999999999999';  | 
            ||
| 177 | //$std->CPF = '12345678901'; //NÃO PASSE TAGS QUE NÃO EXISTEM NO CASO  | 
            ||
| 178 | |||
| 179 | $emit = new \stdClass();  | 
            ||
| 180 | $emit->CNPJ = $document->getDOcument(); // CNPJ do emitente  | 
            ||
| 181 | //$emit->IE = '0100072968'; // Inscricao estadual  | 
            ||
| 182 | //$emit->IEST = ""; // Inscricao estadual  | 
            ||
| 183 | $emit->xNome = $provider->getName(); // Razao social  | 
            ||
| 184 | $emit->xFant = $provider->getAlias(); // Nome fantasia  | 
            ||
| 185 | |||
| 186 | $this->make->tagemit($std);  | 
            ||
| 187 | |||
| 188 | //enderEmit OBRIGATÓRIA  | 
            ||
| 189 | $this->makeEmitAddress($order);  | 
            ||
| 190 | }  | 
            ||
| 191 | |||
| 192 | protected function makeEmitAddress(Order $order)  | 
            ||
| 193 |     { | 
            ||
| 194 | $provider = $order->getProvider();  | 
            ||
| 195 | /**  | 
            ||
| 196 | * @var \ControleOnline\Entity\Address $providerAddress  | 
            ||
| 197 | */  | 
            ||
| 198 | $providerAddress = $provider->getAddress()[0];  | 
            ||
| 199 | |||
| 200 | $enderEmit = new \stdClass();  | 
            ||
| 201 | $enderEmit->xLgr = $providerAddress->getStreet()->getStreet(); // Logradouro  | 
            ||
| 202 | $enderEmit->nro = $providerAddress->getNumber(); // Numero  | 
            ||
| 203 | $enderEmit->xCpl = $providerAddress->getComplement(); // Complemento  | 
            ||
| 204 | $enderEmit->xBairro = $providerAddress->getStreet()->getDistrict()->getDistrict(); // Bairro  | 
            ||
| 205 | $enderEmit->xMun = $providerAddress->getStreet()->getDistrict()->getCity()->getCity(); // Nome do municipio  | 
            ||
| 206 | $enderEmit->CEP = $providerAddress->getStreet()->getCep()->getCep(); // CEP  | 
            ||
| 207 | $enderEmit->UF = $providerAddress->getStreet()->getDistrict()->getCity()->getState()->getUf(); // Sigla UF  | 
            ||
| 208 | $enderEmit->cMun = $this->getCodMunicipio($enderEmit->xMun, $enderEmit->UF); // Código do município (utilizar a tabela do IBGE)  | 
            ||
| 209 | $enderEmit->fone = $provider->getPhone()[0]->getDdd() . $provider->getPhone()[0]->getPhone(); // Fone  | 
            ||
| 210 | $this->make->tagenderemit($enderEmit);  | 
            ||
| 211 | }  | 
            ||
| 212 | //dest OPCIONAL  | 
            ||
| 213 | protected function makeDest(Order $order)  | 
            ||
| 214 |     { | 
            ||
| 215 | $std = new \stdClass();  | 
            ||
| 216 | $std->xNome = 'Eu Ltda';  | 
            ||
| 217 | $std->CNPJ = '01234123456789';  | 
            ||
| 218 | //$std->CPF = '12345678901';  | 
            ||
| 219 | //$std->idEstrangeiro = 'AB1234';  | 
            ||
| 220 | $std->indIEDest = 9;  | 
            ||
| 221 | //$std->IE = '';  | 
            ||
| 222 | //$std->ISUF = '12345679';  | 
            ||
| 223 | //$std->IM = 'XYZ6543212';  | 
            ||
| 224 | $std->email = '[email protected]';  | 
            ||
| 225 | $dest = $this->make->tagdest($std);  | 
            ||
| 226 | |||
| 227 | |||
| 228 | $this->makeDestAddress($order);  | 
            ||
| 229 | }  | 
            ||
| 230 | //enderDest OPCIONAL  | 
            ||
| 231 | protected function makeDestAddress(Order $order)  | 
            ||
| 232 |     { | 
            ||
| 233 | |||
| 234 | $std = new \stdClass();  | 
            ||
| 235 | $std->xLgr = 'Avenida Sebastião Diniz';  | 
            ||
| 236 | $std->nro = '458';  | 
            ||
| 237 | $std->xCpl = null;  | 
            ||
| 238 | $std->xBairro = 'CENTRO';  | 
            ||
| 239 | $std->cMun = 1400100;  | 
            ||
| 240 | $std->xMun = 'Boa Vista';  | 
            ||
| 241 | $std->UF = 'RR';  | 
            ||
| 242 | $std->CEP = '69301088';  | 
            ||
| 243 | $std->cPais = 1058;  | 
            ||
| 244 | $std->xPais = 'Brasil';  | 
            ||
| 245 | $std->fone = '1111111111';  | 
            ||
| 246 | $this->make->tagenderdest($std);  | 
            ||
| 247 | }  | 
            ||
| 248 | |||
| 249 | //prod OBRIGATÓRIA  | 
            ||
| 250 | protected function makeProds(Order $order)  | 
            ||
| 251 |     { | 
            ||
| 252 | $orderProducts = $order->getOrderProducts();  | 
            ||
| 253 | $item = 1;  | 
            ||
| 254 |         foreach ($orderProducts as $orderProducts) { | 
            ||
| 255 | $product = $orderProducts->getProduct();  | 
            ||
| 256 | |||
| 257 | $std = new \stdClass();  | 
            ||
| 258 | $std->item = $item;  | 
            ||
| 259 | $std->cProd = '00341';  | 
            ||
| 260 | $std->cEAN = 'SEM GTIN';  | 
            ||
| 261 | $std->cEANTrib = 'SEM GTIN';  | 
            ||
| 262 | $std->xProd = 'Produto com serviço';  | 
            ||
| 263 | $std->NCM = '96081000';  | 
            ||
| 264 | $std->CFOP = '5933';  | 
            ||
| 265 | $std->uCom = 'JG';  | 
            ||
| 266 | $std->uTrib = 'JG';  | 
            ||
| 267 | $std->cBarra = NULL;  | 
            ||
| 268 | $std->cBarraTrib = NULL;  | 
            ||
| 269 | $std->qCom = '1';  | 
            ||
| 270 | $std->qTrib = '1';  | 
            ||
| 271 | $std->vUnCom = '200';  | 
            ||
| 272 | $std->vUnTrib = '200';  | 
            ||
| 273 | $std->vProd = '200';  | 
            ||
| 274 | $std->vDesc = NULL;  | 
            ||
| 275 | $std->vOutro = NULL;  | 
            ||
| 276 | $std->vSeg = NULL;  | 
            ||
| 277 | $std->vFrete = NULL;  | 
            ||
| 278 | $std->cBenef = NULL;  | 
            ||
| 279 | $std->xPed = NULL;  | 
            ||
| 280 | $std->nItemPed = NULL;  | 
            ||
| 281 | $std->indTot = 1;  | 
            ||
| 282 | $this->make->tagprod($std);  | 
            ||
| 283 | $this->makeImpostos($product, $item);  | 
            ||
| 284 | }  | 
            ||
| 285 | }  | 
            ||
| 286 | protected function makeImpostos(Product $product, $item)  | 
            ||
| 287 |     { | 
            ||
| 288 | $this->makePIS($product, $item);  | 
            ||
| 289 | $this->makeCOFINS($product, $item);  | 
            ||
| 290 | $this->makeISSQN($product, $item);  | 
            ||
| 291 | |||
| 292 | //Imposto  | 
            ||
| 293 | $std = new \stdClass();  | 
            ||
| 294 | $std->item = $item; //item da NFe  | 
            ||
| 295 | $std->vTotTrib = 0;  | 
            ||
| 296 | $this->make->tagimposto($std);  | 
            ||
| 297 | |||
| 298 | |||
| 299 | |||
| 300 | $std = new \stdClass();  | 
            ||
| 301 | $this->make->tagICMSTot($std);  | 
            ||
| 302 | |||
| 303 | $std = new \stdClass();  | 
            ||
| 304 | $std->dCompet = '2010-09-12';  | 
            ||
| 305 | $std->cRegTrib = 6;  | 
            ||
| 306 | $this->make->tagISSQNTot($std);  | 
            ||
| 307 | $this->make->tagISSQNTot($std);  | 
            ||
| 308 | }  | 
            ||
| 309 | |||
| 310 | protected function makeInfNFe($version)  | 
            ||
| 311 |     { | 
            ||
| 312 | //infNFe OBRIGATÓRIA  | 
            ||
| 313 | $std = new \stdClass();  | 
            ||
| 314 | $std->Id = '';  | 
            ||
| 315 | $std->versao = $version;  | 
            ||
| 316 | $this->make->taginfNFe($std);  | 
            ||
| 317 | }  | 
            ||
| 318 | |||
| 319 | protected function makeISSQN(Product $product, $item)  | 
            ||
| 320 |     { | 
            ||
| 321 | // Monta a tag de impostos mas não adiciona no xml  | 
            ||
| 322 | $std = new \stdClass();  | 
            ||
| 323 | $std->item = $item; //item da NFe  | 
            ||
| 324 | $std->vBC = 2.0;  | 
            ||
| 325 | $std->vAliq = 8.0;  | 
            ||
| 326 | $std->vISSQN = 0.16;  | 
            ||
| 327 | $std->cMunFG = 1300029;  | 
            ||
| 328 | $std->cMun = 1300029;  | 
            ||
| 329 | $std->cPais = '1058';  | 
            ||
| 330 | $std->cListServ = '01.01';  | 
            ||
| 331 | $std->indISS = 1;  | 
            ||
| 332 | $std->indIncentivo = 2;  | 
            ||
| 333 | // Adiciona a tag de imposto ISSQN no xml  | 
            ||
| 334 | $this->make->tagISSQN($std);  | 
            ||
| 335 | }  | 
            ||
| 336 | |||
| 337 | protected function makePIS(Product $product, $item)  | 
            ||
| 338 |     { | 
            ||
| 339 | //PIS  | 
            ||
| 340 | $std = new \stdClass();  | 
            ||
| 341 | $std->item = $item; //item da NFe  | 
            ||
| 342 | $std->CST = '99';  | 
            ||
| 343 | $std->vBC = 200;  | 
            ||
| 344 | $std->pPIS = 0.65;  | 
            ||
| 345 | $std->vPIS = 13;  | 
            ||
| 346 | $this->make->tagPIS($std);  | 
            ||
| 347 | }  | 
            ||
| 348 | protected function makeCOFINS(Product $product, $item)  | 
            ||
| 349 |     { | 
            ||
| 350 | //COFINS  | 
            ||
| 351 | $std = new \stdClass();  | 
            ||
| 352 | $std->item = $item; //item da NFe  | 
            ||
| 353 | $std->CST = '99';  | 
            ||
| 354 | $std->vBC = 200;  | 
            ||
| 355 | $std->pCOFINS = 3;  | 
            ||
| 356 | $std->vCOFINS = 60;  | 
            ||
| 357 | $this->make->tagCOFINS($std);  | 
            ||
| 358 | }  | 
            ||
| 359 | |||
| 360 | protected function sign(Order $order)  | 
            ||
| 365 | }  | 
            ||
| 366 | |||
| 367 | protected function getCertificate(Order $order)  | 
            ||
| 368 |     { | 
            ||
| 369 | $provider = $order->getProvider();  | 
            ||
| 370 | |||
| 371 | $dacteKey = $this->manager->getRepository(Config::class)->findOneBy([  | 
            ||
| 372 | 'people' => $provider,  | 
            ||
| 373 | 'config_key' => 'cert-path'  | 
            ||
| 374 | ]);  | 
            ||
| 375 | |||
| 376 | $dacteKeyPass = $this->manager->getRepository(Config::class)->findOneBy([  | 
            ||
| 377 | 'people' => $provider,  | 
            ||
| 378 | 'config_key' => 'cert-pass'  | 
            ||
| 379 | ]);  | 
            ||
| 380 | if (!$dacteKey || !$dacteKeyPass)  | 
            ||
| 381 |             throw new \Exception("DACTE key cert is required", 1); | 
            ||
| 382 | |||
| 383 | $certPath = $this->appKernel->getProjectDir() . $dacteKey->getConfigValue();  | 
            ||
| 384 | if (!is_file($certPath))  | 
            ||
| 385 |             throw new \Exception("DACTE key cert path is invalid", 1); | 
            ||
| 386 | return Certificate::readPfx($this->getSignData($order), $dacteKeyPass->getConfigValue());  | 
            ||
| 387 | }  | 
            ||
| 388 | |||
| 389 | protected function getSignData(Order $order)  | 
            ||
| 390 |     { | 
            ||
| 391 | |||
| 392 | $provider = $order->getProvider();  | 
            ||
| 393 | $document = $provider->getOneDocument();  | 
            ||
| 394 | |||
| 395 | /**  | 
            ||
| 396 | * @var \ControleOnline\Entity\Address $providerAddress  | 
            ||
| 397 | */  | 
            ||
| 398 | $providerAddress = $provider->getAddress()[0];  | 
            ||
| 399 | |||
| 400 | $arr = [  | 
            ||
| 401 |             "atualizacao" => date('Y-m-d H:m:i'), | 
            ||
| 402 | "tpAmb" => 2, //2 - Homologação / 1 - Produção  | 
            ||
| 403 | "razaosocial" => $provider->getName(),  | 
            ||
| 404 | "cnpj" => $document->getDocument(),  | 
            ||
| 405 | //"cpf" => "00000000000",  | 
            ||
| 406 | "siglaUF" => $providerAddress->getStreet()->getDistrict()->getCity()->getState()->getUf(),  | 
            ||
| 407 | "schemes" => "PL_CTe_300",  | 
            ||
| 408 | "versao" => '3.00',  | 
            ||
| 409 | "proxyConf" => [  | 
            ||
| 410 | "proxyIp" => "",  | 
            ||
| 411 | "proxyPort" => "",  | 
            ||
| 412 | "proxyUser" => "",  | 
            ||
| 413 | "proxyPass" => ""  | 
            ||
| 414 | ]  | 
            ||
| 415 | ];  | 
            ||
| 416 | |||
| 417 | return json_encode($arr);  | 
            ||
| 418 | }  | 
            ||
| 419 | |||
| 420 | protected function makeTransp(Order $order)  | 
            ||
| 425 | }  | 
            ||
| 426 | |||
| 427 | |||
| 428 | protected function makePag(Order $order)  | 
            ||
| 429 |     { | 
            ||
| 430 | //pag OBRIGATÓRIA  | 
            ||
| 431 | $std = new \stdClass();  | 
            ||
| 432 | $std->vTroco = 0;  | 
            ||
| 433 | $this->make->tagpag($std);  | 
            ||
| 434 | }  | 
            ||
| 435 | |||
| 436 | |||
| 437 | protected function makedetPag(Order $order)  | 
            ||
| 438 |     { | 
            ||
| 439 | //detPag OBRIGATÓRIA  | 
            ||
| 440 | $std = new \stdClass();  | 
            ||
| 441 | $std->indPag = '0';  | 
            ||
| 442 | $std->xPag = NULL;  | 
            ||
| 443 | $std->tPag = '01';  | 
            ||
| 444 | $std->vPag = 2.01;  | 
            ||
| 445 | $this->make->tagdetpag($std);  | 
            ||
| 446 | }  | 
            ||
| 447 | protected function makeInfRespTec()  | 
            ||
| 448 |     { | 
            ||
| 449 | |||
| 450 | $std = new \stdClass();  | 
            ||
| 451 | $std->CNPJ = '99999999999999'; //CNPJ da pessoa jurídica responsável pelo sistema utilizado na emissão do documento fiscal eletrônico  | 
            ||
| 452 | $std->xContato = 'Fulano de Tal'; //Nome da pessoa a ser contatada  | 
            ||
| 453 | $std->email = '[email protected]'; //E-mail da pessoa jurídica a ser contatada  | 
            ||
| 454 | $std->fone = '1155551122'; //Telefone da pessoa jurídica/física a ser contatada  | 
            ||
| 455 | //$std->CSRT = 'G8063VRTNDMO886SFNK5LDUDEI24XJ22YIPO'; //Código de Segurança do Responsável Técnico  | 
            ||
| 456 | //$std->idCSRT = '01'; //Identificador do CSRT  | 
            ||
| 457 | $this->make->taginfRespTec($std);  | 
            ||
| 458 | }  | 
            ||
| 459 | |||
| 460 | |||
| 461 | protected function getCodMunicipio($mun, $uf)  | 
            ||
| 462 |     { | 
            ||
| 463 | |||
| 464 | /**  | 
            ||
| 465 | * @todo  | 
            ||
| 466 | */  | 
            ||
| 467 | $cod['sp'] = [  | 
            ||
| 468 | 'Guarulhos' => '4108304',  | 
            ||
| 469 | 'São Paulo' => '4108304'  | 
            ||
| 470 | ];  | 
            ||
| 471 | |||
| 472 | return $cod[$uf][$mun];  | 
            ||
| 473 | }  | 
            ||
| 474 | protected function getLastDacte()  | 
            ||
| 475 |     { | 
            ||
| 476 | return '127'; //@todo  | 
            ||
| 477 | }  | 
            ||
| 478 | |||
| 479 | protected function montaChave($cUF, $ano, $mes, $cnpj, $mod, $serie, $numero, $tpEmis, $codigo = '')  | 
            ||
| 480 |     { | 
            ||
| 481 |         if ($codigo == '') { | 
            ||
| 482 | $codigo = $numero;  | 
            ||
| 483 | }  | 
            ||
| 484 | $forma = "%02d%02d%02d%s%02d%03d%09d%01d%08d";  | 
            ||
| 485 | $chave = sprintf(  | 
            ||
| 486 | $forma,  | 
            ||
| 487 | $cUF,  | 
            ||
| 488 | $ano,  | 
            ||
| 489 | $mes,  | 
            ||
| 490 | $cnpj,  | 
            ||
| 491 | $mod,  | 
            ||
| 492 | $serie,  | 
            ||
| 493 | $numero,  | 
            ||
| 494 | $tpEmis,  | 
            ||
| 495 | $codigo  | 
            ||
| 496 | );  | 
            ||
| 497 | return $chave . $this->calculaDV($chave);  | 
            ||
| 498 | }  | 
            ||
| 499 | |||
| 500 | |||
| 501 | protected function sendData($xml)  | 
            ||
| 502 |     { | 
            ||
| 503 | |||
| 504 | //Envia lote e autoriza  | 
            ||
| 505 | $axmls[] = $xml;  | 
            ||
| 506 |         $lote = substr(str_replace(',', '', number_format(microtime(true) * 1000000, 0)), 0, 15); | 
            ||
| 507 | $res = $this->tools->sefazEnviaLote($axmls, $lote);  | 
            ||
| 508 | |||
| 509 | //Converte resposta  | 
            ||
| 510 | $stdCl = new Standardize($res);  | 
            ||
| 511 | //Output array  | 
            ||
| 512 | $arr = $stdCl->toArray();  | 
            ||
| 513 | //print_r($arr);  | 
            ||
| 514 | //Output object  | 
            ||
| 515 | $std = $stdCl->toStd();  | 
            ||
| 516 | |||
| 517 |         if ($std->cStat != 103) { //103 - Lote recebido com Sucesso | 
            ||
| 518 | //processa erros  | 
            ||
| 519 | print_r($arr);  | 
            ||
| 520 | }  | 
            ||
| 521 | |||
| 522 | //Consulta Recibo  | 
            ||
| 523 | $res = $this->tools->sefazConsultaRecibo($std->infRec->nRec);  | 
            ||
| 524 | $stdCl = new Standardize($res);  | 
            ||
| 525 | $arr = $stdCl->toArray();  | 
            ||
| 526 | $std = $stdCl->toStd();  | 
            ||
| 527 |         if ($std->protCTe->infProt->cStat == 100) { //Autorizado o uso do CT-e | 
            ||
| 528 | //adicionar protocolo  | 
            ||
| 529 | }  | 
            ||
| 530 | echo '<pre>';  | 
            ||
| 531 | print_r($arr);  | 
            ||
| 532 | }  | 
            ||
| 533 | |||
| 534 | protected function calculaDV($chave43)  | 
            ||
| 535 |     { | 
            ||
| 536 | $multiplicadores = array(2, 3, 4, 5, 6, 7, 8, 9);  | 
            ||
| 537 | $iCount = 42;  | 
            ||
| 538 | $somaPonderada = 0;  | 
            ||
| 539 |         while ($iCount >= 0) { | 
            ||
| 540 |             for ($mCount = 0; $mCount < count($multiplicadores) && $iCount >= 0; $mCount++) { | 
            ||
| 541 | $num = (int) substr($chave43, $iCount, 1);  | 
            ||
| 542 | $peso = (int) $multiplicadores[$mCount];  | 
            ||
| 543 | $somaPonderada += $num * $peso;  | 
            ||
| 544 | $iCount--;  | 
            ||
| 545 | }  | 
            ||
| 546 | }  | 
            ||
| 547 | $resto = $somaPonderada % 11;  | 
            ||
| 548 |         if ($resto == '0' || $resto == '1') { | 
            ||
| 549 | $cDV = 0;  | 
            ||
| 550 |         } else { | 
            ||
| 551 | $cDV = 11 - $resto;  | 
            ||
| 552 | }  | 
            ||
| 553 | return (string) $cDV;  | 
            ||
| 554 | }  | 
            ||
| 555 | |||
| 556 | public function getNfNumber($xml)  | 
            ||
| 557 |     { | 
            ||
| 558 | return 1;  | 
            ||
| 559 | }  | 
            ||
| 560 | |||
| 561 | protected function persist(Order $order, $xml)  | 
            ||
| 580 | }  | 
            ||
| 581 | }  | 
            ||
| 582 | 
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths