| Total Complexity | 49 |
| Total Lines | 605 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Complex classes like GetExecutionListResponse often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use GetExecutionListResponse, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 8 | class GetExecutionListResponse extends AbstractResponse implements IGetExecutionListResponseInterface |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Symbol name |
||
| 12 | * @var string $symbol |
||
| 13 | */ |
||
| 14 | private string $symbol; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Buy,Sell |
||
| 18 | * @var string $side |
||
| 19 | */ |
||
| 20 | private string $side; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Order id |
||
| 24 | * @var string $orderId |
||
| 25 | */ |
||
| 26 | private string $orderId; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * User customised order id |
||
| 30 | * @var string $orderLinkId |
||
| 31 | */ |
||
| 32 | private string $orderLinkId; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Order price |
||
| 36 | * @var float $orderPrice |
||
| 37 | */ |
||
| 38 | private float $orderPrice; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Order qty |
||
| 42 | * @var float $orderQty |
||
| 43 | */ |
||
| 44 | private float $orderQty; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Market,Limit |
||
| 48 | * @var string $orderType |
||
| 49 | */ |
||
| 50 | private string $orderType; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Stop order type |
||
| 54 | * @var string $stopOrderType |
||
| 55 | */ |
||
| 56 | private string $stopOrderType; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Trade Id |
||
| 60 | * @var string $execId |
||
| 61 | */ |
||
| 62 | private string $execId; |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Execution price |
||
| 66 | * @var float $execPrice |
||
| 67 | */ |
||
| 68 | private float $execPrice; |
||
| 69 | |||
| 70 | /** |
||
| 71 | * Execution qty |
||
| 72 | * @var float $execQty |
||
| 73 | */ |
||
| 74 | private float $execQty; |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Execution fee |
||
| 78 | * @var float $execFee |
||
| 79 | */ |
||
| 80 | private float $execFee; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Execution type |
||
| 84 | * @var string $execType |
||
| 85 | */ |
||
| 86 | private string $execType; |
||
| 87 | |||
| 88 | /** |
||
| 89 | * Execution position value |
||
| 90 | * @var float $execValue |
||
| 91 | */ |
||
| 92 | private float $execValue; |
||
| 93 | |||
| 94 | /** |
||
| 95 | * Trading fee rate |
||
| 96 | * @var float $feeRate |
||
| 97 | */ |
||
| 98 | private float $feeRate; |
||
| 99 | |||
| 100 | /** |
||
| 101 | * AddedLiquidity, RemovedLiquidity |
||
| 102 | * @var string $lastLiquidityInd |
||
| 103 | */ |
||
| 104 | private string $lastLiquidityInd; |
||
| 105 | |||
| 106 | /** |
||
| 107 | * Is maker |
||
| 108 | * @var bool $isMaker |
||
| 109 | */ |
||
| 110 | private bool $isMaker; |
||
| 111 | |||
| 112 | /** |
||
| 113 | * Remaining qty waiting for execution |
||
| 114 | * @var float $leavesQty |
||
| 115 | */ |
||
| 116 | private float $leavesQty; |
||
| 117 | |||
| 118 | /** |
||
| 119 | * Close size |
||
| 120 | * @var float $closedSize |
||
| 121 | */ |
||
| 122 | private float $closedSize; |
||
| 123 | |||
| 124 | /** |
||
| 125 | * Block trade id |
||
| 126 | * @var string $blockTradeId |
||
| 127 | */ |
||
| 128 | private string $blockTradeId; |
||
| 129 | |||
| 130 | /** |
||
| 131 | * Mark price |
||
| 132 | * @var float $markPrice |
||
| 133 | */ |
||
| 134 | private float $markPrice; |
||
| 135 | |||
| 136 | /** |
||
| 137 | * Index price |
||
| 138 | * @var float $indexPrice |
||
| 139 | */ |
||
| 140 | private float $indexPrice; |
||
| 141 | |||
| 142 | /** |
||
| 143 | * Underlying price |
||
| 144 | * @var float $underlyingPrice |
||
| 145 | */ |
||
| 146 | private float $underlyingPrice; |
||
| 147 | |||
| 148 | /** |
||
| 149 | * Execution timestamp (ms) |
||
| 150 | * @var \DateTime $execTime |
||
| 151 | */ |
||
| 152 | private \DateTime $execTime; |
||
| 153 | |||
| 154 | public function __construct(array $data) |
||
| 155 | { |
||
| 156 | $this |
||
| 157 | ->setSymbol($data['symbol']) |
||
| 158 | ->setSide($data['side']) |
||
| 159 | ->setOrderId($data['orderId']) |
||
| 160 | ->setOrderLinkId($data['orderLinkId']) |
||
| 161 | ->setOrderPrice((float) $data['orderPrice']) |
||
| 162 | ->setOrderQty((float) $data['orderQty']) |
||
| 163 | ->setOrderType($data['orderType']) |
||
| 164 | ->setStopOrderType($data['stopOrderType']) |
||
| 165 | ->setExecId($data['execId']) |
||
| 166 | ->setExecQty((float) $data['execPrice']) |
||
| 167 | ->setExecQty((float) $data['execQty']) |
||
| 168 | ->setExecFee((float) $data['execFee']) |
||
| 169 | ->setExecType($data['execType']) |
||
| 170 | ->setExecValue((float) $data['execValue']) |
||
| 171 | ->setFeeRate((float) $data['feeRate']) |
||
| 172 | ->setLastLiquidityInd($data['lastLiquidityInd']) |
||
| 173 | ->setIsMaker($data['isMaker']) |
||
| 174 | ->setLeavesQty((float) $data['leavesQty']) |
||
| 175 | ->setClosedSize((float) $data['closedSize']) |
||
| 176 | ->setBlockTradeId($data['blockTradeId']) |
||
| 177 | ->setMarkPrice((float) $data['markPrice']) |
||
| 178 | ->setIndexPrice((float) $data['indexPrice']) |
||
| 179 | ->setUnderlyingPrice((float) $data['underlyingPrice']) |
||
| 180 | ->setExecTime($data['execTime']); |
||
| 181 | } |
||
| 182 | |||
| 183 | /** |
||
| 184 | * @return string |
||
| 185 | */ |
||
| 186 | public function getSymbol(): string |
||
| 187 | { |
||
| 188 | return $this->symbol; |
||
| 189 | } |
||
| 190 | |||
| 191 | /** |
||
| 192 | * @param string $symbol |
||
| 193 | * @return GetExecutionListResponse |
||
| 194 | */ |
||
| 195 | private function setSymbol(string $symbol): self |
||
| 196 | { |
||
| 197 | $this->symbol = $symbol; |
||
| 198 | return $this; |
||
| 199 | } |
||
| 200 | |||
| 201 | /** |
||
| 202 | * @return string |
||
| 203 | */ |
||
| 204 | public function getSide(): string |
||
| 205 | { |
||
| 206 | return $this->side; |
||
| 207 | } |
||
| 208 | |||
| 209 | /** |
||
| 210 | * @param string $side |
||
| 211 | * @return GetExecutionListResponse |
||
| 212 | */ |
||
| 213 | private function setSide(string $side): self |
||
| 214 | { |
||
| 215 | $this->side = $side; |
||
| 216 | return $this; |
||
| 217 | } |
||
| 218 | |||
| 219 | /** |
||
| 220 | * @return string |
||
| 221 | */ |
||
| 222 | public function getOrderId(): string |
||
| 223 | { |
||
| 224 | return $this->orderId; |
||
| 225 | } |
||
| 226 | |||
| 227 | /** |
||
| 228 | * @param string $orderId |
||
| 229 | * @return GetExecutionListResponse |
||
| 230 | */ |
||
| 231 | public function setOrderId(string $orderId): self |
||
| 232 | { |
||
| 233 | $this->orderId = $orderId; |
||
| 234 | return $this; |
||
| 235 | } |
||
| 236 | |||
| 237 | /** |
||
| 238 | * @return string |
||
| 239 | */ |
||
| 240 | public function getOrderLinkId(): string |
||
| 241 | { |
||
| 242 | return $this->orderLinkId; |
||
| 243 | } |
||
| 244 | |||
| 245 | /** |
||
| 246 | * @param string $orderLinkId |
||
| 247 | * @return GetExecutionListResponse |
||
| 248 | */ |
||
| 249 | private function setOrderLinkId(string $orderLinkId): self |
||
| 250 | { |
||
| 251 | $this->orderLinkId = $orderLinkId; |
||
| 252 | return $this; |
||
| 253 | } |
||
| 254 | |||
| 255 | /** |
||
| 256 | * @return float |
||
| 257 | */ |
||
| 258 | public function getOrderPrice(): float |
||
| 259 | { |
||
| 260 | return $this->orderPrice; |
||
| 261 | } |
||
| 262 | |||
| 263 | /** |
||
| 264 | * @param float $orderPrice |
||
| 265 | * @return GetExecutionListResponse |
||
| 266 | */ |
||
| 267 | private function setOrderPrice(float $orderPrice): self |
||
| 268 | { |
||
| 269 | $this->orderPrice = $orderPrice; |
||
| 270 | return $this; |
||
| 271 | } |
||
| 272 | |||
| 273 | /** |
||
| 274 | * @return float |
||
| 275 | */ |
||
| 276 | public function getOrderQty(): float |
||
| 277 | { |
||
| 278 | return $this->orderQty; |
||
| 279 | } |
||
| 280 | |||
| 281 | /** |
||
| 282 | * @param float $orderQty |
||
| 283 | * @return GetExecutionListResponse |
||
| 284 | */ |
||
| 285 | private function setOrderQty(float $orderQty): self |
||
| 286 | { |
||
| 287 | $this->orderQty = $orderQty; |
||
| 288 | return $this; |
||
| 289 | } |
||
| 290 | |||
| 291 | /** |
||
| 292 | * @return string |
||
| 293 | */ |
||
| 294 | public function getOrderType(): string |
||
| 295 | { |
||
| 296 | return $this->orderType; |
||
| 297 | } |
||
| 298 | |||
| 299 | /** |
||
| 300 | * @param string $orderType |
||
| 301 | * @return GetExecutionListResponse |
||
| 302 | */ |
||
| 303 | private function setOrderType(string $orderType): self |
||
| 304 | { |
||
| 305 | $this->orderType = $orderType; |
||
| 306 | return $this; |
||
| 307 | } |
||
| 308 | |||
| 309 | /** |
||
| 310 | * @return string |
||
| 311 | */ |
||
| 312 | public function getStopOrderType(): string |
||
| 313 | { |
||
| 314 | return $this->stopOrderType; |
||
| 315 | } |
||
| 316 | |||
| 317 | /** |
||
| 318 | * @param string $stopOrderType |
||
| 319 | * @return GetExecutionListResponse |
||
| 320 | */ |
||
| 321 | private function setStopOrderType(string $stopOrderType): self |
||
| 322 | { |
||
| 323 | $this->stopOrderType = $stopOrderType; |
||
| 324 | return $this; |
||
| 325 | } |
||
| 326 | |||
| 327 | /** |
||
| 328 | * @return string |
||
| 329 | */ |
||
| 330 | public function getExecId(): string |
||
| 333 | } |
||
| 334 | |||
| 335 | /** |
||
| 336 | * @param string $execId |
||
| 337 | * @return GetExecutionListResponse |
||
| 338 | */ |
||
| 339 | private function setExecId(string $execId): self |
||
| 340 | { |
||
| 341 | $this->execId = $execId; |
||
| 342 | return $this; |
||
| 343 | } |
||
| 344 | |||
| 345 | /** |
||
| 346 | * @return float |
||
| 347 | */ |
||
| 348 | public function getExecPrice(): float |
||
| 349 | { |
||
| 350 | return $this->execPrice; |
||
| 351 | } |
||
| 352 | |||
| 353 | /** |
||
| 354 | * @param float $execPrice |
||
| 355 | * @return GetExecutionListResponse |
||
| 356 | */ |
||
| 357 | private function setExecPrice(float $execPrice): self |
||
| 361 | } |
||
| 362 | |||
| 363 | /** |
||
| 364 | * @return float |
||
| 365 | */ |
||
| 366 | public function getExecQty(): float |
||
| 367 | { |
||
| 368 | return $this->execQty; |
||
| 369 | } |
||
| 370 | |||
| 371 | /** |
||
| 372 | * @param float $execQty |
||
| 373 | * @return GetExecutionListResponse |
||
| 374 | */ |
||
| 375 | private function setExecQty(float $execQty): self |
||
| 376 | { |
||
| 377 | $this->execQty = $execQty; |
||
| 378 | return $this; |
||
| 379 | } |
||
| 380 | |||
| 381 | /** |
||
| 382 | * @return float |
||
| 383 | */ |
||
| 384 | public function getExecFee(): float |
||
| 385 | { |
||
| 386 | return $this->execFee; |
||
| 387 | } |
||
| 388 | |||
| 389 | /** |
||
| 390 | * @param float $execFee |
||
| 391 | * @return GetExecutionListResponse |
||
| 392 | */ |
||
| 393 | private function setExecFee(float $execFee): self |
||
| 394 | { |
||
| 395 | $this->execFee = $execFee; |
||
| 396 | return $this; |
||
| 397 | } |
||
| 398 | |||
| 399 | /** |
||
| 400 | * @return string |
||
| 401 | */ |
||
| 402 | public function getExecType(): string |
||
| 403 | { |
||
| 404 | return $this->execType; |
||
| 405 | } |
||
| 406 | |||
| 407 | /** |
||
| 408 | * @param string $execType |
||
| 409 | * @return GetExecutionListResponse |
||
| 410 | */ |
||
| 411 | private function setExecType(string $execType): self |
||
| 412 | { |
||
| 413 | $this->execType = $execType; |
||
| 414 | return $this; |
||
| 415 | } |
||
| 416 | |||
| 417 | /** |
||
| 418 | * @return float |
||
| 419 | */ |
||
| 420 | public function getExecValue(): float |
||
| 421 | { |
||
| 422 | return $this->execValue; |
||
| 423 | } |
||
| 424 | |||
| 425 | /** |
||
| 426 | * @param float $execValue |
||
| 427 | * @return GetExecutionListResponse |
||
| 428 | */ |
||
| 429 | private function setExecValue(float $execValue): self |
||
| 430 | { |
||
| 431 | $this->execValue = $execValue; |
||
| 432 | return $this; |
||
| 433 | } |
||
| 434 | |||
| 435 | /** |
||
| 436 | * @return float |
||
| 437 | */ |
||
| 438 | public function getFeeRate(): float |
||
| 439 | { |
||
| 440 | return $this->feeRate; |
||
| 441 | } |
||
| 442 | |||
| 443 | /** |
||
| 444 | * @param float $feeRate |
||
| 445 | * @return GetExecutionListResponse |
||
| 446 | */ |
||
| 447 | private function setFeeRate(float $feeRate): self |
||
| 448 | { |
||
| 449 | $this->feeRate = $feeRate; |
||
| 450 | return $this; |
||
| 451 | } |
||
| 452 | |||
| 453 | /** |
||
| 454 | * @return string |
||
| 455 | */ |
||
| 456 | public function getLastLiquidityInd(): string |
||
| 457 | { |
||
| 458 | return $this->lastLiquidityInd; |
||
| 459 | } |
||
| 460 | |||
| 461 | /** |
||
| 462 | * @param string $lastLiquidityInd |
||
| 463 | * @return GetExecutionListResponse |
||
| 464 | */ |
||
| 465 | private function setLastLiquidityInd(string $lastLiquidityInd): self |
||
| 466 | { |
||
| 467 | $this->lastLiquidityInd = $lastLiquidityInd; |
||
| 468 | return $this; |
||
| 469 | } |
||
| 470 | |||
| 471 | /** |
||
| 472 | * @return bool |
||
| 473 | */ |
||
| 474 | public function isMaker(): bool |
||
| 475 | { |
||
| 476 | return $this->isMaker; |
||
| 477 | } |
||
| 478 | |||
| 479 | /** |
||
| 480 | * @param bool $isMaker |
||
| 481 | * @return GetExecutionListResponse |
||
| 482 | */ |
||
| 483 | private function setIsMaker(bool $isMaker): self |
||
| 484 | { |
||
| 485 | $this->isMaker = $isMaker; |
||
| 486 | return $this; |
||
| 487 | } |
||
| 488 | |||
| 489 | /** |
||
| 490 | * @return float |
||
| 491 | */ |
||
| 492 | public function getLeavesQty(): float |
||
| 493 | { |
||
| 494 | return $this->leavesQty; |
||
| 495 | } |
||
| 496 | |||
| 497 | /** |
||
| 498 | * @param float $leavesQty |
||
| 499 | * @return GetExecutionListResponse |
||
| 500 | */ |
||
| 501 | private function setLeavesQty(float $leavesQty): self |
||
| 502 | { |
||
| 503 | $this->leavesQty = $leavesQty; |
||
| 504 | return $this; |
||
| 505 | } |
||
| 506 | |||
| 507 | /** |
||
| 508 | * @return float |
||
| 509 | */ |
||
| 510 | public function getClosedSize(): float |
||
| 511 | { |
||
| 512 | return $this->closedSize; |
||
| 513 | } |
||
| 514 | |||
| 515 | /** |
||
| 516 | * @param float $closedSize |
||
| 517 | * @return GetExecutionListResponse |
||
| 518 | */ |
||
| 519 | private function setClosedSize(float $closedSize): self |
||
| 520 | { |
||
| 521 | $this->closedSize = $closedSize; |
||
| 522 | return $this; |
||
| 523 | } |
||
| 524 | |||
| 525 | /** |
||
| 526 | * @return string |
||
| 527 | */ |
||
| 528 | public function getBlockTradeId(): string |
||
| 529 | { |
||
| 530 | return $this->blockTradeId; |
||
| 531 | } |
||
| 532 | |||
| 533 | /** |
||
| 534 | * @param string $blockTradeId |
||
| 535 | * @return GetExecutionListResponse |
||
| 536 | */ |
||
| 537 | private function setBlockTradeId(string $blockTradeId): self |
||
| 538 | { |
||
| 539 | $this->blockTradeId = $blockTradeId; |
||
| 540 | return $this; |
||
| 541 | } |
||
| 542 | |||
| 543 | /** |
||
| 544 | * @return float |
||
| 545 | */ |
||
| 546 | public function getMarkPrice(): float |
||
| 547 | { |
||
| 548 | return $this->markPrice; |
||
| 549 | } |
||
| 550 | |||
| 551 | /** |
||
| 552 | * @param float $markPrice |
||
| 553 | * @return GetExecutionListResponse |
||
| 554 | */ |
||
| 555 | private function setMarkPrice(float $markPrice): self |
||
| 559 | } |
||
| 560 | |||
| 561 | /** |
||
| 562 | * @return float |
||
| 563 | */ |
||
| 564 | public function getIndexPrice(): float |
||
| 565 | { |
||
| 566 | return $this->indexPrice; |
||
| 567 | } |
||
| 568 | |||
| 569 | /** |
||
| 570 | * @param float $indexPrice |
||
| 571 | * @return GetExecutionListResponse |
||
| 572 | */ |
||
| 573 | private function setIndexPrice(float $indexPrice): self |
||
| 574 | { |
||
| 575 | $this->indexPrice = $indexPrice; |
||
| 576 | return $this; |
||
| 577 | } |
||
| 578 | |||
| 579 | /** |
||
| 580 | * @return float |
||
| 581 | */ |
||
| 582 | public function getUnderlyingPrice(): float |
||
| 583 | { |
||
| 584 | return $this->underlyingPrice; |
||
| 585 | } |
||
| 586 | |||
| 587 | /** |
||
| 588 | * @param float $underlyingPrice |
||
| 589 | * @return GetExecutionListResponse |
||
| 590 | */ |
||
| 591 | private function setUnderlyingPrice(float $underlyingPrice): self |
||
| 592 | { |
||
| 593 | $this->underlyingPrice = $underlyingPrice; |
||
| 594 | return $this; |
||
| 595 | } |
||
| 596 | |||
| 597 | /** |
||
| 598 | * @return \DateTime |
||
| 599 | */ |
||
| 600 | public function getExecTime(): \DateTime |
||
| 603 | } |
||
| 604 | |||
| 605 | /** |
||
| 606 | * @param string $execTime |
||
| 607 | * @return GetExecutionListResponse |
||
| 608 | */ |
||
| 609 | private function setExecTime(string $execTime): self |
||
| 610 | { |
||
| 611 | $this->execTime = DateTimeHelper::makeFromTimestamp($execTime); |
||
| 612 | return $this; |
||
| 613 | } |
||
| 614 | } |
This check looks for private methods that have been defined, but are not used inside the class.