ContaRecebimento::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Integracao\ControlPay\Model;
4
use Integracao\ControlPay\Helpers\SerializerHelper;
5
6
/**
7
 * Class ContaRecebimento
8
 * @package Integracao\ControlPay\Model
9
 */
10
class ContaRecebimento implements \JsonSerializable
11
{
12
    /**
13
     * @var integer
14
     */
15
    private $id;
16
17
    /**
18
     * @var Pessoa
19
     */
20
    private $pessoa;
21
22
    /**
23
     * @var double
24
     */
25
    private $saldoAtual;
26
27
    /**
28
     * @var \DateTime
29
     */
30
    private $dataInsercao;
31
32
    /**
33
     * @var array
34
     */
35
    private $contaRecebimentoLancamentos;
36
37
    /**
38
     * ContaRecebimento constructor.
39
     */
40
    public function __construct()
41
    {
42
    }
43
44
    /**
45
     * @return int
46
     */
47
    public function getId()
48
    {
49
        return $this->id;
50
    }
51
52
    /**
53
     * @param int $id
54
     * @return ContaRecebimento
55
     */
56
    public function setId($id)
57
    {
58
        $this->id = $id;
59
        return $this;
60
    }
61
62
    /**
63
     * @return Pessoa
64
     */
65
    public function getPessoa()
66
    {
67
        return $this->pessoa;
68
    }
69
70
    /**
71
     * @param Pessoa $pessoa
72
     * @return ContaRecebimento
73
     */
74
    public function setPessoa($pessoa)
75
    {
76
        $this->pessoa = $pessoa;
77
78
        if(is_array($this->pessoa))
79
            $this->pessoa = SerializerHelper::denormalize($pessoa, Pessoa::class);
80
81
        return $this;
82
    }
83
84
    /**
85
     * @return float
86
     */
87
    public function getSaldoAtual()
88
    {
89
        return $this->saldoAtual;
90
    }
91
92
    /**
93
     * @param float $saldoAtual
94
     * @return ContaRecebimento
95
     */
96
    public function setSaldoAtual($saldoAtual)
97
    {
98
        $this->saldoAtual = $saldoAtual;
99
        return $this;
100
    }
101
102
    /**
103
     * @return \DateTime
104
     */
105
    public function getDataInsercao()
106
    {
107
        return $this->dataInsercao;
108
    }
109
110
    /**
111
     * @param \DateTime $dataInsercao
112
     * @return ContaRecebimento
113
     */
114
    public function setDataInsercao($dataInsercao)
115
    {
116
        $this->dataInsercao = \DateTime::createFromFormat('d/m/Y H:i:s.u', $dataInsercao);
0 ignored issues
show
Documentation Bug introduced by
It seems like \DateTime::createFromFor...:i:s.u', $dataInsercao) can also be of type false. However, the property $dataInsercao is declared as type object<DateTime>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
117
        return $this;
118
    }
119
120
    /**
121
     * @return array
122
     */
123
    public function getContaRecebimentoLancamentos()
124
    {
125
        return $this->contaRecebimentoLancamentos;
126
    }
127
128
    /**
129
     * @param array $contaRecebimentoLancamentos
130
     * @return ContaRecebimento
131
     */
132
    public function setContaRecebimentoLancamentos($contaRecebimentoLancamentos)
133
    {
134
135
        foreach ($contaRecebimentoLancamentos as $contaRecebimentoLancamento)
136
        {
137
            $this->contaRecebimentoLancamentos[] = SerializerHelper::denormalize(
138
                $contaRecebimentoLancamento, ContaRecebimentoLancamento::class);
139
        }
140
141
        return $this;
142
    }
143
144
    function jsonSerialize()
145
    {
146
        return [
147
            'id' => $this->id,
148
            'pessoa' => $this->pessoa,
149
            'saldoAtual' => $this->saldoAtual,
150
            'dataInsercao' => $this->dataInsercao,
151
            'contaRecebimentoLancamentos' => $this->contaRecebimentoLancamentos,
152
        ];
153
    }
154
155
156
}