Completed
Push — master ( 741114...78e68a )
by Adriano
09:10
created

CancelarVendaResponse::setIntencaoVenda()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
3
namespace Integracao\ControlPay\Contracts\Venda;
4
5
use Integracao\ControlPay\Helpers\SerializerHelper;
6
use Integracao\ControlPay\Model\IntencaoVenda;
7
8
/**
9
 * Class CancelarVendaResponse
10
 * @package Integracao\ControlPay\Contracts\Venda
11
 */
12 View Code Duplication
class CancelarVendaResponse
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
{
14
    /**
15
     * @var \DateTime
16
     */
17
    private $data;
18
19
    /**
20
     * @var IntencaoVenda
21
     */
22
    private $intencaoVenda;
23
24
    /**
25
     * VenderResponse constructor.
26
     */
27
    public function __construct()
28
    {
29
    }
30
31
    /**
32
     * @return \DateTime
33
     */
34
    public function getData()
35
    {
36
        return $this->data;
37
    }
38
39
    /**
40
     * @param \DateTime $data
41
     * @return VenderResponse
42
     */
43
    public function setData($data)
44
    {
45
        $this->data = \DateTime::createFromFormat('d/m/Y H:i:s.u', $data);
0 ignored issues
show
Documentation Bug introduced by
It seems like \DateTime::createFromFor...'d/m/Y H:i:s.u', $data) can also be of type false. However, the property $data 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...
46
        return $this;
47
    }
48
49
    /**
50
     * @return IntencaoVenda
51
     */
52
    public function getIntencaoVenda()
53
    {
54
        return $this->intencaoVenda;
55
    }
56
57
    /**
58
     * @param IntencaoVenda $intencaoVenda
59
     * @return VenderResponse
60
     */
61
    public function setIntencaoVenda($intencaoVenda)
62
    {
63
        $this->intencaoVenda = $intencaoVenda;
64
65
        if(is_array($this->intencaoVenda))
66
            $this->intencaoVenda = SerializerHelper::denormalize($this->intencaoVenda, IntencaoVenda::class);
67
68
        return $this;
69
    }
70
71
}