Test Failed
Pull Request — master (#3)
by Vladislav
02:16
created

PublicTradingRecordsResponse::getTime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace Carpenstar\ByBitAPI\Spot\MarketData\PublicTradingRecords\Response;
3
4
use Carpenstar\ByBitAPI\Core\Helpers\DateTimeHelper;
5
use Carpenstar\ByBitAPI\Core\Objects\ResponseEntity;
6
use Carpenstar\ByBitAPI\Spot\MarketData\PublicTradingRecords\Interfaces\IPublicTradingRecordsResponse;
7
8
class PublicTradingRecordsResponse extends ResponseEntity implements IPublicTradingRecordsResponse
9
{
10
    /**
11
     * Order price
12
     * @var float $price
13
     */
14
    private float $price;
15
16
    /**
17
     * Current timestamp
18
     * @var \DateTime $time
19
     */
20
    private \DateTime $time;
21
22
    /**
23
     * Order quantity
24
     * @var float $quantity
25
     */
26
    private float $qty;
27
28
    /**
29
     * 0:Sell or taker order, 1:Buy maker order
30
     * @var bool $isBuyerMaker
31
     */
32
    private bool $isBuyerMaker;
33
34
    /**
35
     * 0:normal trade, 1:Paradigm block trade
36
     * @var int $type
37
     */
38
    private int $type;
39
40
    /**
41
     * @param array $data
42
     */
43
    public function __construct(array $data)
44
    {
45
        $this
46
            ->setPrice($data['price'])
47
            ->setQty($data['qty'])
48
            ->setTime($data['time'])
49
            ->setIsBuyerMaker((bool)$data['isBuyerMaker'])
50
            ->setType($data['type']);
51
    }
52
53
    /**
54
     * @param string $type
55
     * @return self
56
     */
57
    private function setType(string $type): self
58
    {
59
        $this->type = $type;
0 ignored issues
show
Documentation Bug introduced by
The property $type was declared of type integer, but $type is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
60
        return $this;
61
    }
62
63
    /**
64
     * @return int
65
     */
66
    public function getType(): int
67
    {
68
        return $this->type;
69
    }
70
71
    /**
72
     * @param float $price
73
     * @return PublicTradingRecordsResponse
74
     */
75
    private function setPrice(float $price): self
76
    {
77
        $this->price = $price;
78
        return $this;
79
    }
80
81
    /**
82
     * @return float
83
     */
84
    public function getPrice(): float
85
    {
86
        return $this->price;
87
    }
88
89
    /**
90
     * @param float $quantity
91
     * @return PublicTradingRecordsResponse
92
     */
93
    private function setQty(float $quantity): self
94
    {
95
        $this->qty = $quantity;
96
        return $this;
97
    }
98
99
    /**
100
     * @return float
101
     */
102
    public function getQuantity(): float
103
    {
104
        return $this->qty;
105
    }
106
107
    /**
108
     *
109
     * @param int $time
110
     */
111
    private function setTime(int $time): self
112
    {
113
        $this->time = DateTimeHelper::makeFromTimestamp($time);
114
        return $this;
115
    }
116
117
    /**
118
     * @return \DateTime
119
     */
120
    public function getTime(): \DateTime
121
    {
122
        return $this->time;
123
    }
124
125
    /**
126
     * @param int $isBuyerMaker
127
     * @return PublicTradingRecordsResponse
128
     */
129
    private function setIsBuyerMaker(bool $isBuyerMaker): self
130
    {
131
        $this->isBuyerMaker = $isBuyerMaker;
132
        return $this;
133
    }
134
135
    /**
136
     * @return bool
137
     */
138
    public function getIsBuyerMaker(): bool
139
    {
140
        return $this->isBuyerMaker;
141
    }
142
}