| Total Complexity | 53 |
| Total Lines | 601 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like Order 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 Order, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 9 | class Order extends AbstractSObject |
||
| 10 | { |
||
| 11 | use BillingAddressTrait; |
||
| 12 | use ShippingAddressTrait; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var string|null |
||
| 16 | * @JMS\Type("string") |
||
| 17 | * @JMS\Groups({"update", "create"}) |
||
| 18 | */ |
||
| 19 | protected $ownerId; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var string|null |
||
| 23 | * @JMS\Type("string") |
||
| 24 | * @JMS\Groups({"update", "create"}) |
||
| 25 | */ |
||
| 26 | protected $contractId; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @var string|null |
||
| 30 | * @JMS\Type("string") |
||
| 31 | * @JMS\Groups({"update", "create"}) |
||
| 32 | */ |
||
| 33 | protected $accountId; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @var string|null |
||
| 37 | * @JMS\Type("string") |
||
| 38 | * @JMS\Groups({"update", "create"}) |
||
| 39 | * @JMS\SerializedName("Pricebook2Id") |
||
| 40 | */ |
||
| 41 | protected $pricebookId; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @var string|null |
||
| 45 | * @JMS\Type("string") |
||
| 46 | * @JMS\Groups({"create"}) |
||
| 47 | */ |
||
| 48 | protected $originalOrderId; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @var \DateTimeInterface|null |
||
| 52 | * @JMS\Type("DateTime<'Y-m-d'>") |
||
| 53 | * @JMS\Groups({"update", "create"}) |
||
| 54 | */ |
||
| 55 | protected $effectiveDate; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @var \DateTimeInterface|null |
||
| 59 | * @JMS\Type("DateTime<'Y-m-d'>") |
||
| 60 | * @JMS\Groups({"update", "create"}) |
||
| 61 | */ |
||
| 62 | protected $endDate; |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @var bool |
||
| 66 | * @JMS\Type("boolean") |
||
| 67 | */ |
||
| 68 | protected $isReductionOrder; |
||
| 69 | |||
| 70 | /** |
||
| 71 | * @var string |
||
| 72 | * @JMS\Type("string") |
||
| 73 | * @JMS\Groups({"update", "create"}) |
||
| 74 | */ |
||
| 75 | protected $status; |
||
| 76 | |||
| 77 | /** |
||
| 78 | * @var string|null |
||
| 79 | * @JMS\Type("string") |
||
| 80 | * @JMS\Groups({"update", "create"}) |
||
| 81 | */ |
||
| 82 | protected $description; |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @var string|null |
||
| 86 | * @JMS\Type("string") |
||
| 87 | * @JMS\Groups({"update", "create"}) |
||
| 88 | */ |
||
| 89 | protected $customerAuthorizedById; |
||
| 90 | |||
| 91 | /** |
||
| 92 | * @var \DateTimeInterface|null |
||
| 93 | * @JMS\Type("DateTime<'Y-m-d'>") |
||
| 94 | * @JMS\Groups({"update", "create"}) |
||
| 95 | */ |
||
| 96 | protected $customerAuthorizedDate; |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @var string|null |
||
| 100 | * @JMS\Type("string") |
||
| 101 | * @JMS\Groups({"update", "create"}) |
||
| 102 | */ |
||
| 103 | protected $companyAuthorizedById; |
||
| 104 | |||
| 105 | /** |
||
| 106 | * @var \DateTimeInterface|null |
||
| 107 | * @JMS\Type("DateTime<'Y-m-d'>") |
||
| 108 | * @JMS\Groups({"update", "create"}) |
||
| 109 | */ |
||
| 110 | protected $companyAuthorizedDate; |
||
| 111 | |||
| 112 | /** |
||
| 113 | * @var string|null |
||
| 114 | * @JMS\Type("string") |
||
| 115 | * @JMS\Groups({"update", "create"}) |
||
| 116 | */ |
||
| 117 | protected $type; |
||
| 118 | |||
| 119 | /** |
||
| 120 | * @var string|null |
||
| 121 | * @JMS\Type("string") |
||
| 122 | * @JMS\Groups({"update", "create"}) |
||
| 123 | */ |
||
| 124 | protected $name; |
||
| 125 | |||
| 126 | /** |
||
| 127 | * @var \DateTimeInterface|null |
||
| 128 | * @JMS\Type("DateTime<'Y-m-d'>") |
||
| 129 | * @JMS\Groups({"update", "create"}) |
||
| 130 | */ |
||
| 131 | protected $poDate; |
||
| 132 | |||
| 133 | /** |
||
| 134 | * @var string|null |
||
| 135 | * @JMS\Type("string") |
||
| 136 | * @JMS\Groups({"update", "create"}) |
||
| 137 | */ |
||
| 138 | protected $poNumber; |
||
| 139 | |||
| 140 | /** |
||
| 141 | * @var string|null |
||
| 142 | * @JMS\Type("string") |
||
| 143 | * @JMS\Groups({"update", "create"}) |
||
| 144 | */ |
||
| 145 | protected $orderReferenceNumber; |
||
| 146 | |||
| 147 | /** |
||
| 148 | * @var string|null |
||
| 149 | * @JMS\Type("string") |
||
| 150 | * @JMS\Groups({"update", "create"}) |
||
| 151 | */ |
||
| 152 | protected $billToContactId; |
||
| 153 | |||
| 154 | /** |
||
| 155 | * @var string|null |
||
| 156 | * @JMS\Type("string") |
||
| 157 | * @JMS\Groups({"update", "create"}) |
||
| 158 | */ |
||
| 159 | protected $shipToContactId; |
||
| 160 | |||
| 161 | /** |
||
| 162 | * @var \DateTimeInterface|null |
||
| 163 | * @JMS\Type("DateTime<'Y-m-d\TH:i:s.\0\0\0O'>") |
||
| 164 | */ |
||
| 165 | protected $activatedDate; |
||
| 166 | |||
| 167 | /** |
||
| 168 | * @var string|null |
||
| 169 | * @JMS\Type("string") |
||
| 170 | * @JMS\Groups({"update", "create"}) |
||
| 171 | */ |
||
| 172 | protected $activatedById; |
||
| 173 | |||
| 174 | /** |
||
| 175 | * @var string|null |
||
| 176 | * @JMS\Type("string") |
||
| 177 | * @JMS\Groups({"update", "create"}) |
||
| 178 | */ |
||
| 179 | protected $statusCode; |
||
| 180 | |||
| 181 | /** |
||
| 182 | * @var string|null |
||
| 183 | * @JMS\Type("string") |
||
| 184 | */ |
||
| 185 | protected $orderNumber; |
||
| 186 | |||
| 187 | /** |
||
| 188 | * @var float|null |
||
| 189 | * @JMS\Type("float") |
||
| 190 | */ |
||
| 191 | protected $totalAmount; |
||
| 192 | |||
| 193 | /** |
||
| 194 | * @var \DateTimeInterface|null |
||
| 195 | * @JMS\Type("DateTime<'Y-m-d\TH:i:s.\0\0\0O'>") |
||
| 196 | */ |
||
| 197 | protected $lastViewedDate; |
||
| 198 | |||
| 199 | /** |
||
| 200 | * @var \DateTimeInterface|null |
||
| 201 | * @JMS\Type("DateTime<'Y-m-d\TH:i:s.\0\0\0O'>") |
||
| 202 | */ |
||
| 203 | protected $lastReferencedDate; |
||
| 204 | |||
| 205 | /** |
||
| 206 | * @var bool|null |
||
| 207 | * @JMS\Type("boolean") |
||
| 208 | */ |
||
| 209 | protected $isDeleted; |
||
| 210 | |||
| 211 | /** |
||
| 212 | * {@inheritdoc} |
||
| 213 | */ |
||
| 214 | public static function getSObjectName(): AbstractSObjectType |
||
| 215 | { |
||
| 216 | return SObjectType::ORDER(); |
||
| 217 | } |
||
| 218 | |||
| 219 | /** |
||
| 220 | * @return string|null |
||
| 221 | */ |
||
| 222 | public function getOwnerId() |
||
| 223 | { |
||
| 224 | return $this->ownerId; |
||
| 225 | } |
||
| 226 | |||
| 227 | /** |
||
| 228 | * @return string|null |
||
| 229 | */ |
||
| 230 | public function getContractId() |
||
| 231 | { |
||
| 232 | return $this->contractId; |
||
| 233 | } |
||
| 234 | |||
| 235 | /** |
||
| 236 | * @return string|null |
||
| 237 | */ |
||
| 238 | public function getAccountId() |
||
| 239 | { |
||
| 240 | return $this->accountId; |
||
| 241 | } |
||
| 242 | |||
| 243 | /** |
||
| 244 | * @return string|null |
||
| 245 | */ |
||
| 246 | public function getPricebookId() |
||
| 247 | { |
||
| 248 | return $this->pricebookId; |
||
| 249 | } |
||
| 250 | |||
| 251 | /** |
||
| 252 | * @return string|null |
||
| 253 | */ |
||
| 254 | public function getOriginalOrderId() |
||
| 255 | { |
||
| 256 | return $this->originalOrderId; |
||
| 257 | } |
||
| 258 | |||
| 259 | /** |
||
| 260 | * @return \DateTimeInterface|null |
||
| 261 | */ |
||
| 262 | public function getEffectiveDate() |
||
| 263 | { |
||
| 264 | return $this->effectiveDate; |
||
| 265 | } |
||
| 266 | |||
| 267 | /** |
||
| 268 | * @return \DateTimeInterface|null |
||
| 269 | */ |
||
| 270 | public function getEndDate() |
||
| 271 | { |
||
| 272 | return $this->endDate; |
||
| 273 | } |
||
| 274 | |||
| 275 | /** |
||
| 276 | * @return bool |
||
| 277 | */ |
||
| 278 | public function getIsReductionOrder() |
||
| 279 | { |
||
| 280 | return $this->isReductionOrder; |
||
| 281 | } |
||
| 282 | |||
| 283 | /** |
||
| 284 | * @return string|null |
||
| 285 | */ |
||
| 286 | public function getStatus() |
||
| 287 | { |
||
| 288 | return $this->status; |
||
| 289 | } |
||
| 290 | |||
| 291 | /** |
||
| 292 | * @return string|null |
||
| 293 | */ |
||
| 294 | public function getDescription() |
||
| 295 | { |
||
| 296 | return $this->description; |
||
| 297 | } |
||
| 298 | |||
| 299 | /** |
||
| 300 | * @return string|null |
||
| 301 | */ |
||
| 302 | public function getCustomerAuthorizedById() |
||
| 303 | { |
||
| 304 | return $this->customerAuthorizedById; |
||
| 305 | } |
||
| 306 | |||
| 307 | /** |
||
| 308 | * @return \DateTimeInterface|null |
||
| 309 | */ |
||
| 310 | public function getCustomerAuthorizedDate() |
||
| 311 | { |
||
| 312 | return $this->customerAuthorizedDate; |
||
| 313 | } |
||
| 314 | |||
| 315 | /** |
||
| 316 | * @return string|null |
||
| 317 | */ |
||
| 318 | public function getCompanyAuthorizedById() |
||
| 319 | { |
||
| 320 | return $this->companyAuthorizedById; |
||
| 321 | } |
||
| 322 | |||
| 323 | /** |
||
| 324 | * @return \DateTimeInterface|null |
||
| 325 | */ |
||
| 326 | public function getCompanyAuthorizedDate() |
||
| 327 | { |
||
| 328 | return $this->companyAuthorizedDate; |
||
| 329 | } |
||
| 330 | |||
| 331 | /** |
||
| 332 | * @return string|null |
||
| 333 | */ |
||
| 334 | public function getType() |
||
| 335 | { |
||
| 336 | return $this->type; |
||
| 337 | } |
||
| 338 | |||
| 339 | /** |
||
| 340 | * @return string|null |
||
| 341 | */ |
||
| 342 | public function getName() |
||
| 343 | { |
||
| 344 | return $this->name; |
||
| 345 | } |
||
| 346 | |||
| 347 | /** |
||
| 348 | * @return \DateTimeInterface|null |
||
| 349 | */ |
||
| 350 | public function getPoDate() |
||
| 351 | { |
||
| 352 | return $this->poDate; |
||
| 353 | } |
||
| 354 | |||
| 355 | /** |
||
| 356 | * @return string|null |
||
| 357 | */ |
||
| 358 | public function getPoNumber() |
||
| 359 | { |
||
| 360 | return $this->poNumber; |
||
| 361 | } |
||
| 362 | |||
| 363 | /** |
||
| 364 | * @return string|null |
||
| 365 | */ |
||
| 366 | public function getOrderReferenceNumber() |
||
| 367 | { |
||
| 368 | return $this->orderReferenceNumber; |
||
| 369 | } |
||
| 370 | |||
| 371 | /** |
||
| 372 | * @return string|null |
||
| 373 | */ |
||
| 374 | public function getBillToContactId() |
||
| 375 | { |
||
| 376 | return $this->billToContactId; |
||
| 377 | } |
||
| 378 | |||
| 379 | /** |
||
| 380 | * @return string|null |
||
| 381 | */ |
||
| 382 | public function getShipToContactId() |
||
| 383 | { |
||
| 384 | return $this->shipToContactId; |
||
| 385 | } |
||
| 386 | |||
| 387 | /** |
||
| 388 | * @return \DateTimeInterface|null |
||
| 389 | */ |
||
| 390 | public function getActivatedDate() |
||
| 391 | { |
||
| 392 | return $this->activatedDate; |
||
| 393 | } |
||
| 394 | |||
| 395 | /** |
||
| 396 | * @return string|null |
||
| 397 | */ |
||
| 398 | public function getActivatedById() |
||
| 399 | { |
||
| 400 | return $this->activatedById; |
||
| 401 | } |
||
| 402 | |||
| 403 | /** |
||
| 404 | * @return string|null |
||
| 405 | */ |
||
| 406 | public function getStatusCode() |
||
| 407 | { |
||
| 408 | return $this->statusCode; |
||
| 409 | } |
||
| 410 | |||
| 411 | /** |
||
| 412 | * @return string|null |
||
| 413 | */ |
||
| 414 | public function getOrderNumber() |
||
| 415 | { |
||
| 416 | return $this->orderNumber; |
||
| 417 | } |
||
| 418 | |||
| 419 | /** |
||
| 420 | * @return float|null |
||
| 421 | */ |
||
| 422 | public function getTotalAmount() |
||
| 423 | { |
||
| 424 | return $this->totalAmount; |
||
| 425 | } |
||
| 426 | |||
| 427 | /** |
||
| 428 | * @return \DateTimeInterface|null |
||
| 429 | */ |
||
| 430 | public function getLastViewedDate() |
||
| 431 | { |
||
| 432 | return $this->lastViewedDate; |
||
| 433 | } |
||
| 434 | |||
| 435 | /** |
||
| 436 | * @return \DateTimeInterface|null |
||
| 437 | */ |
||
| 438 | public function getLastReferencedDate() |
||
| 441 | } |
||
| 442 | |||
| 443 | /** |
||
| 444 | * @return bool|null |
||
| 445 | */ |
||
| 446 | public function isDeleted() |
||
| 447 | { |
||
| 448 | return $this->isDeleted; |
||
| 449 | } |
||
| 450 | |||
| 451 | public function setOwnerId(string $ownerId): self |
||
| 452 | { |
||
| 453 | $this->ownerId = $ownerId; |
||
| 454 | |||
| 455 | return $this; |
||
| 456 | } |
||
| 457 | |||
| 458 | public function setContractId(string $contractId = null): self |
||
| 459 | { |
||
| 460 | $this->contractId = $contractId; |
||
| 461 | |||
| 462 | return $this; |
||
| 463 | } |
||
| 464 | |||
| 465 | public function setAccountId(string $accountId = null): self |
||
| 466 | { |
||
| 467 | $this->accountId = $accountId; |
||
| 468 | |||
| 469 | return $this; |
||
| 470 | } |
||
| 471 | |||
| 472 | public function setPricebookId(string $pricebookId = null): self |
||
| 473 | { |
||
| 474 | $this->pricebookId = $pricebookId; |
||
| 475 | |||
| 476 | return $this; |
||
| 477 | } |
||
| 478 | |||
| 479 | public function setOriginalOrderId(string $originalOrderId = null): self |
||
| 480 | { |
||
| 481 | $this->originalOrderId = $originalOrderId; |
||
| 482 | |||
| 483 | return $this; |
||
| 484 | } |
||
| 485 | |||
| 486 | public function setEffectiveDate(\DateTimeInterface $effectiveDate): self |
||
| 487 | { |
||
| 488 | $this->effectiveDate = $effectiveDate; |
||
| 489 | |||
| 490 | return $this; |
||
| 491 | } |
||
| 492 | |||
| 493 | public function setEndDate(\DateTimeInterface $endDate): self |
||
| 494 | { |
||
| 495 | $this->endDate = $endDate; |
||
| 496 | |||
| 497 | return $this; |
||
| 498 | } |
||
| 499 | |||
| 500 | public function setStatus(string $status): self |
||
| 501 | { |
||
| 502 | $this->status = $status; |
||
| 503 | |||
| 504 | return $this; |
||
| 505 | } |
||
| 506 | |||
| 507 | public function setDescription(string $description = null): self |
||
| 508 | { |
||
| 509 | $this->description = $description; |
||
| 510 | |||
| 511 | return $this; |
||
| 512 | } |
||
| 513 | |||
| 514 | public function setCustomerAuthorizedById(string $customerAuthorizedById = null): self |
||
| 515 | { |
||
| 516 | $this->customerAuthorizedById = $customerAuthorizedById; |
||
| 517 | |||
| 518 | return $this; |
||
| 519 | } |
||
| 520 | |||
| 521 | public function setCustomerAuthorizedDate(\DateTimeInterface $customerAuthorizedDate = null): self |
||
| 522 | { |
||
| 523 | $this->customerAuthorizedDate = $customerAuthorizedDate; |
||
| 524 | |||
| 525 | return $this; |
||
| 526 | } |
||
| 527 | |||
| 528 | public function setCompanyAuthorizedById(string $companyAuthorizedById = null): self |
||
| 529 | { |
||
| 530 | $this->companyAuthorizedById = $companyAuthorizedById; |
||
| 531 | |||
| 532 | return $this; |
||
| 533 | } |
||
| 534 | |||
| 535 | public function setCompanyAuthorizedDate(\DateTimeInterface $companyAuthorizedDate = null): self |
||
| 536 | { |
||
| 537 | $this->companyAuthorizedDate = $companyAuthorizedDate; |
||
| 538 | |||
| 539 | return $this; |
||
| 540 | } |
||
| 541 | |||
| 542 | public function setType(string $type = null): self |
||
| 543 | { |
||
| 544 | $this->type = $type; |
||
| 545 | |||
| 546 | return $this; |
||
| 547 | } |
||
| 548 | |||
| 549 | public function setName(string $name = null): self |
||
| 550 | { |
||
| 551 | $this->name = $name; |
||
| 552 | |||
| 553 | return $this; |
||
| 554 | } |
||
| 555 | |||
| 556 | public function setPoDate(\DateTimeInterface $poDate = null): self |
||
| 557 | { |
||
| 558 | $this->poDate = $poDate; |
||
| 559 | |||
| 560 | return $this; |
||
| 561 | } |
||
| 562 | |||
| 563 | public function setPoNumber(string $poNumber = null): self |
||
| 568 | } |
||
| 569 | |||
| 570 | public function setOrderReferenceNumber(string $orderReferenceNumber = null): self |
||
| 571 | { |
||
| 572 | $this->orderReferenceNumber = $orderReferenceNumber; |
||
| 573 | |||
| 574 | return $this; |
||
| 575 | } |
||
| 576 | |||
| 577 | public function setBillToContactId(string $billToContactId = null): self |
||
| 578 | { |
||
| 579 | $this->billToContactId = $billToContactId; |
||
| 580 | |||
| 581 | return $this; |
||
| 582 | } |
||
| 583 | |||
| 584 | public function setShipToContactId(string $shipToContactId = null): self |
||
| 585 | { |
||
| 586 | $this->shipToContactId = $shipToContactId; |
||
| 587 | |||
| 588 | return $this; |
||
| 589 | } |
||
| 590 | |||
| 591 | public function setActivatedDate(\DateTimeInterface $activatedDate = null): self |
||
| 592 | { |
||
| 593 | $this->activatedDate = $activatedDate; |
||
| 594 | |||
| 595 | return $this; |
||
| 596 | } |
||
| 597 | |||
| 598 | public function setActivatedById(string $activatedById = null): self |
||
| 603 | } |
||
| 604 | |||
| 605 | public function setStatusCode(string $statusCode): self |
||
| 606 | { |
||
| 607 | $this->statusCode = $statusCode; |
||
| 608 | |||
| 609 | return $this; |
||
| 610 | } |
||
| 611 | } |
||
| 612 |