SegmentoT   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 8

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 1
c 2
b 0
f 1
lcom 0
cbo 8
dl 0
loc 56
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A buildDetail() 0 52 1
1
<?php
2
3
namespace Umbrella\Ya\RetornoBoleto\Cnab\Cnab240\Segmento;
4
5
use Stringy\Stringy;
6
use Umbrella\Ya\RetornoBoleto\Cnab\Cnab240\Detail;
7
use Umbrella\Ya\RetornoBoleto\Model\Banco;
8
use Umbrella\Ya\RetornoBoleto\Model\Cedente;
9
use Umbrella\Ya\RetornoBoleto\Model\Empresa;
10
use Umbrella\Ya\RetornoBoleto\Model\Inscricao;
11
use Umbrella\Ya\RetornoBoleto\Model\Sacado;
12
13
class SegmentoT extends AbstractSegmento
14
{
15
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))
0 ignored issues
show
Documentation introduced by
$linha->substr(74, 8) is of type object<Stringy\Stringy>, but the function expects a object<DateTime>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
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