BoocktickerResponseItem   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
c 0
b 0
f 0
dl 0
loc 66
rs 10
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getResponseTimestamp() 0 3 1
A getBidQuantity() 0 3 1
A getBestAskPrice() 0 3 1
A __construct() 0 8 1
A getAskQuantity() 0 3 1
A getSymbol() 0 3 1
A getBestBidPrice() 0 3 1
1
<?php
2
3
namespace Carpenstar\ByBitAPI\WebSockets\Spot\PublicChannels\Bookticker\Entities;
4
5
use Carpenstar\ByBitAPI\Core\Helpers\DateTimeHelper;
6
use Carpenstar\ByBitAPI\Core\Objects\AbstractResponse;
7
8
class BoocktickerResponseItem extends AbstractResponse
9
{
10
    private string $symbol;
11
    private ?float $bestBidPrice;
12
    private ?float $bidQuantity;
13
    private ?float $bestAskPrice;
14
    private ?float $askQuantity;
15
    private \DateTime $responseTimestamp;
16
17
18
    public function __construct(array $data)
19
    {
20
        $this->responseTimestamp = DateTimeHelper::makeFromTimestamp($data['t']);
21
        $this->bestBidPrice = $data['bp'] ?? null;
22
        $this->bidQuantity = $data['bq'] ?? null;
23
        $this->bestAskPrice = $data['ap'] ?? null;
24
        $this->askQuantity = $data['aq'] ?? null;
25
        $this->symbol = $data['s'];
26
    }
27
28
    /**
29
     * @return \DateTime
30
     */
31
    public function getResponseTimestamp(): \DateTime
32
    {
33
        return $this->responseTimestamp;
34
    }
35
36
    /**
37
     * @return float
38
     */
39
    public function getBestBidPrice(): float
40
    {
41
        return $this->bestBidPrice;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->bestBidPrice 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...
42
    }
43
44
    /**
45
     * @return float
46
     */
47
    public function getBidQuantity(): float
48
    {
49
        return $this->bidQuantity;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->bidQuantity 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...
50
    }
51
52
    /**
53
     * @return float
54
     */
55
    public function getBestAskPrice(): float
56
    {
57
        return $this->bestAskPrice;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->bestAskPrice 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...
58
    }
59
60
    /**
61
     * @return float
62
     */
63
    public function getAskQuantity(): float
64
    {
65
        return $this->askQuantity;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->askQuantity 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...
66
    }
67
68
    /**
69
     * @return string
70
     */
71
    public function getSymbol(): string
72
    {
73
        return $this->symbol;
74
    }
75
}
76