Complex classes like PagamentoExterno 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 PagamentoExterno, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 10 | class PagamentoExterno implements \JsonSerializable |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var integer |
||
| 14 | */ |
||
| 15 | private $id; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var integer |
||
| 19 | */ |
||
| 20 | private $tipo; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var integer |
||
| 24 | */ |
||
| 25 | private $origem; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var integer |
||
| 29 | */ |
||
| 30 | private $tipoParcelamento; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @var PagamentoExternoStatus |
||
| 34 | */ |
||
| 35 | private $pagamentoExternoStatus; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @var Pessoa |
||
| 39 | */ |
||
| 40 | private $pessoa; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @var IntencaoVenda |
||
| 44 | */ |
||
| 45 | private $intencoesVenda; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @var Terminal |
||
| 49 | */ |
||
| 50 | private $terminal; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @var integer |
||
| 54 | */ |
||
| 55 | private $nsuTid; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @var string |
||
| 59 | */ |
||
| 60 | private $autorizacao; |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @var string |
||
| 64 | */ |
||
| 65 | private $adquirente; |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @var string |
||
| 69 | */ |
||
| 70 | private $codigoRespostaAdquirente; |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @var string |
||
| 74 | */ |
||
| 75 | private $mensagemRespostaAdquirente; |
||
| 76 | |||
| 77 | /** |
||
| 78 | * @var \DateTime |
||
| 79 | */ |
||
| 80 | private $dataAdquirente; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @var string |
||
| 84 | */ |
||
| 85 | private $respostaAdquirente; |
||
| 86 | |||
| 87 | /** |
||
| 88 | * @var string |
||
| 89 | */ |
||
| 90 | private $comprovanteAdquirente; |
||
| 91 | |||
| 92 | /** |
||
| 93 | * @var array |
||
| 94 | */ |
||
| 95 | private $comprovanteAdquirenteLinhas; |
||
| 96 | |||
| 97 | /** |
||
| 98 | * PagamentoExterno constructor. |
||
| 99 | */ |
||
| 100 | public function __construct() |
||
| 103 | |||
| 104 | /** |
||
| 105 | * @return int |
||
| 106 | */ |
||
| 107 | public function getId() |
||
| 111 | |||
| 112 | /** |
||
| 113 | * @param int $id |
||
| 114 | * @return PagamentoExterno |
||
| 115 | */ |
||
| 116 | public function setId($id) |
||
| 121 | |||
| 122 | /** |
||
| 123 | * @return int |
||
| 124 | */ |
||
| 125 | public function getTipo() |
||
| 129 | |||
| 130 | /** |
||
| 131 | * @param int $tipo |
||
| 132 | * @return PagamentoExterno |
||
| 133 | */ |
||
| 134 | public function setTipo($tipo) |
||
| 139 | |||
| 140 | /** |
||
| 141 | * @return int |
||
| 142 | */ |
||
| 143 | public function getOrigem() |
||
| 147 | |||
| 148 | /** |
||
| 149 | * @param int $origem |
||
| 150 | * @return PagamentoExterno |
||
| 151 | */ |
||
| 152 | public function setOrigem($origem) |
||
| 157 | |||
| 158 | /** |
||
| 159 | * @return int |
||
| 160 | */ |
||
| 161 | public function getTipoParcelamento() |
||
| 165 | |||
| 166 | /** |
||
| 167 | * @param int $tipoParcelamento |
||
| 168 | * @return PagamentoExterno |
||
| 169 | */ |
||
| 170 | public function setTipoParcelamento($tipoParcelamento) |
||
| 175 | |||
| 176 | /** |
||
| 177 | * @return PagamentoExternoStatus |
||
| 178 | */ |
||
| 179 | public function getPagamentoExternoStatus() |
||
| 183 | |||
| 184 | /** |
||
| 185 | * @param PagamentoExternoStatus $pagamentoExternoStatus |
||
| 186 | * @return PagamentoExterno |
||
| 187 | */ |
||
| 188 | public function setPagamentoExternoStatus($pagamentoExternoStatus) |
||
| 198 | |||
| 199 | /** |
||
| 200 | * @return Pessoa |
||
| 201 | */ |
||
| 202 | public function getPessoa() |
||
| 206 | |||
| 207 | /** |
||
| 208 | * @param Pessoa $pessoa |
||
| 209 | * @return PagamentoExterno |
||
| 210 | */ |
||
| 211 | public function setPessoa($pessoa) |
||
| 220 | |||
| 221 | /** |
||
| 222 | * @return IntencaoVenda |
||
| 223 | */ |
||
| 224 | public function getIntencoesVenda() |
||
| 228 | |||
| 229 | /** |
||
| 230 | * @param IntencaoVenda $intencoesVenda |
||
| 231 | * @return PagamentoExterno |
||
| 232 | */ |
||
| 233 | public function setIntencoesVenda($intencoesVenda) |
||
| 242 | |||
| 243 | /** |
||
| 244 | * @return Terminal |
||
| 245 | */ |
||
| 246 | public function getTerminal() |
||
| 250 | |||
| 251 | /** |
||
| 252 | * @param Terminal $terminal |
||
| 253 | * @return PagamentoExterno |
||
| 254 | */ |
||
| 255 | public function setTerminal($terminal) |
||
| 264 | |||
| 265 | /** |
||
| 266 | * @return int |
||
| 267 | */ |
||
| 268 | public function getNsuTid() |
||
| 272 | |||
| 273 | /** |
||
| 274 | * @param int $nsuTid |
||
| 275 | * @return PagamentoExterno |
||
| 276 | */ |
||
| 277 | public function setNsuTid($nsuTid) |
||
| 282 | |||
| 283 | /** |
||
| 284 | * @return string |
||
| 285 | */ |
||
| 286 | public function getAutorizacao() |
||
| 290 | |||
| 291 | /** |
||
| 292 | * @param string $autorizacao |
||
| 293 | * @return PagamentoExterno |
||
| 294 | */ |
||
| 295 | public function setAutorizacao($autorizacao) |
||
| 300 | |||
| 301 | /** |
||
| 302 | * @return string |
||
| 303 | */ |
||
| 304 | public function getAdquirente() |
||
| 308 | |||
| 309 | /** |
||
| 310 | * @param string $adquirente |
||
| 311 | * @return PagamentoExterno |
||
| 312 | */ |
||
| 313 | public function setAdquirente($adquirente) |
||
| 318 | |||
| 319 | /** |
||
| 320 | * @return string |
||
| 321 | */ |
||
| 322 | public function getCodigoRespostaAdquirente() |
||
| 326 | |||
| 327 | /** |
||
| 328 | * @param string $codigoRespostaAdquirente |
||
| 329 | * @return PagamentoExterno |
||
| 330 | */ |
||
| 331 | public function setCodigoRespostaAdquirente($codigoRespostaAdquirente) |
||
| 336 | |||
| 337 | /** |
||
| 338 | * @return string |
||
| 339 | */ |
||
| 340 | public function getMensagemRespostaAdquirente() |
||
| 344 | |||
| 345 | /** |
||
| 346 | * @param string $mensagemRespostaAdquirente |
||
| 347 | * @return PagamentoExterno |
||
| 348 | */ |
||
| 349 | public function setMensagemRespostaAdquirente($mensagemRespostaAdquirente) |
||
| 354 | |||
| 355 | /** |
||
| 356 | * @return \DateTime |
||
| 357 | */ |
||
| 358 | public function getDataAdquirente() |
||
| 362 | |||
| 363 | /** |
||
| 364 | * @param \DateTime $dataAdquirente |
||
| 365 | * @return PagamentoExterno |
||
| 366 | */ |
||
| 367 | public function setDataAdquirente($dataAdquirente) |
||
| 372 | |||
| 373 | /** |
||
| 374 | * @return string |
||
| 375 | */ |
||
| 376 | public function getRespostaAdquirente() |
||
| 380 | |||
| 381 | /** |
||
| 382 | * @param string $respostaAdquirente |
||
| 383 | * @return PagamentoExterno |
||
| 384 | */ |
||
| 385 | public function setRespostaAdquirente($respostaAdquirente) |
||
| 390 | |||
| 391 | /** |
||
| 392 | * @return string |
||
| 393 | */ |
||
| 394 | public function getComprovanteAdquirente() |
||
| 398 | |||
| 399 | /** |
||
| 400 | * @param string $comprovanteAdquirente |
||
| 401 | * @return PagamentoExterno |
||
| 402 | */ |
||
| 403 | public function setComprovanteAdquirente($comprovanteAdquirente) |
||
| 414 | |||
| 415 | /** |
||
| 416 | * @return array |
||
| 417 | */ |
||
| 418 | public function getComprovanteAdquirenteLinhas() |
||
| 422 | |||
| 423 | /** |
||
| 424 | * @param array $comprovanteAdquirenteLinhas |
||
| 425 | * @return PagamentoExterno |
||
| 426 | */ |
||
| 427 | public function setComprovanteAdquirenteLinhas($comprovanteAdquirenteLinhas) |
||
| 432 | |||
| 433 | function jsonSerialize() |
||
| 453 | |||
| 454 | |||
| 455 | } |