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

PlaceOrderResponse::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

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

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