| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| Code Lines | 40 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 16 | public function buildDetail(Stringy $linha) |
||
| 17 | { |
||
| 18 | $detail = new Detail(); |
||
| 19 | $banco = new Banco(); |
||
| 20 | $bancoSacado = new Banco(); |
||
| 21 | $sacado = new Sacado(); |
||
| 22 | $ocorrencia = new Ocorrencia(); |
||
| 23 | $dadosTitulo = new DadosTitulo(); |
||
| 24 | $cedente = new Cedente(); |
||
| 25 | |||
| 26 | $bancoSacado->setCod($linha->substr(1, 3)); |
||
| 27 | $sacado->setBanco($bancoSacado); |
||
| 28 | |||
| 29 | $detail |
||
| 30 | ->setLote($linha->substr(4, 4)) |
||
| 31 | ->setRegistro($linha->substr(8, 1)) |
||
| 32 | ->setNumRegistroLote($linha->substr(9, 5)) |
||
| 33 | ->setSegmento($linha->substr(14, 1)) |
||
| 34 | ->addCnab($linha->substr(15, 1)) |
||
| 35 | ->setCodMovimento($linha->substr(16, 2)); |
||
| 36 | |||
| 37 | //Dados do Titulo |
||
| 38 | $dadosTitulo->setAcrescimos($this->convertToFloat($linha->substr(18, 15))) |
||
| 39 | ->setValorDesconto($this->convertToFloat($linha->substr(33, 15))) |
||
| 40 | ->setValorAbatimento($this->convertToFloat($linha->substr(48, 15))) |
||
| 41 | ->setValorIOF($this->convertToFloat($linha->substr(63, 15))) |
||
| 42 | ->setValorPago($this->convertToFloat($linha->substr(78, 15))) |
||
| 43 | ->setValorLiquido($this->convertToFloat($linha->substr(93, 15))); |
||
| 44 | |||
| 45 | $detail->setDadosTitulo($dadosTitulo) |
||
| 46 | ->setOutrasDespesas($this->convertToFloat($linha->substr(108, 15))) |
||
| 47 | ->setOutrosCreditos($this->convertToFloat($linha->substr(123, 15))) |
||
| 48 | ->setDataOcorrencia($this->createDate($linha->substr(138, 8), "dmY")) |
||
| 49 | ->setDataCredito($this->createDate($linha->substr(146, 8), "dmY")); |
||
| 50 | |||
| 51 | $ocorrencia->setCod(($this->convertToInt($linha->substr(154, 4)))) |
||
| 52 | ->setData($this->createDate($linha->substr(158, 8))) |
||
| 53 | ->setValor($this->convertToFloat($linha->substr(166, 15))) |
||
| 54 | ->setComplemento($linha->substr(181, 30)); |
||
| 55 | |||
| 56 | $banco->setCod($linha->substr(211, 3)); |
||
| 57 | $cedente->setBanco($banco); |
||
| 58 | |||
| 59 | $detail->setNossoNumero($linha->substr(214, 20)) |
||
| 60 | ->addCnab($linha->substr(234, 7)); |
||
| 61 | |||
| 62 | $detail |
||
| 63 | ->setCedente($cedente) |
||
| 64 | ->setSacado($sacado); |
||
| 65 | |||
| 66 | return $detail; |
||
| 67 | } |
||
| 68 | } |
||
| 69 |