DadoBoleto::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Itau\API\BoleCode;
4
5
use Itau\API\TraitEntity;
6
7
class DadoBoleto implements \JsonSerializable
8
{
9
    use TraitEntity;
10
11
    const ESPECIE_DM = '01';
12
    const ESPECIE_DS = '08';
13
14
    private string $descricao_instrumento_cobranca = "boleto_pix";
0 ignored issues
show
introduced by
The private property $descricao_instrumento_cobranca is not used, and could be removed.
Loading history...
15
    private int $codigo_carteira = 109;
0 ignored issues
show
introduced by
The private property $codigo_carteira is not used, and could be removed.
Loading history...
16
    private string $valor_total_titulo;
17
    private string $codigo_especie;
18
    private string $data_emissao;
19
    private string $texto_seu_numero;
20
    private Pagador $pagador;
21
    private ?array $dados_individuais_boleto = [];
22
    private Juros $juros;
23
    private Multa $multa;
24
25
26
    public function __construct()
27
    {
28
        $this->data_emissao = date("Y-m-d");
29
    }
30
31
    public function setDados(string $valor, string $codigoEspecia,string $numero): self
32
    {
33
        $this->valor_total_titulo = round($valor*100);
34
        $this->codigo_especie = $codigoEspecia;
35
        $this->texto_seu_numero = $numero;
36
        return $this;
37
    }
38
39
    public function pagador(): Pagador
40
    {
41
        $pagador = new Pagador();
42
43
        $this->setPagador($pagador);
44
45
        return $pagador;
46
    }
47
48
    private function setPagador(Pagador $pagador): self
49
    {
50
        $this->pagador = $pagador;
51
        return $this;
52
    }
53
54
    public function dadosIndividuais(): DadosIndividuaisBoleto
55
    {
56
        $dados = new DadosIndividuaisBoleto();
57
58
        $this->setDadosIndividuaisBoleto($dados);
59
60
        return $dados;
61
    }
62
63
    private function setDadosIndividuaisBoleto(DadosIndividuaisBoleto $dados): self
64
    {
65
        array_push($this->dados_individuais_boleto, $dados);
0 ignored issues
show
Bug introduced by
It seems like $this->dados_individuais_boleto can also be of type null; however, parameter $array of array_push() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

65
        array_push(/** @scrutinizer ignore-type */ $this->dados_individuais_boleto, $dados);
Loading history...
66
        return $this;
67
    }
68
69
    public function juros(): Juros
70
    {
71
        $juros = new Juros();
72
73
        $this->setJuros($juros);
74
75
        return $juros;
76
    }
77
78
    private function setJuros(Juros $juros): self
79
    {
80
        $this->juros = $juros;
81
        return $this;
82
    }
83
84
    public function multa(): Multa
85
    {
86
        $multa = new Multa();
87
88
        $this->setMulta($multa);
89
90
        return $multa;
91
    }
92
93
    private function setMulta(Multa $multa): self
94
    {
95
        $this->multa = $multa;
96
        return $this;
97
    }
98
}