| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| Code Lines | 39 |
| 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 | |||
| 20 | $banco = new Banco(); |
||
| 21 | $banco->setCod($linha->substr(1, 3)); |
||
| 22 | |||
| 23 | $detail |
||
| 24 | ->setLote($linha->substr(4, 4)) |
||
| 25 | ->setRegistro($linha->substr(8, 1)) |
||
| 26 | ->setNumRegistroLote($linha->substr(9, 5)) |
||
| 27 | ->setSegmento($linha->substr(14, 1)) |
||
| 28 | ->setTipoMovimento($linha->substr(15, 1)) |
||
| 29 | ->setCodMovimento($linha->substr(16, 2)); |
||
| 30 | |||
| 31 | $banco->setAgencia($linha->substr(18, 5)) |
||
| 32 | ->setDvAgencia($linha->substr(23, 1)) |
||
| 33 | ->setConta($linha->substr(24, 12)) |
||
| 34 | ->setDvConta($linha->substr(36, 1)); |
||
| 35 | |||
| 36 | $detail->setNossoNumero($linha->substr(38, 20)) |
||
| 37 | ->setCarteira($linha->substr(58, 1)) |
||
| 38 | ->setNumeroDocumento($linha->substr(59, 15)) |
||
| 39 | ->setDataVencimento($linha->substr(74, 8)) |
||
|
|
|||
| 40 | ->setValorTitulo($this->convertToFloat($linha->substr(82, 15))); |
||
| 41 | |||
| 42 | $banco->setCod($linha->substr(97, 3)) |
||
| 43 | ->setAgencia($linha->substr(100, 5)) |
||
| 44 | ->setDvAgencia($linha->substr(105, 1)); |
||
| 45 | |||
| 46 | $empresa = new Empresa(); |
||
| 47 | $empresa->addUso($linha->substr(106, 25)); |
||
| 48 | |||
| 49 | $detail->setCodMoeda($linha->substr(131, 2)); |
||
| 50 | |||
| 51 | $sacado = new Sacado(); |
||
| 52 | $sacado->setInscricao(new Inscricao($linha->substr(134, 15), $linha->substr(133, 1))) |
||
| 53 | ->setNome($linha->substr(149, 40)); |
||
| 54 | |||
| 55 | $detail->setNumeroContrato($linha->substr(189, 10)) |
||
| 56 | ->setValorTarifa($this->convertToFloat($linha->substr(199, 15))) |
||
| 57 | ->addOcorrencia($linha->substr(214, 10)) |
||
| 58 | ->addCnab($linha->substr(224, 17)); |
||
| 59 | |||
| 60 | $cedente = new Cedente(); |
||
| 61 | $cedente->setBanco($banco); |
||
| 62 | $detail |
||
| 63 | ->setCedente($cedente) |
||
| 64 | ->setSacado($sacado); |
||
| 65 | |||
| 66 | return $detail; |
||
| 67 | } |
||
| 68 | } |
||
| 69 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: