Complex classes like Evento 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. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
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 Evento, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 37 | class Evento extends Retorno |
||
|
|
|||
| 38 | { |
||
| 39 | |||
| 40 | const VERSAO = '1.00'; |
||
| 41 | |||
| 42 | const TIPO_CANCELAMENTO = '110111'; |
||
| 43 | const TAG_RETORNO = 'retEvento'; |
||
| 44 | const TAG_RETORNO_ENVIO = 'retEnvEvento'; |
||
| 45 | |||
| 46 | private $id; |
||
| 47 | private $orgao; |
||
| 48 | private $identificador; |
||
| 49 | private $chave; |
||
| 50 | private $data; |
||
| 51 | private $tipo; |
||
| 52 | private $sequencia; |
||
| 53 | private $descricao; |
||
| 54 | private $numero; |
||
| 55 | private $justificativa; |
||
| 56 | private $email; |
||
| 57 | private $modelo; |
||
| 58 | private $informacao; |
||
| 59 | |||
| 60 | 8 | public function __construct($evento = array()) |
|
| 64 | |||
| 65 | /** |
||
| 66 | * Identificador da TAG a ser assinada, a regra de formação do Id é: "ID" + |
||
| 67 | * tpEvento + chave da NF-e + nSeqEvento |
||
| 68 | */ |
||
| 69 | 7 | public function getID($normalize = false) |
|
| 76 | |||
| 77 | 8 | public function setID($id) |
|
| 82 | |||
| 83 | /** |
||
| 84 | * Código do órgão de recepção do Evento. Utilizar a Tabela do IBGE |
||
| 85 | * extendida, utilizar 91 para identificar o Ambiente Nacional |
||
| 86 | */ |
||
| 87 | 6 | public function getOrgao($normalize = false) |
|
| 96 | |||
| 97 | 8 | public function setOrgao($orgao) |
|
| 102 | |||
| 103 | /** |
||
| 104 | * Identificação do autor do evento |
||
| 105 | */ |
||
| 106 | 6 | public function getIdentificador($normalize = false) |
|
| 113 | |||
| 114 | 8 | public function setIdentificador($identificador) |
|
| 119 | |||
| 120 | /** |
||
| 121 | * Chave de Acesso da NF-e vinculada ao evento |
||
| 122 | */ |
||
| 123 | 6 | public function getChave($normalize = false) |
|
| 130 | |||
| 131 | 8 | public function setChave($chave) |
|
| 136 | |||
| 137 | /** |
||
| 138 | * Data e Hora do Evento, formato UTC (AAAA-MM-DDThh:mm:ssTZD, onde TZD = |
||
| 139 | * +hh:mm ou -hh:mm) |
||
| 140 | */ |
||
| 141 | 6 | public function getData($normalize = false) |
|
| 148 | |||
| 149 | 8 | public function setData($data) |
|
| 150 | { |
||
| 151 | 8 | if (!is_numeric($data)) { |
|
| 152 | 8 | $data = strtotime($data); |
|
| 153 | } |
||
| 154 | 8 | $this->data = $data; |
|
| 155 | 8 | return $this; |
|
| 156 | } |
||
| 157 | |||
| 158 | /** |
||
| 159 | * Tipo do Evento |
||
| 160 | */ |
||
| 161 | 6 | public function getTipo($normalize = false) |
|
| 168 | |||
| 169 | 8 | public function setTipo($tipo) |
|
| 174 | |||
| 175 | /** |
||
| 176 | * Seqüencial do evento para o mesmo tipo de evento. Para maioria dos |
||
| 177 | * eventos será 1, nos casos em que possa existir mais de um evento, como é |
||
| 178 | * o caso da carta de correção, o autor do evento deve numerar de forma |
||
| 179 | * seqüencial. |
||
| 180 | */ |
||
| 181 | 6 | public function getSequencia($normalize = false) |
|
| 188 | |||
| 189 | 8 | public function setSequencia($sequencia) |
|
| 194 | |||
| 195 | /** |
||
| 196 | * Descrição do Evento |
||
| 197 | */ |
||
| 198 | 6 | public function getDescricao($normalize = false) |
|
| 205 | |||
| 206 | 8 | public function setDescricao($descricao) |
|
| 211 | |||
| 212 | /** |
||
| 213 | * Número do Protocolo de Status da NF-e. 1 posição (1 – Secretaria de |
||
| 214 | * Fazenda Estadual 2 – Receita Federal); 2 posições ano; 10 seqüencial no |
||
| 215 | * ano. |
||
| 216 | */ |
||
| 217 | 6 | public function getNumero($normalize = false) |
|
| 224 | |||
| 225 | 8 | public function setNumero($numero) |
|
| 230 | |||
| 231 | /** |
||
| 232 | * Justificativa do cancelamento |
||
| 233 | */ |
||
| 234 | 6 | public function getJustificativa($normalize = false) |
|
| 241 | |||
| 242 | 8 | public function setJustificativa($justificativa) |
|
| 247 | |||
| 248 | /** |
||
| 249 | * email do destinatário |
||
| 250 | */ |
||
| 251 | 4 | public function getEmail($normalize = false) |
|
| 258 | |||
| 259 | 8 | public function setEmail($email) |
|
| 264 | |||
| 265 | /** |
||
| 266 | * Código do modelo do Documento Fiscal. 55 = NF-e; 65 = NFC-e. |
||
| 267 | * @param boolean $normalize informa se o modelo deve estar no formato do XML |
||
| 268 | * @return mixed modelo do Envio |
||
| 269 | */ |
||
| 270 | 3 | public function getModelo($normalize = false) |
|
| 271 | { |
||
| 272 | 3 | if (!$normalize) { |
|
| 273 | 3 | return $this->modelo; |
|
| 274 | } |
||
| 275 | switch ($this->modelo) { |
||
| 276 | case Nota::MODELO_NFE: |
||
| 277 | return '55'; |
||
| 278 | case Nota::MODELO_NFCE: |
||
| 279 | return '65'; |
||
| 280 | } |
||
| 281 | return $this->modelo; |
||
| 282 | } |
||
| 283 | |||
| 284 | /** |
||
| 285 | * Altera o valor do Modelo para o informado no parâmetro |
||
| 286 | * @param mixed $modelo novo valor para Modelo |
||
| 287 | * @return Envio A própria instância da classe |
||
| 288 | */ |
||
| 289 | 8 | public function setModelo($modelo) |
|
| 302 | |||
| 303 | /** |
||
| 304 | * Resposta de informação do evento |
||
| 305 | */ |
||
| 306 | 5 | public function getInformacao() |
|
| 310 | |||
| 311 | 8 | public function setInformacao($informacao) |
|
| 316 | |||
| 317 | /** |
||
| 318 | * Informa se a identificação é um CNPJ |
||
| 319 | */ |
||
| 320 | 6 | public function isCNPJ() |
|
| 324 | |||
| 325 | /** |
||
| 326 | * Informa se o lote já foi processado e já tem um protocolo |
||
| 327 | */ |
||
| 328 | 3 | public function isProcessado() |
|
| 332 | |||
| 333 | /** |
||
| 334 | * Informa se a nota foi cancelada com sucesso |
||
| 335 | */ |
||
| 336 | 2 | public function isCancelado() |
|
| 340 | |||
| 341 | 1 | public function toArray($recursive = false) |
|
| 359 | |||
| 360 | 8 | public function fromArray($evento = array()) |
|
| 361 | { |
||
| 362 | 8 | if ($evento instanceof Evento) { |
|
| 363 | 1 | $evento = $evento->toArray(); |
|
| 364 | 8 | } elseif (!is_array($evento)) { |
|
| 365 | 1 | return $this; |
|
| 366 | } |
||
| 367 | 8 | parent::fromArray($evento); |
|
| 368 | 8 | if (isset($evento['id'])) { |
|
| 369 | 1 | $this->setID($evento['id']); |
|
| 370 | } else { |
||
| 371 | 8 | $this->setID(null); |
|
| 372 | } |
||
| 373 | 8 | if (isset($evento['orgao'])) { |
|
| 374 | 1 | $this->setOrgao($evento['orgao']); |
|
| 375 | } else { |
||
| 376 | 8 | $this->setOrgao(null); |
|
| 377 | } |
||
| 378 | 8 | if (isset($evento['identificador'])) { |
|
| 379 | 1 | $this->setIdentificador($evento['identificador']); |
|
| 380 | } else { |
||
| 381 | 8 | $this->setIdentificador(null); |
|
| 382 | } |
||
| 383 | 8 | if (isset($evento['chave'])) { |
|
| 384 | 1 | $this->setChave($evento['chave']); |
|
| 385 | } else { |
||
| 386 | 8 | $this->setChave(null); |
|
| 387 | } |
||
| 388 | 8 | if (isset($evento['data'])) { |
|
| 389 | 1 | $this->setData($evento['data']); |
|
| 390 | } else { |
||
| 391 | 8 | $this->setData(null); |
|
| 392 | } |
||
| 393 | 8 | if (!isset($evento['tipo']) || is_null($evento['tipo'])) { |
|
| 394 | 8 | $this->setTipo(self::TIPO_CANCELAMENTO); |
|
| 395 | } else { |
||
| 396 | 1 | $this->setTipo($evento['tipo']); |
|
| 397 | } |
||
| 398 | 8 | if (!isset($evento['sequencia']) || is_null($evento['sequencia'])) { |
|
| 399 | 8 | $this->setSequencia(1); |
|
| 400 | } else { |
||
| 401 | 1 | $this->setSequencia($evento['sequencia']); |
|
| 402 | } |
||
| 403 | 8 | if (!isset($evento['descricao']) || is_null($evento['descricao'])) { |
|
| 404 | 8 | $this->setDescricao('Cancelamento'); |
|
| 405 | } else { |
||
| 406 | 1 | $this->setDescricao($evento['descricao']); |
|
| 407 | } |
||
| 408 | 8 | if (isset($evento['numero'])) { |
|
| 409 | 1 | $this->setNumero($evento['numero']); |
|
| 410 | } else { |
||
| 411 | 8 | $this->setNumero(null); |
|
| 412 | } |
||
| 413 | 8 | if (isset($evento['justificativa'])) { |
|
| 414 | 1 | $this->setJustificativa($evento['justificativa']); |
|
| 415 | } else { |
||
| 416 | 8 | $this->setJustificativa(null); |
|
| 417 | } |
||
| 418 | 8 | if (isset($evento['email'])) { |
|
| 419 | $this->setEmail($evento['email']); |
||
| 420 | } else { |
||
| 421 | 8 | $this->setEmail(null); |
|
| 422 | } |
||
| 423 | 8 | if (isset($evento['modelo'])) { |
|
| 424 | 1 | $this->setModelo($evento['modelo']); |
|
| 425 | } else { |
||
| 426 | 8 | $this->setModelo(null); |
|
| 427 | } |
||
| 428 | 8 | if (isset($evento['informacao'])) { |
|
| 429 | 1 | $this->setInformacao($evento['informacao']); |
|
| 430 | } else { |
||
| 431 | 8 | $this->setInformacao(null); |
|
| 432 | } |
||
| 433 | 8 | return $this; |
|
| 434 | } |
||
| 435 | |||
| 436 | /** |
||
| 437 | * Gera o ID, a regra de formação do Id é: "ID" + |
||
| 438 | * tpEvento + chave da NF-e + nSeqEvento |
||
| 439 | */ |
||
| 440 | 6 | public function gerarID() |
|
| 441 | { |
||
| 442 | 6 | $id = sprintf( |
|
| 443 | 6 | '%s%s%02d', |
|
| 444 | 6 | $this->getTipo(true), |
|
| 445 | 6 | $this->getChave(true), |
|
| 446 | 6 | $this->getSequencia(true) |
|
| 447 | ); |
||
| 448 | 6 | return $id; |
|
| 449 | } |
||
| 450 | |||
| 451 | 6 | public function getNode($name = null) |
|
| 452 | { |
||
| 453 | 6 | $this->setID($this->gerarID()); |
|
| 454 | |||
| 455 | 6 | $dom = new \DOMDocument('1.0', 'UTF-8'); |
|
| 456 | 6 | $element = $dom->createElement(is_null($name)?'evento':$name); |
|
| 457 | 6 | $element->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns', Nota::PORTAL); |
|
| 458 | 6 | $versao = $dom->createAttribute('versao'); |
|
| 459 | 6 | $versao->value = self::VERSAO; |
|
| 460 | 6 | $element->appendChild($versao); |
|
| 461 | |||
| 462 | 6 | $info = $dom->createElement('infEvento'); |
|
| 463 | 6 | $dom = $element->ownerDocument; |
|
| 464 | 6 | $id = $dom->createAttribute('Id'); |
|
| 465 | 6 | $id->value = $this->getID(true); |
|
| 466 | 6 | $info->appendChild($id); |
|
| 467 | |||
| 468 | 6 | Util::appendNode($info, 'cOrgao', $this->getOrgao(true)); |
|
| 469 | 6 | Util::appendNode($info, 'tpAmb', $this->getAmbiente(true)); |
|
| 470 | 6 | if ($this->isCNPJ()) { |
|
| 471 | 6 | Util::appendNode($info, 'CNPJ', $this->getIdentificador(true)); |
|
| 472 | } else { |
||
| 473 | 4 | Util::appendNode($info, 'CPF', $this->getIdentificador(true)); |
|
| 474 | } |
||
| 475 | 6 | Util::appendNode($info, 'chNFe', $this->getChave(true)); |
|
| 476 | 6 | Util::appendNode($info, 'dhEvento', $this->getData(true)); |
|
| 477 | 6 | Util::appendNode($info, 'tpEvento', $this->getTipo(true)); |
|
| 478 | 6 | Util::appendNode($info, 'nSeqEvento', $this->getSequencia(true)); |
|
| 479 | 6 | Util::appendNode($info, 'verEvento', self::VERSAO); |
|
| 480 | |||
| 481 | 6 | $detalhes = $dom->createElement('detEvento'); |
|
| 482 | 6 | $versao = $dom->createAttribute('versao'); |
|
| 483 | 6 | $versao->value = self::VERSAO; |
|
| 484 | 6 | $detalhes->appendChild($versao); |
|
| 485 | |||
| 486 | 6 | Util::appendNode($detalhes, 'descEvento', $this->getDescricao(true)); |
|
| 487 | 6 | Util::appendNode($detalhes, 'nProt', $this->getNumero(true)); |
|
| 488 | 6 | Util::appendNode($detalhes, 'xJust', $this->getJustificativa(true)); |
|
| 489 | 6 | $info->appendChild($detalhes); |
|
| 490 | |||
| 491 | 6 | $element->appendChild($info); |
|
| 492 | 6 | $dom->appendChild($element); |
|
| 493 | 6 | return $element; |
|
| 494 | } |
||
| 495 | |||
| 496 | 2 | public function loadNode($element, $name = null) |
|
| 497 | { |
||
| 498 | 2 | $root = $element; |
|
| 499 | 2 | $element = Util::findNode($element, 'evento'); |
|
| 500 | 2 | $name = is_null($name)?'infEvento':$name; |
|
| 501 | 2 | $element = Util::findNode($element, $name); |
|
| 502 | 2 | $this->setOrgao( |
|
| 503 | 2 | Util::loadNode( |
|
| 504 | $element, |
||
| 505 | 2 | 'cOrgao', |
|
| 506 | 2 | 'Tag "cOrgao" não encontrada no Evento' |
|
| 507 | ) |
||
| 508 | ); |
||
| 509 | 2 | $this->setAmbiente( |
|
| 510 | 2 | Util::loadNode( |
|
| 511 | $element, |
||
| 512 | 2 | 'tpAmb', |
|
| 513 | 2 | 'Tag "tpAmb" não encontrada no Evento' |
|
| 514 | ) |
||
| 515 | ); |
||
| 516 | 2 | if (Util::nodeExists($element, 'CNPJ')) { |
|
| 517 | 2 | $this->setIdentificador( |
|
| 518 | 2 | Util::loadNode( |
|
| 519 | $element, |
||
| 520 | 2 | 'CNPJ', |
|
| 521 | 2 | 'Tag "CNPJ" não encontrada no Evento' |
|
| 522 | ) |
||
| 523 | ); |
||
| 524 | } else { |
||
| 525 | $this->setIdentificador( |
||
| 526 | Util::loadNode( |
||
| 527 | $element, |
||
| 528 | 'CPF', |
||
| 529 | 'Tag "CPF" não encontrada no Evento' |
||
| 530 | ) |
||
| 531 | ); |
||
| 532 | } |
||
| 533 | 2 | $this->setChave( |
|
| 534 | 2 | Util::loadNode( |
|
| 535 | $element, |
||
| 536 | 2 | 'chNFe', |
|
| 537 | 2 | 'Tag "chNFe" não encontrada no Evento' |
|
| 538 | ) |
||
| 539 | ); |
||
| 540 | 2 | $this->setData( |
|
| 541 | 2 | Util::loadNode( |
|
| 542 | $element, |
||
| 543 | 2 | 'dhEvento', |
|
| 544 | 2 | 'Tag "dhEvento" não encontrada no Evento' |
|
| 545 | ) |
||
| 546 | ); |
||
| 547 | 2 | $this->setTipo( |
|
| 548 | 2 | Util::loadNode( |
|
| 549 | $element, |
||
| 550 | 2 | 'tpEvento', |
|
| 551 | 2 | 'Tag "tpEvento" não encontrada no Evento' |
|
| 552 | ) |
||
| 553 | ); |
||
| 554 | 2 | $this->setSequencia( |
|
| 555 | 2 | Util::loadNode( |
|
| 556 | $element, |
||
| 557 | 2 | 'nSeqEvento', |
|
| 558 | 2 | 'Tag "nSeqEvento" não encontrada no Evento' |
|
| 559 | ) |
||
| 560 | ); |
||
| 561 | |||
| 562 | 2 | $detalhes = Util::findNode($element, 'detEvento'); |
|
| 563 | 2 | $this->setDescricao( |
|
| 564 | 2 | Util::loadNode( |
|
| 565 | $detalhes, |
||
| 566 | 2 | 'descEvento', |
|
| 567 | 2 | 'Tag "descEvento" não encontrada no Evento' |
|
| 568 | ) |
||
| 569 | ); |
||
| 570 | 2 | $this->setNumero( |
|
| 571 | 2 | Util::loadNode( |
|
| 572 | $detalhes, |
||
| 573 | 2 | 'nProt', |
|
| 574 | 2 | 'Tag "nProt" não encontrada no Evento' |
|
| 575 | ) |
||
| 576 | ); |
||
| 577 | 2 | $this->setJustificativa( |
|
| 578 | 2 | Util::loadNode( |
|
| 579 | $detalhes, |
||
| 580 | 2 | 'xJust', |
|
| 581 | 2 | 'Tag "xJust" não encontrada no Evento' |
|
| 582 | ) |
||
| 583 | ); |
||
| 584 | 2 | $informacao = null; |
|
| 585 | 2 | if (Util::nodeExists($root, 'procEventoNFe')) { |
|
| 586 | 2 | $informacao = $this->loadResponse($root); |
|
| 587 | } |
||
| 588 | 2 | $this->setInformacao($informacao); |
|
| 589 | 2 | return $element; |
|
| 590 | } |
||
| 591 | |||
| 592 | 5 | public function loadResponse($resp) |
|
| 599 | |||
| 600 | 5 | public function loadStatusNode($element, $name = null) |
|
| 601 | { |
||
| 602 | 5 | $name = is_null($name)?self::TAG_RETORNO_ENVIO:$name; |
|
| 603 | 5 | $element = parent::loadNode($element, $name); |
|
| 604 | 5 | $this->setOrgao( |
|
| 605 | 5 | Util::loadNode( |
|
| 606 | $element, |
||
| 607 | 5 | 'cOrgao', |
|
| 608 | 5 | 'Tag "cOrgao" do campo "Orgao" não encontrada' |
|
| 609 | ) |
||
| 610 | ); |
||
| 611 | 5 | return $element; |
|
| 612 | } |
||
| 613 | |||
| 614 | 4 | public function getReturnNode() |
|
| 615 | { |
||
| 616 | 4 | $outros = parent::getNode('infEvento'); |
|
| 617 | 4 | $element = $this->getNode(self::TAG_RETORNO); |
|
| 618 | 4 | $dom = $element->ownerDocument; |
|
| 619 | 4 | $element->removeAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns'); |
|
| 620 | 4 | $info = $dom->getElementsByTagName('infEvento')->item(0); |
|
| 621 | 4 | $info->removeAttribute('Id'); |
|
| 622 | 4 | $removeTags = array('detEvento', 'verEvento', 'dhEvento', 'CNPJ', 'CPF', 'cOrgao'); |
|
| 623 | 4 | foreach ($removeTags as $key) { |
|
| 624 | 4 | $_fields = $info->getElementsByTagName($key); |
|
| 625 | 4 | if ($_fields->length == 0) { |
|
| 626 | 4 | continue; |
|
| 627 | } |
||
| 628 | 4 | $node = $_fields->item(0); |
|
| 629 | 4 | $info->removeChild($node); |
|
| 630 | } |
||
| 631 | 4 | $chave = $info->getElementsByTagName('chNFe')->item(0); |
|
| 632 | 4 | foreach ($outros->childNodes as $node) { |
|
| 633 | 4 | $node = $dom->importNode($node, true); |
|
| 634 | 4 | $list = $info->getElementsByTagName($node->nodeName); |
|
| 635 | 4 | if ($list->length == 1) { |
|
| 636 | 4 | continue; |
|
| 637 | } |
||
| 638 | 4 | $info->insertBefore($node, $chave); |
|
| 639 | } |
||
| 640 | 4 | $status = $info->getElementsByTagName('cStat')->item(0); |
|
| 641 | 4 | Util::appendNode($info, 'cOrgao', $this->getOrgao(true), $status); |
|
| 642 | 4 | $sequencia = $info->getElementsByTagName('nSeqEvento')->item(0); |
|
| 643 | 4 | Util::appendNode($info, 'xEvento', $this->getDescricao(true), $sequencia); |
|
| 644 | 4 | if (!is_null($this->getIdentificador())) { |
|
| 645 | if ($this->isCNPJ()) { |
||
| 646 | Util::appendNode($info, 'CNPJDest', $this->getIdentificador(true)); |
||
| 647 | } else { |
||
| 648 | Util::appendNode($info, 'CPFDest', $this->getIdentificador(true)); |
||
| 649 | } |
||
| 650 | } |
||
| 651 | 4 | if (!is_null($this->getEmail())) { |
|
| 652 | Util::appendNode($info, 'emailDest', $this->getEmail(true)); |
||
| 653 | } |
||
| 654 | 4 | Util::appendNode($info, 'dhRegEvento', $this->getData(true)); |
|
| 655 | 4 | Util::appendNode($info, 'nProt', $this->getNumero(true)); |
|
| 656 | 4 | return $element; |
|
| 657 | } |
||
| 658 | |||
| 659 | 5 | public function loadReturnNode($element, $name = null) |
|
| 660 | { |
||
| 661 | 5 | $element = Util::findNode($element, Evento::TAG_RETORNO); |
|
| 662 | 5 | $name = is_null($name)?'infEvento':$name; |
|
| 663 | 5 | $element = parent::loadNode($element, $name); |
|
| 664 | 5 | $this->setOrgao( |
|
| 665 | 5 | Util::loadNode( |
|
| 666 | $element, |
||
| 667 | 5 | 'cOrgao', |
|
| 668 | 5 | 'Tag "cOrgao" do campo "Orgao" não encontrada' |
|
| 669 | ) |
||
| 670 | ); |
||
| 671 | 5 | $this->setChave(Util::loadNode($element, 'chNFe')); |
|
| 672 | 5 | $this->setTipo(Util::loadNode($element, 'tpEvento')); |
|
| 673 | 5 | $this->setDescricao(Util::loadNode($element, 'xEvento')); |
|
| 674 | 5 | $this->setSequencia(Util::loadNode($element, 'nSeqEvento')); |
|
| 675 | 5 | if ($element->getElementsByTagName('CNPJDest')->length > 0) { |
|
| 676 | $this->setIdentificador(Util::loadNode($element, 'CNPJDest')); |
||
| 677 | } else { |
||
| 678 | 5 | $this->setIdentificador(Util::loadNode($element, 'CPFDest')); |
|
| 679 | } |
||
| 680 | 5 | $this->setEmail(Util::loadNode($element, 'emailDest')); |
|
| 681 | 5 | $this->setData( |
|
| 682 | 5 | Util::loadNode( |
|
| 683 | $element, |
||
| 684 | 5 | 'dhRegEvento', |
|
| 685 | 5 | 'Tag "dhRegEvento" do campo "Data" não encontrada' |
|
| 686 | ) |
||
| 687 | ); |
||
| 688 | 5 | $this->setNumero(Util::loadNode($element, 'nProt')); |
|
| 689 | 5 | return $element; |
|
| 690 | } |
||
| 691 | |||
| 692 | 3 | private function getConteudo($dom) |
|
| 712 | |||
| 713 | 3 | public function envia($dom) |
|
| 728 | |||
| 729 | /** |
||
| 730 | * Adiciona a informação no XML do evento |
||
| 731 | */ |
||
| 732 | 5 | public function addInformacao($dom) |
|
| 762 | |||
| 763 | /** |
||
| 764 | * Assina o XML com a assinatura eletrônica do tipo A1 |
||
| 765 | */ |
||
| 766 | 6 | public function assinar($dom = null) |
|
| 767 | { |
||
| 768 | 6 | if (is_null($dom)) { |
|
| 769 | 3 | $xml = $this->getNode(); |
|
| 770 | 3 | $dom = $xml->ownerDocument; |
|
| 771 | } |
||
| 782 | |||
| 783 | /** |
||
| 784 | * Valida o documento após assinar |
||
| 785 | */ |
||
| 786 | 6 | public function validar($dom) |
|
| 809 | } |
||
| 810 |
The class complexity is the sum of the complexity of all methods. A very high value is usually an indication that your class does not follow the single reponsibility principle and does more than one job.
Some resources for further reading:
You can also find more detailed suggestions for refactoring in the “Code” section of your repository.