PlaceOrderResponse::setOrderQty()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Carpenstar\ByBitAPI\Spot\Trade\PlaceOrder\Response;
4
5
use Carpenstar\ByBitAPI\Core\Helpers\DateTimeHelper;
6
use Carpenstar\ByBitAPI\Core\Objects\AbstractResponse;
7
use Carpenstar\ByBitAPI\Spot\Trade\PlaceOrder\Interfaces\IPlaceOrderResponseInterface;
8
9
class PlaceOrderResponse extends AbstractResponse implements IPlaceOrderResponseInterface
10
{
11
    /**
12
     * Order ID
13
     * @var int $orderId
14
     */
15
    private ?int $orderId;
16
17
    /**
18
     * User-generated order ID
19
     * @var string $orderLinkId
20
     */
21
    private ?string $orderLinkId;
22
23
    /**
24
     * Name of the trading pair
25
     * @var string $symbol
26
     */
27
    private ?string $symbol;
28
29
    /**
30
     * Order Creation Time
31
     * @var \DateTime $createTime
32
     */
33
    private \DateTime $createTime;
34
35
    /**
36
     * Last traded price
37
     * @var float $orderPrice
38
     */
39
    private ?float $orderPrice;
40
41
    /**
42
     * Order quantity
43
     * @var float $orderQty
44
     */
45
    private ?float $orderQty;
46
47
    /**
48
     * Order type
49
     * @var string $orderType
50
     */
51
    private ?string $orderType;
52
53
    /**
54
     * Side. BUY, SELL
55
     * @var string $side
56
     */
57
    private ?string $side;
58
59
    /**
60
     * Order status
61
     * @var string $status
62
     */
63
    private ?string $status;
64
65
    /**
66
     * Time in force
67
     * @var string $timeInForce
68
     */
69
    private ?string $timeInForce;
70
71
    /**
72
     * Account ID
73
     * @var string $accountId
74
     */
75
    private ?string $accountId;
76
77
    /**
78
     * Order category. 0:normal order by default; 1:TP/SL order
79
     * @var int $orderCategory
80
     */
81
    private ?int $orderCategory;
82
83
    /**
84
     * Trigger price. TP/SL order has this field
85
     * @var float $triggerPrice
86
     */
87
    private ?float $triggerPrice;
88
89
    /**
90
     * @param array $data
91
     */
92
    public function __construct(array $data)
93
    {
94
        $this
95
            ->setOrderId($data['orderId'] ?? null)
96
            ->setOrderLinkId($data['orderLinkId'] ?? null)
97
            ->setSymbol($data['symbol'] ?? null)
98
            ->setCreateTime($data['createTime'] ?? null)
99
            ->setOrderPrice($data['orderPrice'] ?? null)
100
            ->setOrderQty($data['orderQty'] ?? null)
101
            ->setOrderType($data['orderType'] ?? null)
102
            ->setSide($data['side'] ?? null)
103
            ->setStatus($data['status'] ?? null)
104
            ->setTimeInForce($data['timeInForce'] ?? null)
105
            ->setAccountId($data['accountId'] ?? null)
106
            ->setOrderCategory($data['orderCategory'] ?? null)
107
            ->setTriggerPrice($data['triggerPrice'] ?? null);
108
    }
109
110
    /**
111
     * @param int $orderId
112
     * @return $this
113
     */
114
    private function setOrderId(?int $orderId): self
115
    {
116
        $this->orderId = $orderId;
117
        return $this;
118
    }
119
120
    /**
121
     * @return int
122
     */
123
    public function getOrderId(): ?int
124
    {
125
        return $this->orderId;
126
    }
127
128
    private function setOrderLinkId(?string $orderLinkId): self
129
    {
130
        $this->orderLinkId = $orderLinkId;
131
        return $this;
132
    }
133
134
    /**
135
     * @return string
136
     */
137
    public function getOrderLinkId(): ?string
138
    {
139
        return $this->orderLinkId;
140
    }
141
142
    /**
143
     * @param string $symbol
144
     * @return $this
145
     */
146
    private function setSymbol(?string $symbol): self
147
    {
148
        $this->symbol = $symbol;
149
        return $this;
150
    }
151
152
    /**
153
     * @return string
154
     */
155
    public function getSymbol(): ?string
156
    {
157
        return $this->symbol;
158
    }
159
160
    /**
161
     * @param int $createTime
162
     * @return $this
163
     */
164
    private function setCreateTime(?string $createTime): self
165
    {
166
        if (!empty($createTime)) {
167
            $this->createTime = DateTimeHelper::makeFromTimestamp($createTime);
0 ignored issues
show
Bug introduced by
$createTime of type string is incompatible with the type integer expected by parameter $timestamp of Carpenstar\ByBitAPI\Core...er::makeFromTimestamp(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

167
            $this->createTime = DateTimeHelper::makeFromTimestamp(/** @scrutinizer ignore-type */ $createTime);
Loading history...
168
        }
169
        return $this;
170
    }
171
172
    /**
173
     * @return \DateTime
174
     */
175
    public function getCreateTime(): \DateTime
176
    {
177
        return $this->createTime;
178
    }
179
180
    /**
181
     * @param float $orderPrice
182
     * @return PlaceOrderResponse
183
     */
184
    public function setOrderPrice(?float $orderPrice): self
185
    {
186
        $this->orderPrice = $orderPrice;
187
        return $this;
188
    }
189
190
    /**
191
     * @return float
192
     */
193
    public function getOrderPrice(): ?float
194
    {
195
        return $this->orderPrice;
196
    }
197
198
    /**
199
     * @param float $orderQty
200
     * @return PlaceOrderResponse
201
     */
202
    private function setOrderQty(?float $orderQty): self
203
    {
204
        $this->orderQty = $orderQty;
205
        return $this;
206
    }
207
208
    /**
209
     * @return float
210
     */
211
    public function getOrderQty(): ?float
212
    {
213
        return $this->orderQty;
214
    }
215
216
    /**
217
     * @param string|null $orderType
218
     * @return $this
219
     */
220
    private function setOrderType(?string $orderType): self
221
    {
222
        $this->orderType = $orderType;
223
        return $this;
224
    }
225
226
    /**
227
     * @return string|null
228
     */
229
    public function getOrderType(): ?string
230
    {
231
        return $this->orderType;
232
    }
233
234
    /**
235
     * @return string|null
236
     */
237
    public function getStatus(): ?string
238
    {
239
        return $this->status;
240
    }
241
242
    /**
243
     * @param string|null $status
244
     * @return PlaceOrderResponse
245
     */
246
    private function setStatus(?string $status): self
247
    {
248
        $this->status = $status;
249
        return $this;
250
    }
251
252
    /**
253
     * @param string $side
254
     * @return PlaceOrderResponse
255
     */
256
    private function setSide(?string $side): self
257
    {
258
        $this->side = $side;
259
        return $this;
260
    }
261
262
    /**
263
     * @return string
264
     */
265
    public function getSide(): ?string
266
    {
267
        return $this->side;
268
    }
269
270
    /**
271
     * @param string $timeInForce
272
     * @return PlaceOrderResponse
273
     */
274
    private function setTimeInForce(?string $timeInForce): self
275
    {
276
        $this->timeInForce = $timeInForce;
277
        return $this;
278
    }
279
280
    /**
281
     * @return string
282
     */
283
    public function getTimeInForce(): ?string
284
    {
285
        return $this->timeInForce;
286
    }
287
288
    /**
289
     * @param string $accountId
290
     * @return PlaceOrderResponse
291
     */
292
    private function setAccountId(?string $accountId): self
293
    {
294
        $this->accountId = $accountId;
295
        return $this;
296
    }
297
298
    /**
299
     * @return string
300
     */
301
    public function getAccountId(): ?string
302
    {
303
        return $this->accountId;
304
    }
305
306
    /**
307
     * @param int $orderCategory
308
     * @return PlaceOrderResponse
309
     */
310
    public function setOrderCategory(?int $orderCategory): self
311
    {
312
        $this->orderCategory = $orderCategory;
313
        return $this;
314
    }
315
316
    /**
317
     * @return int
318
     */
319
    public function getOrderCategory(): ?int
320
    {
321
        return $this->orderCategory;
322
    }
323
324
    /**
325
     * @param float $triggerPrice
326
     * @return PlaceOrderResponse
327
     */
328
    public function setTriggerPrice(?float $triggerPrice): self
329
    {
330
        $this->triggerPrice = $triggerPrice;
331
        return $this;
332
    }
333
334
    /**
335
     * @return float
336
     */
337
    public function getTriggerPrice(): ?float
338
    {
339
        return $this->triggerPrice;
340
    }
341
}
342