Passed
Push — master ( 7a134a...be08d2 )
by Vladislav
02:35 queued 13s
created

WalletBalanceResponse   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 135
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 11
eloc 28
dl 0
loc 135
rs 10
c 0
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
A setFree() 0 4 1
A getCoinId() 0 3 1
A setCoin() 0 4 1
A getTotal() 0 3 1
A setCoinId() 0 4 1
A getCoin() 0 3 1
A getLocked() 0 3 1
A __construct() 0 8 1
A getFree() 0 3 1
A setLocked() 0 4 1
A setTotal() 0 4 1
1
<?php
2
namespace Carpenstar\ByBitAPI\Spot\Account\WalletBalance\Response;
3
4
use Carpenstar\ByBitAPI\Core\Objects\ResponseEntity;
5
6
class WalletBalanceResponse extends ResponseEntity
7
{
8
    public static string $rootDataKey = 'balances';
9
10
    /**
11
     * Coin
12
     * @var string $coin
13
     */
14
    private string $coin;
15
16
    /**
17
     * Coin ID
18
     * @var string $coinId
19
     */
20
    private string $coinId;
21
22
    /**
23
     * Total equity
24
     * @var float
25
     */
26
    private float $total;
27
28
    /**
29
     * Available balance
30
     * @var float
31
     */
32
    private float $free;
33
34
    /**
35
     * Reserved for orders
36
     * @var bool
37
     */
38
    private bool $locked;
39
40
    /**
41
     * @param array $data
42
     */
43
    public function __construct(array $data)
44
    {
45
        $this
46
            ->setCoin($data['coin'])
47
            ->setCoinId($data['coinId'])
48
            ->setFree($data['free'])
49
            ->setTotal($data['total'])
50
            ->setLocked($data['locked']);
51
    }
52
53
    /**
54
     * @param string $coin
55
     * @return $this
56
     */
57
    private function setCoin(string $coin): self
58
    {
59
        $this->coin = $coin;
60
        return $this;
61
    }
62
63
    /**
64
     * @return string
65
     */
66
    public function getCoin(): string
67
    {
68
        return $this->coin;
69
    }
70
71
    /**
72
     * @param string $coinId
73
     * @return $this
74
     */
75
    private function setCoinId(string $coinId): self
76
    {
77
        $this->coinId = $coinId;
78
        return $this;
79
    }
80
81
    /**
82
     * @return string
83
     */
84
    public function getCoinId(): string
85
    {
86
        return $this->coinId;
87
    }
88
89
    /**
90
     * @param float $total
91
     * @return $this
92
     */
93
    private function setTotal(float $total): self
94
    {
95
        $this->total = $total;
96
        return $this;
97
    }
98
99
    /**
100
     * @return float
101
     */
102
    public function getTotal(): float
103
    {
104
        return $this->total;
105
    }
106
107
    /**
108
     * @param float $free
109
     * @return $this
110
     */
111
    private function setFree(float $free): self
112
    {
113
        $this->free = $free;
114
        return $this;
115
    }
116
117
    /**
118
     * @return float
119
     */
120
    public function getFree(): float
121
    {
122
        return $this->free;
123
    }
124
125
    /**
126
     * @param int $locked
127
     * @return $this
128
     */
129
    private function setLocked(int $locked): self
130
    {
131
        $this->locked = (bool)$locked;
132
        return $this;
133
    }
134
135
    /**
136
     * @return bool
137
     */
138
    public function getLocked(): bool
139
    {
140
        return $this->locked;
141
    }
142
}