Passed
Push — master ( 8ca73d...2eaf19 )
by Vladislav
02:37 queued 15s
created

PublicTradeResponseItem::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 12
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 14
rs 9.8666
1
<?php
2
namespace Carpenstar\ByBitAPI\WebSockets\Derivatives\PublicChannels\PublicTrade\Entities;
3
4
use Carpenstar\ByBitAPI\Core\Helpers\DateTimeHelper;
5
use Carpenstar\ByBitAPI\Core\Objects\AbstractResponse;
6
7
class PublicTradeResponseItem extends AbstractResponse
8
{
9
    private \DateTime $filledAt;
10
11
    private string $symbol;
12
13
    private string $side;
14
15
    private ?float $quantity;
16
17
    private ?float $executedPrice;
18
19
    private ?string $changePriceDirection;
20
21
    private string $tradeId;
22
23
    private bool $isBlockTrade;
24
25
    private ?float $markPrice;
26
27
    private ?float $indexPrice;
28
29
    private ?float $ivPrice;
30
31
    private ?float $iv;
32
33
    public function __construct(array $data)
34
    {
35
        $this->filledAt = DateTimeHelper::makeFromTimestamp($data['T']);
36
        $this->symbol = $data['s'];
37
        $this->side = $data['S'];
38
        $this->quantity = $data['v'];
39
        $this->executedPrice = $data['p'];
40
        $this->changePriceDirection = $data['L'];
41
        $this->tradeId = $data['i'];
42
        $this->isBlockTrade = $data['BT'];
43
        $this->markPrice = $data['mP'] ?? null;
44
        $this->indexPrice = $data['iP'] ?? null;
45
        $this->ivPrice = $data['mlv'] ?? null;
46
        $this->iv = $data['iv'] ?? null;
47
    }
48
49
    public function getFilledAt(): \DateTime
50
    {
51
        return $this->filledAt;
52
    }
53
54
    public function getSymbol(): string
55
    {
56
        return $this->symbol;
57
    }
58
59
    public function getSide(): string
60
    {
61
        return $this->side;
62
    }
63
64
    public function getQuantity(): float
65
    {
66
        return $this->quantity;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->quantity could return the type null which is incompatible with the type-hinted return double. Consider adding an additional type-check to rule them out.
Loading history...
67
    }
68
69
    public function getExecutedPrice(): float
70
    {
71
        return $this->executedPrice;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->executedPrice could return the type null which is incompatible with the type-hinted return double. Consider adding an additional type-check to rule them out.
Loading history...
72
    }
73
74
    public function getChangePriceDirection(): string
75
    {
76
        return $this->changePriceDirection;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->changePriceDirection could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
77
    }
78
79
    public function getTradeId(): string
80
    {
81
        return $this->tradeId;
82
    } 
83
84
    public function isBlockTrade(): bool
85
    {
86
        return $this->isBlockTrade;
87
    }
88
89
    public function getMarkPrice(): float
90
    {
91
        return $this->markPrice;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->markPrice could return the type null which is incompatible with the type-hinted return double. Consider adding an additional type-check to rule them out.
Loading history...
92
    }
93
94
    public function getIndexPrice(): float
95
    {
96
        return $this->indexPrice;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->indexPrice could return the type null which is incompatible with the type-hinted return double. Consider adding an additional type-check to rule them out.
Loading history...
97
    }
98
99
    public function getIvPrice(): float
100
    {
101
        return $this->ivPrice;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->ivPrice could return the type null which is incompatible with the type-hinted return double. Consider adding an additional type-check to rule them out.
Loading history...
102
    }
103
104
    public function getIv(): float
105
    {
106
        return $this->iv;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->iv could return the type null which is incompatible with the type-hinted return double. Consider adding an additional type-check to rule them out.
Loading history...
107
    }
108
}
109