Complex classes like Detail 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 Detail, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 8 | class Detail extends AbstractCnab240 implements CnabDetailInterface |
||
| 9 | { |
||
| 10 | protected $numRegistroLote; |
||
| 11 | protected $segmento; |
||
| 12 | protected $tipoMovimento; |
||
| 13 | protected $codMovimento; |
||
| 14 | protected $codBarras; |
||
| 15 | protected $carteira; |
||
| 16 | protected $numeroDocumento; |
||
| 17 | protected $numeroContrato; |
||
| 18 | protected $valorTarifa; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * |
||
| 22 | * @var DateTime |
||
| 23 | */ |
||
| 24 | protected $dataVencimento; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * |
||
| 28 | * @var DateTime |
||
| 29 | */ |
||
| 30 | protected $dataPagamento; |
||
| 31 | protected $valorTitulo; |
||
| 32 | protected $valorPagamento; |
||
| 33 | protected $quantidadeMoeda; |
||
| 34 | protected $referenciaSacado; |
||
| 35 | protected $nossoNumero; |
||
| 36 | protected $codMoeda; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @var float |
||
| 40 | */ |
||
| 41 | protected $outrasDespesas; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @var float |
||
| 45 | */ |
||
| 46 | protected $outrosCreditos; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @var DateTime |
||
| 50 | */ |
||
| 51 | protected $dataOcorrencia; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @var DateTime |
||
| 55 | */ |
||
| 56 | protected $dataCredito; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @var DadosTitulo |
||
| 60 | */ |
||
| 61 | protected $dadosTitulo; |
||
| 62 | protected $numeroSequencial; |
||
| 63 | protected $numeroAutenticacao; |
||
| 64 | protected $valorRecebido; |
||
| 65 | |||
| 66 | /** |
||
| 67 | * @return mixed |
||
| 68 | */ |
||
| 69 | public function getCarteira() |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @param mixed $carteira |
||
| 76 | * @return $this |
||
| 77 | */ |
||
| 78 | public function setCarteira($carteira) |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @return mixed |
||
| 86 | */ |
||
| 87 | public function getCodBarras() |
||
| 91 | |||
| 92 | /** |
||
| 93 | * @param mixed $codBarras |
||
| 94 | * @return $this |
||
| 95 | */ |
||
| 96 | public function setCodBarras($codBarras) |
||
| 101 | |||
| 102 | /** |
||
| 103 | * @return mixed |
||
| 104 | */ |
||
| 105 | public function getCodMoeda() |
||
| 109 | |||
| 110 | /** |
||
| 111 | * @param mixed $codMoeda |
||
| 112 | * @return $this |
||
| 113 | */ |
||
| 114 | public function setCodMoeda($codMoeda) |
||
| 119 | |||
| 120 | /** |
||
| 121 | * @return mixed |
||
| 122 | */ |
||
| 123 | public function getCodMovimento() |
||
| 127 | |||
| 128 | /** |
||
| 129 | * @param mixed $codMovimento |
||
| 130 | * @return $this |
||
| 131 | */ |
||
| 132 | public function setCodMovimento($codMovimento) |
||
| 137 | |||
| 138 | /** |
||
| 139 | * @return DadosTitulo |
||
| 140 | */ |
||
| 141 | public function getDadosTitulo() |
||
| 145 | |||
| 146 | /** |
||
| 147 | * @param DadosTitulo $dadosTitulo |
||
| 148 | * @return $this |
||
| 149 | */ |
||
| 150 | public function setDadosTitulo($dadosTitulo) |
||
| 155 | |||
| 156 | /** |
||
| 157 | * @return DateTime |
||
| 158 | */ |
||
| 159 | public function getDataPagamento() |
||
| 163 | |||
| 164 | /** |
||
| 165 | * @param DateTime $dataPagamento |
||
| 166 | * @return $this |
||
| 167 | */ |
||
| 168 | public function setDataPagamento($dataPagamento) |
||
| 173 | |||
| 174 | /** |
||
| 175 | * @return DateTime |
||
| 176 | */ |
||
| 177 | public function getDataVencimento() |
||
| 181 | |||
| 182 | /** |
||
| 183 | * @param DateTime $dataVencimento |
||
| 184 | * @return $this |
||
| 185 | */ |
||
| 186 | public function setDataVencimento($dataVencimento) |
||
| 191 | |||
| 192 | /** |
||
| 193 | * @return mixed |
||
| 194 | */ |
||
| 195 | public function getNossoNumero() |
||
| 199 | |||
| 200 | /** |
||
| 201 | * @param mixed $nossoNumero |
||
| 202 | * @return $this |
||
| 203 | */ |
||
| 204 | public function setNossoNumero($nossoNumero) |
||
| 209 | |||
| 210 | /** |
||
| 211 | * @return mixed |
||
| 212 | */ |
||
| 213 | public function getNumRegistroLote() |
||
| 217 | |||
| 218 | /** |
||
| 219 | * @param mixed $numRegistroLote |
||
| 220 | * @return $this |
||
| 221 | */ |
||
| 222 | public function setNumRegistroLote($numRegistroLote) |
||
| 227 | |||
| 228 | /** |
||
| 229 | * @return mixed |
||
| 230 | */ |
||
| 231 | public function getNumeroContrato() |
||
| 235 | |||
| 236 | /** |
||
| 237 | * @param mixed $numeroContrato |
||
| 238 | * @return $this |
||
| 239 | */ |
||
| 240 | public function setNumeroContrato($numeroContrato) |
||
| 245 | |||
| 246 | /** |
||
| 247 | * @return mixed |
||
| 248 | */ |
||
| 249 | public function getNumeroDocumento() |
||
| 253 | |||
| 254 | /** |
||
| 255 | * @param mixed $numeroDocumento |
||
| 256 | * @return $this |
||
| 257 | */ |
||
| 258 | public function setNumeroDocumento($numeroDocumento) |
||
| 263 | |||
| 264 | /** |
||
| 265 | * @return mixed |
||
| 266 | */ |
||
| 267 | public function getQuantidadeMoeda() |
||
| 271 | |||
| 272 | /** |
||
| 273 | * @param mixed $quantidadeMoeda |
||
| 274 | * @return $this |
||
| 275 | */ |
||
| 276 | public function setQuantidadeMoeda($quantidadeMoeda) |
||
| 281 | |||
| 282 | /** |
||
| 283 | * @return mixed |
||
| 284 | */ |
||
| 285 | public function getReferenciaSacado() |
||
| 289 | |||
| 290 | /** |
||
| 291 | * @param mixed $referenciaSacado |
||
| 292 | * @return $this |
||
| 293 | */ |
||
| 294 | public function setReferenciaSacado($referenciaSacado) |
||
| 299 | |||
| 300 | /** |
||
| 301 | * @return mixed |
||
| 302 | */ |
||
| 303 | public function getSegmento() |
||
| 307 | |||
| 308 | /** |
||
| 309 | * @param mixed $segmento |
||
| 310 | * @return $this |
||
| 311 | */ |
||
| 312 | public function setSegmento($segmento) |
||
| 317 | |||
| 318 | /** |
||
| 319 | * @return mixed |
||
| 320 | */ |
||
| 321 | public function getTipoMovimento() |
||
| 325 | |||
| 326 | /** |
||
| 327 | * @param mixed $tipoMovimento |
||
| 328 | * @return $this |
||
| 329 | */ |
||
| 330 | public function setTipoMovimento($tipoMovimento) |
||
| 335 | |||
| 336 | /** |
||
| 337 | * @return mixed |
||
| 338 | */ |
||
| 339 | public function getValorPagamento() |
||
| 343 | |||
| 344 | /** |
||
| 345 | * @param mixed $valorPagamento |
||
| 346 | * @return $this |
||
| 347 | */ |
||
| 348 | public function setValorPagamento($valorPagamento) |
||
| 353 | |||
| 354 | /** |
||
| 355 | * @return mixed |
||
| 356 | */ |
||
| 357 | public function getValorTarifa() |
||
| 361 | |||
| 362 | /** |
||
| 363 | * @param mixed $valorTarifa |
||
| 364 | * @return $this |
||
| 365 | */ |
||
| 366 | public function setValorTarifa($valorTarifa) |
||
| 371 | |||
| 372 | /** |
||
| 373 | * @return mixed |
||
| 374 | */ |
||
| 375 | public function getValorTitulo() |
||
| 379 | |||
| 380 | /** |
||
| 381 | * @param mixed $valorTitulo |
||
| 382 | * @return $this |
||
| 383 | */ |
||
| 384 | public function setValorTitulo($valorTitulo) |
||
| 389 | |||
| 390 | /** |
||
| 391 | * @return DateTime |
||
| 392 | */ |
||
| 393 | public function getDataCredito() |
||
| 397 | |||
| 398 | /** |
||
| 399 | * @param DateTime $dataCredito |
||
| 400 | * @return $this |
||
| 401 | */ |
||
| 402 | public function setDataCredito(DateTime $dataCredito) |
||
| 407 | |||
| 408 | /** |
||
| 409 | * @return DateTime |
||
| 410 | */ |
||
| 411 | public function getDataOcorrencia() |
||
| 415 | |||
| 416 | /** |
||
| 417 | * @param DateTime $dataOcorrencia |
||
| 418 | * @return $this |
||
| 419 | */ |
||
| 420 | public function setDataOcorrencia(DateTime $dataOcorrencia) |
||
| 425 | |||
| 426 | /** |
||
| 427 | * @return float |
||
| 428 | */ |
||
| 429 | public function getOutrasDespesas() |
||
| 433 | |||
| 434 | /** |
||
| 435 | * @param float $outrasDespesas |
||
| 436 | * @return $this |
||
| 437 | */ |
||
| 438 | public function setOutrasDespesas($outrasDespesas) |
||
| 443 | |||
| 444 | /** |
||
| 445 | * @return float |
||
| 446 | */ |
||
| 447 | public function getOutrosCreditos() |
||
| 451 | |||
| 452 | /** |
||
| 453 | * @param float $outrosCreditos |
||
| 454 | * @return $this |
||
| 455 | */ |
||
| 456 | public function setOutrosCreditos($outrosCreditos) |
||
| 461 | |||
| 462 | /** |
||
| 463 | * |
||
| 464 | * @return mixed |
||
| 465 | */ |
||
| 466 | public function getNumeroSequencial() |
||
| 470 | |||
| 471 | /** |
||
| 472 | * |
||
| 473 | * @param mixed $numeroSequencial |
||
| 474 | * @return $this |
||
| 475 | */ |
||
| 476 | public function setNumeroSequencial($numeroSequencial) |
||
| 481 | |||
| 482 | /** |
||
| 483 | * |
||
| 484 | * @return mixed |
||
| 485 | */ |
||
| 486 | public function getNumeroAutenticacao() |
||
| 490 | |||
| 491 | /** |
||
| 492 | * |
||
| 493 | * @param mixed $numeroAutenticacao |
||
| 494 | * @return $this |
||
| 495 | */ |
||
| 496 | public function setNumeroAutenticacao($numeroAutenticacao) |
||
| 501 | |||
| 502 | /** |
||
| 503 | * |
||
| 504 | * @return mixed |
||
| 505 | */ |
||
| 506 | public function getValorRecebido() |
||
| 510 | |||
| 511 | /** |
||
| 512 | * |
||
| 513 | * @param mixed $valorRecebido |
||
| 514 | * @return $this |
||
| 515 | */ |
||
| 516 | public function setValorRecebido($valorRecebido) |
||
| 521 | |||
| 522 | } |
||
| 523 |