Total Complexity | 66 |
Total Lines | 729 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like Account 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 Account, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
9 | class Account extends AbstractSObject |
||
10 | { |
||
11 | use BillingAddressTrait; |
||
12 | use ShippingAddressTrait; |
||
13 | |||
14 | /** |
||
15 | * @var bool|null |
||
16 | * @JMS\Type("boolean") |
||
17 | */ |
||
18 | protected $isDeleted; |
||
19 | |||
20 | /** |
||
21 | * @var string|null |
||
22 | * @JMS\Type("string") |
||
23 | */ |
||
24 | protected $masterRecordId; |
||
25 | |||
26 | /** |
||
27 | * @var string|null |
||
28 | * @JMS\Type("string") |
||
29 | * @JMS\Groups({"update", "create"}) |
||
30 | */ |
||
31 | protected $name; |
||
32 | |||
33 | /** |
||
34 | * @var string|null |
||
35 | * @JMS\Type("string") |
||
36 | * @JMS\Groups({"update", "create"}) |
||
37 | */ |
||
38 | protected $type; |
||
39 | |||
40 | /** |
||
41 | * @var string|null |
||
42 | * @JMS\Type("string") |
||
43 | * @JMS\Groups({"update", "create"}) |
||
44 | */ |
||
45 | protected $parentId; |
||
46 | |||
47 | /** |
||
48 | * @var string|null |
||
49 | * @JMS\Type("string") |
||
50 | * @JMS\Groups({"update", "create"}) |
||
51 | */ |
||
52 | protected $phone; |
||
53 | |||
54 | /** |
||
55 | * @var string|null |
||
56 | * @JMS\Type("string") |
||
57 | * @JMS\Groups({"update", "create"}) |
||
58 | */ |
||
59 | protected $fax; |
||
60 | |||
61 | /** |
||
62 | * @var string|null |
||
63 | * @JMS\Type("string") |
||
64 | * @JMS\Groups({"update", "create"}) |
||
65 | */ |
||
66 | protected $accountNumber; |
||
67 | |||
68 | /** |
||
69 | * @var string|null |
||
70 | * @JMS\Type("string") |
||
71 | * @JMS\Groups({"update", "create"}) |
||
72 | */ |
||
73 | protected $website; |
||
74 | |||
75 | /** |
||
76 | * @var string|null |
||
77 | * @JMS\Type("string") |
||
78 | */ |
||
79 | protected $photoUrl; |
||
80 | |||
81 | /** |
||
82 | * @var string|null |
||
83 | * @JMS\Type("string") |
||
84 | * @JMS\Groups({"update", "create"}) |
||
85 | */ |
||
86 | protected $sic; |
||
87 | |||
88 | /** |
||
89 | * @var string|null |
||
90 | * @JMS\Type("string") |
||
91 | * @JMS\Groups({"update", "create"}) |
||
92 | */ |
||
93 | protected $industry; |
||
94 | |||
95 | /** |
||
96 | * @var string|null |
||
97 | * @JMS\Type("string") |
||
98 | * @JMS\Groups({"update", "create"}) |
||
99 | */ |
||
100 | protected $annualRevenue; |
||
101 | |||
102 | /** |
||
103 | * @var int|null |
||
104 | * @JMS\Type("int") |
||
105 | * @JMS\Groups({"update", "create"}) |
||
106 | */ |
||
107 | protected $numberOfEmployees; |
||
108 | |||
109 | /** |
||
110 | * @var string|null |
||
111 | * @JMS\Type("string") |
||
112 | * @JMS\Groups({"update", "create"}) |
||
113 | */ |
||
114 | protected $ownership; |
||
115 | |||
116 | /** |
||
117 | * @var string|null |
||
118 | * @JMS\Type("string") |
||
119 | * @JMS\Groups({"update", "create"}) |
||
120 | */ |
||
121 | protected $tickerSymbol; |
||
122 | |||
123 | /** |
||
124 | * @var string|null |
||
125 | * @JMS\Type("string") |
||
126 | * @JMS\Groups({"update", "create"}) |
||
127 | */ |
||
128 | protected $description; |
||
129 | |||
130 | /** |
||
131 | * @var string|null |
||
132 | * @JMS\Type("string") |
||
133 | * @JMS\Groups({"update", "create"}) |
||
134 | */ |
||
135 | protected $rating; |
||
136 | |||
137 | /** |
||
138 | * @var string|null |
||
139 | * @JMS\Type("string") |
||
140 | * @JMS\Groups({"update", "create"}) |
||
141 | */ |
||
142 | protected $site; |
||
143 | |||
144 | /** |
||
145 | * @var string|null |
||
146 | * @JMS\Type("string") |
||
147 | * @JMS\Groups({"update", "create"}) |
||
148 | */ |
||
149 | protected $ownerId; |
||
150 | |||
151 | /** |
||
152 | * @var \DateTimeInterface|null |
||
153 | * @JMS\Type("DateTime<'Y-m-d\TH:i:s.\0\0\0O'>") |
||
154 | */ |
||
155 | protected $lastActivityDate; |
||
156 | |||
157 | /** |
||
158 | * @var \DateTimeInterface|null |
||
159 | * @JMS\Type("DateTime<'Y-m-d\TH:i:s.\0\0\0O'>") |
||
160 | */ |
||
161 | protected $lastViewedDate; |
||
162 | |||
163 | /** |
||
164 | * @var \DateTimeInterface|null |
||
165 | * @JMS\Type("DateTime<'Y-m-d\TH:i:s.\0\0\0O'>") |
||
166 | */ |
||
167 | protected $lastReferencedDate; |
||
168 | |||
169 | /** |
||
170 | * @var string|null |
||
171 | * @JMS\Type("string") |
||
172 | */ |
||
173 | protected $jigsaw; |
||
174 | |||
175 | /** |
||
176 | * @var string|null |
||
177 | * @JMS\Type("string") |
||
178 | */ |
||
179 | protected $jigsawCompanyId; |
||
180 | |||
181 | /** |
||
182 | * @var string|null |
||
183 | * @JMS\Type("string") |
||
184 | * @JMS\Groups({"update", "create"}) |
||
185 | */ |
||
186 | protected $cleanStatus; |
||
187 | |||
188 | /** |
||
189 | * @var string|null |
||
190 | * @JMS\Type("string") |
||
191 | * @JMS\Groups({"update", "create"}) |
||
192 | */ |
||
193 | protected $accountSource; |
||
194 | |||
195 | /** |
||
196 | * @var string|null |
||
197 | * @JMS\Type("string") |
||
198 | */ |
||
199 | protected $dunsNumber; |
||
200 | |||
201 | /** |
||
202 | * @var string|null |
||
203 | * @JMS\Type("string") |
||
204 | * @JMS\Groups({"update", "create"}) |
||
205 | */ |
||
206 | protected $tradestyle; |
||
207 | |||
208 | /** |
||
209 | * @var string|null |
||
210 | * @JMS\Type("string") |
||
211 | * @JMS\Groups({"update", "create"}) |
||
212 | */ |
||
213 | protected $naicsCode; |
||
214 | |||
215 | /** |
||
216 | * @var string|null |
||
217 | * @JMS\Type("string") |
||
218 | * @JMS\Groups({"update", "create"}) |
||
219 | */ |
||
220 | protected $naicsDesc; |
||
221 | |||
222 | /** |
||
223 | * @var string|null |
||
224 | * @JMS\Type("string") |
||
225 | * @JMS\Groups({"update", "create"}) |
||
226 | */ |
||
227 | protected $yearStarted; |
||
228 | |||
229 | /** |
||
230 | * @var string|null |
||
231 | * @JMS\Type("string") |
||
232 | * @JMS\Groups({"update", "create"}) |
||
233 | */ |
||
234 | protected $sicDesc; |
||
235 | |||
236 | /** |
||
237 | * @var string|null |
||
238 | * @JMS\Type("string") |
||
239 | * @JMS\Groups({"update", "create"}) |
||
240 | */ |
||
241 | protected $dandbCompanyId; |
||
242 | |||
243 | /** |
||
244 | * {@inheritdoc} |
||
245 | */ |
||
246 | public static function getSObjectName(): AbstractSObjectType |
||
247 | { |
||
248 | return SObjectType::ACCOUNT(); |
||
249 | } |
||
250 | |||
251 | /** |
||
252 | * @return bool|null |
||
253 | */ |
||
254 | public function isDeleted() |
||
255 | { |
||
256 | return $this->isDeleted; |
||
257 | } |
||
258 | |||
259 | /** |
||
260 | * @return string|null |
||
261 | */ |
||
262 | public function getMasterRecordId() |
||
263 | { |
||
264 | return $this->masterRecordId; |
||
265 | } |
||
266 | |||
267 | /** |
||
268 | * @return string|null |
||
269 | */ |
||
270 | public function getName() |
||
271 | { |
||
272 | return $this->name; |
||
273 | } |
||
274 | |||
275 | /** |
||
276 | * @return string|null |
||
277 | */ |
||
278 | public function getType() |
||
279 | { |
||
280 | return $this->type; |
||
281 | } |
||
282 | |||
283 | /** |
||
284 | * @return string|null |
||
285 | */ |
||
286 | public function getParentId() |
||
287 | { |
||
288 | return $this->parentId; |
||
289 | } |
||
290 | |||
291 | /** |
||
292 | * @return string|null |
||
293 | */ |
||
294 | public function getPhone() |
||
295 | { |
||
296 | return $this->phone; |
||
297 | } |
||
298 | |||
299 | /** |
||
300 | * @return string|null |
||
301 | */ |
||
302 | public function getFax() |
||
303 | { |
||
304 | return $this->fax; |
||
305 | } |
||
306 | |||
307 | /** |
||
308 | * @return string|null |
||
309 | */ |
||
310 | public function getAccountNumber() |
||
311 | { |
||
312 | return $this->accountNumber; |
||
313 | } |
||
314 | |||
315 | /** |
||
316 | * @return string|null |
||
317 | */ |
||
318 | public function getWebsite() |
||
319 | { |
||
320 | return $this->website; |
||
321 | } |
||
322 | |||
323 | /** |
||
324 | * @return string|null |
||
325 | */ |
||
326 | public function getPhotoUrl() |
||
327 | { |
||
328 | return $this->photoUrl; |
||
329 | } |
||
330 | |||
331 | /** |
||
332 | * @return string|null |
||
333 | */ |
||
334 | public function getSic() |
||
335 | { |
||
336 | return $this->sic; |
||
337 | } |
||
338 | |||
339 | /** |
||
340 | * @return string|null |
||
341 | */ |
||
342 | public function getIndustry() |
||
343 | { |
||
344 | return $this->industry; |
||
345 | } |
||
346 | |||
347 | /** |
||
348 | * @return string|null |
||
349 | */ |
||
350 | public function getAnnualRevenue() |
||
351 | { |
||
352 | return $this->annualRevenue; |
||
353 | } |
||
354 | |||
355 | /** |
||
356 | * @return int|null |
||
357 | */ |
||
358 | public function getNumberOfEmployees() |
||
359 | { |
||
360 | return $this->numberOfEmployees; |
||
361 | } |
||
362 | |||
363 | /** |
||
364 | * @return string|null |
||
365 | */ |
||
366 | public function getOwnership() |
||
367 | { |
||
368 | return $this->ownership; |
||
369 | } |
||
370 | |||
371 | /** |
||
372 | * @return string|null |
||
373 | */ |
||
374 | public function getTickerSymbol() |
||
375 | { |
||
376 | return $this->tickerSymbol; |
||
377 | } |
||
378 | |||
379 | /** |
||
380 | * @return string|null |
||
381 | */ |
||
382 | public function getDescription() |
||
383 | { |
||
384 | return $this->description; |
||
385 | } |
||
386 | |||
387 | /** |
||
388 | * @return string|null |
||
389 | */ |
||
390 | public function getRating() |
||
391 | { |
||
392 | return $this->rating; |
||
393 | } |
||
394 | |||
395 | /** |
||
396 | * @return string|null |
||
397 | */ |
||
398 | public function getSite() |
||
399 | { |
||
400 | return $this->site; |
||
401 | } |
||
402 | |||
403 | /** |
||
404 | * @return string|null |
||
405 | */ |
||
406 | public function getOwnerId() |
||
407 | { |
||
408 | return $this->ownerId; |
||
409 | } |
||
410 | |||
411 | /** |
||
412 | * @return \DateTimeInterface|null |
||
413 | */ |
||
414 | public function getLastActivityDate() |
||
415 | { |
||
416 | return $this->lastActivityDate; |
||
417 | } |
||
418 | |||
419 | /** |
||
420 | * @return \DateTimeInterface|null |
||
421 | */ |
||
422 | public function getLastViewedDate() |
||
423 | { |
||
424 | return $this->lastViewedDate; |
||
425 | } |
||
426 | |||
427 | /** |
||
428 | * @return \DateTimeInterface|null |
||
429 | */ |
||
430 | public function getLastReferencedDate() |
||
431 | { |
||
432 | return $this->lastReferencedDate; |
||
433 | } |
||
434 | |||
435 | /** |
||
436 | * @return string|null |
||
437 | */ |
||
438 | public function getJigsaw() |
||
439 | { |
||
440 | return $this->jigsaw; |
||
441 | } |
||
442 | |||
443 | /** |
||
444 | * @return string|null |
||
445 | */ |
||
446 | public function getJigsawCompanyId() |
||
447 | { |
||
448 | return $this->jigsawCompanyId; |
||
449 | } |
||
450 | |||
451 | /** |
||
452 | * @return string|null |
||
453 | */ |
||
454 | public function getCleanStatus() |
||
455 | { |
||
456 | return $this->cleanStatus; |
||
457 | } |
||
458 | |||
459 | /** |
||
460 | * @return string|null |
||
461 | */ |
||
462 | public function getAccountSource() |
||
463 | { |
||
464 | return $this->accountSource; |
||
465 | } |
||
466 | |||
467 | /** |
||
468 | * @return string|null |
||
469 | */ |
||
470 | public function getDunsNumber() |
||
471 | { |
||
472 | return $this->dunsNumber; |
||
473 | } |
||
474 | |||
475 | /** |
||
476 | * @return string|null |
||
477 | */ |
||
478 | public function getTradestyle() |
||
479 | { |
||
480 | return $this->tradestyle; |
||
481 | } |
||
482 | |||
483 | /** |
||
484 | * @return string|null |
||
485 | */ |
||
486 | public function getNaicsCode() |
||
487 | { |
||
488 | return $this->naicsCode; |
||
489 | } |
||
490 | |||
491 | /** |
||
492 | * @return string|null |
||
493 | */ |
||
494 | public function getNaicsDesc() |
||
495 | { |
||
496 | return $this->naicsDesc; |
||
497 | } |
||
498 | |||
499 | /** |
||
500 | * @return string|null |
||
501 | */ |
||
502 | public function getYearStarted() |
||
503 | { |
||
504 | return $this->yearStarted; |
||
505 | } |
||
506 | |||
507 | /** |
||
508 | * @return string|null |
||
509 | */ |
||
510 | public function getSicDesc() |
||
511 | { |
||
512 | return $this->sicDesc; |
||
513 | } |
||
514 | |||
515 | /** |
||
516 | * @return string|null |
||
517 | */ |
||
518 | public function getDandbCompanyId() |
||
521 | } |
||
522 | |||
523 | public function setName(string $name): self |
||
524 | { |
||
525 | $this->name = $name; |
||
526 | |||
527 | return $this; |
||
528 | } |
||
529 | |||
530 | public function setType(string $type = null): self |
||
531 | { |
||
532 | $this->type = $type; |
||
533 | |||
534 | return $this; |
||
535 | } |
||
536 | |||
537 | public function setParentId(string $parentId = null): self |
||
538 | { |
||
539 | $this->parentId = $parentId; |
||
540 | |||
541 | return $this; |
||
542 | } |
||
543 | |||
544 | public function setPhone(string $phone = null): self |
||
545 | { |
||
546 | $this->phone = $phone; |
||
547 | |||
548 | return $this; |
||
549 | } |
||
550 | |||
551 | public function setFax(string $fax = null): self |
||
552 | { |
||
553 | $this->fax = $fax; |
||
554 | |||
555 | return $this; |
||
556 | } |
||
557 | |||
558 | public function setAccountNumber(string $accountNumber = null): self |
||
559 | { |
||
560 | $this->accountNumber = $accountNumber; |
||
561 | |||
562 | return $this; |
||
563 | } |
||
564 | |||
565 | public function setWebsite(string $website = null): self |
||
566 | { |
||
567 | $this->website = $website; |
||
568 | |||
569 | return $this; |
||
570 | } |
||
571 | |||
572 | public function setSic(string $sic = null): self |
||
577 | } |
||
578 | |||
579 | public function setIndustry(string $industry = null): self |
||
580 | { |
||
581 | $this->industry = $industry; |
||
582 | |||
583 | return $this; |
||
584 | } |
||
585 | |||
586 | public function setAnnualRevenue(string $annualRevenue = null): self |
||
587 | { |
||
588 | $this->annualRevenue = $annualRevenue; |
||
589 | |||
590 | return $this; |
||
591 | } |
||
592 | |||
593 | public function setNumberOfEmployees(int $numberOfEmployees = null): self |
||
594 | { |
||
595 | $this->numberOfEmployees = $numberOfEmployees; |
||
596 | |||
597 | return $this; |
||
598 | } |
||
599 | |||
600 | public function setOwnership(string $ownership = null): self |
||
601 | { |
||
602 | $this->ownership = $ownership; |
||
603 | |||
604 | return $this; |
||
605 | } |
||
606 | |||
607 | public function setTickerSymbol(string $tickerSymbol = null): self |
||
608 | { |
||
609 | $this->tickerSymbol = $tickerSymbol; |
||
610 | |||
611 | return $this; |
||
612 | } |
||
613 | |||
614 | public function setDescription(string $description = null): self |
||
615 | { |
||
616 | $this->description = $description; |
||
617 | |||
618 | return $this; |
||
619 | } |
||
620 | |||
621 | public function setRating(string $rating = null): self |
||
622 | { |
||
623 | $this->rating = $rating; |
||
624 | |||
625 | return $this; |
||
626 | } |
||
627 | |||
628 | public function setSite(string $site = null): self |
||
629 | { |
||
630 | $this->site = $site; |
||
631 | |||
632 | return $this; |
||
633 | } |
||
634 | |||
635 | public function setOwnerId(string $ownerId): self |
||
636 | { |
||
637 | $this->ownerId = $ownerId; |
||
638 | |||
639 | return $this; |
||
640 | } |
||
641 | |||
642 | public function setLastActivityDate(\DateTimeInterface $lastActivityDate = null): self |
||
643 | { |
||
644 | $this->lastActivityDate = $lastActivityDate; |
||
645 | |||
646 | return $this; |
||
647 | } |
||
648 | |||
649 | public function setLastViewedDate(\DateTimeInterface $lastViewedDate = null): self |
||
650 | { |
||
651 | $this->lastViewedDate = $lastViewedDate; |
||
652 | |||
653 | return $this; |
||
654 | } |
||
655 | |||
656 | public function setLastReferencedDate(\DateTimeInterface $lastReferencedDate = null): self |
||
657 | { |
||
658 | $this->lastReferencedDate = $lastReferencedDate; |
||
659 | |||
660 | return $this; |
||
661 | } |
||
662 | |||
663 | public function setJigsaw(string $jigsaw = null): self |
||
664 | { |
||
665 | $this->jigsaw = $jigsaw; |
||
666 | |||
667 | return $this; |
||
668 | } |
||
669 | |||
670 | public function setJigsawCompanyId(string $jigsawCompanyId = null): self |
||
675 | } |
||
676 | |||
677 | public function setCleanStatus(string $cleanStatus = null): self |
||
678 | { |
||
679 | $this->cleanStatus = $cleanStatus; |
||
680 | |||
681 | return $this; |
||
682 | } |
||
683 | |||
684 | public function setAccountSource(string $accountSource = null): self |
||
685 | { |
||
686 | $this->accountSource = $accountSource; |
||
687 | |||
688 | return $this; |
||
689 | } |
||
690 | |||
691 | public function setDunsNumber(string $dunsNumber = null): self |
||
692 | { |
||
693 | $this->dunsNumber = $dunsNumber; |
||
694 | |||
695 | return $this; |
||
696 | } |
||
697 | |||
698 | public function setTradestyle(string $tradestyle = null): self |
||
699 | { |
||
700 | $this->tradestyle = $tradestyle; |
||
701 | |||
702 | return $this; |
||
703 | } |
||
704 | |||
705 | public function setNaicsCode(string $naicsCode = null): self |
||
710 | } |
||
711 | |||
712 | public function setNaicsDesc(string $naicsDesc = null): self |
||
717 | } |
||
718 | |||
719 | public function setYearStarted(string $yearStarted = null): self |
||
720 | { |
||
721 | $this->yearStarted = $yearStarted; |
||
722 | |||
723 | return $this; |
||
724 | } |
||
725 | |||
726 | public function setSicDesc(string $sicDesc = null): self |
||
731 | } |
||
732 | |||
733 | public function setDandbCompanyId(string $dandbCompanyId = null): self |
||
734 | { |
||
735 | $this->dandbCompanyId = $dandbCompanyId; |
||
736 | |||
737 | return $this; |
||
738 | } |
||
739 | } |
||
740 |