Passed
Pull Request — master (#10)
by Vladislav
15:29 queued 07:37
created

PublicTradeResponseItem   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
c 1
b 0
f 0
dl 0
loc 76
rs 10
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getTradeType() 0 3 1
A getPrice() 0 3 1
A getTradingTime() 0 3 1
A getTradeId() 0 3 1
A __construct() 0 8 1
A getQuantity() 0 3 1
A getIsTaker() 0 3 1
1
<?php
2
namespace Carpenstar\ByBitAPI\WebSockets\Channels\Spot\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
    /**
10
     * Trade ID
11
     * @var string $tradeId
12
     */
13
    private string $tradeId;
14
15
    /**
16
     * Timestamp (trading time in the match box)
17
     * @var \DateTime $tradingTime
18
     */
19
    private \DateTime $tradingTime;
20
21
    /**
22
     * Price
23
     * @var float $price
24
     */
25
    private float $price;
26
27
    /**
28
     * Quantity
29
     * @var float $quantity
30
     */
31
    private float $quantity;
32
33
    /**
34
     * True indicates buy side is taker, false indicates sell side is taker
35
     * @var bool $isTaker
36
     */
37
    private bool $isTaker;
38
39
    /**
40
     * Trade type. 0:Spot trade. 1:Paradigm block trade
41
     * @var int $tradeType
42
     */
43
    private int $tradeType;
44
45
    public function __construct(array $data)
46
    {
47
        $this->price = $data['p'];
48
        $this->quantity = $data['q'];
49
        $this->tradeId = $data['v'];
50
        $this->tradeType = $data['type'];
51
        $this->isTaker = $data['m'];
52
        $this->tradingTime = DateTimeHelper::makeFromTimestamp($data['t']);
53
    }
54
55
    public function getPrice(): float
56
    {
57
        return $this->price;
58
    }
59
60
    public function getQuantity(): float
61
    {
62
        return $this->quantity;
63
    }
64
65
    public function getTradeId(): string
66
    {
67
        return $this->tradeId;
68
    }
69
70
    public function getTradeType(): int
71
    {
72
        return $this->tradeType;
73
    }
74
75
    public function getTradingTime(): \DateTime
76
    {
77
        return $this->tradingTime;
78
    }
79
80
    public function getIsTaker(): bool
81
    {
82
        return $this->isTaker;
83
    }
84
}
85