Total Complexity | 68 |
Total Lines | 823 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like Lead 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 Lead, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
10 | class Lead extends AbstractSObject |
||
11 | { |
||
12 | /** |
||
13 | * @var bool |
||
14 | * @JMS\Type("boolean") |
||
15 | */ |
||
16 | protected $isDeleted; |
||
17 | |||
18 | /** |
||
19 | * @var string|null |
||
20 | * @JMS\Type("string") |
||
21 | */ |
||
22 | protected $masterRecordId; |
||
23 | |||
24 | /** |
||
25 | * @var string|null |
||
26 | * @JMS\Type("string") |
||
27 | * @JMS\Groups({"update", "create"}) |
||
28 | */ |
||
29 | protected $lastName; |
||
30 | |||
31 | /** |
||
32 | * @var string|null |
||
33 | * @JMS\Type("string") |
||
34 | * @JMS\Groups({"update", "create"}) |
||
35 | */ |
||
36 | protected $firstName; |
||
37 | |||
38 | /** |
||
39 | * @var string|null |
||
40 | * @JMS\Type("string") |
||
41 | * @JMS\Groups({"update", "create"}) |
||
42 | */ |
||
43 | protected $salutation; |
||
44 | |||
45 | /** |
||
46 | * @var string|null |
||
47 | * @JMS\Type("string") |
||
48 | */ |
||
49 | protected $name; |
||
50 | |||
51 | /** |
||
52 | * @var string|null |
||
53 | * @JMS\Type("string") |
||
54 | * @JMS\Groups({"update", "create"}) |
||
55 | */ |
||
56 | protected $company; |
||
57 | |||
58 | /** |
||
59 | * @var string|null |
||
60 | * @JMS\Type("string") |
||
61 | * @JMS\Groups({"update", "create"}) |
||
62 | */ |
||
63 | protected $street; |
||
64 | |||
65 | /** |
||
66 | * @var string|null |
||
67 | * @JMS\Type("string") |
||
68 | * @JMS\Groups({"update", "create"}) |
||
69 | */ |
||
70 | protected $city; |
||
71 | |||
72 | /** |
||
73 | * @var string|null |
||
74 | * @JMS\Type("string") |
||
75 | * @JMS\Groups({"update", "create"}) |
||
76 | */ |
||
77 | protected $state; |
||
78 | |||
79 | /** |
||
80 | * @var string|null |
||
81 | * @JMS\Type("string") |
||
82 | * @JMS\Groups({"update", "create"}) |
||
83 | */ |
||
84 | protected $postalCode; |
||
85 | |||
86 | /** |
||
87 | * @var string|null |
||
88 | * @JMS\Type("string") |
||
89 | * @JMS\Groups({"update", "create"}) |
||
90 | */ |
||
91 | protected $country; |
||
92 | |||
93 | /** |
||
94 | * @var float|null |
||
95 | * @JMS\Type("float") |
||
96 | * @JMS\Groups({"update", "create"}) |
||
97 | */ |
||
98 | protected $latitude; |
||
99 | |||
100 | /** |
||
101 | * @var float|null |
||
102 | * @JMS\Type("float") |
||
103 | * @JMS\Groups({"update", "create"}) |
||
104 | */ |
||
105 | protected $longitude; |
||
106 | |||
107 | /** |
||
108 | * @var string|null |
||
109 | * @JMS\Type("string") |
||
110 | * @JMS\Groups({"update", "create"}) |
||
111 | */ |
||
112 | protected $geocodeAccuracy; |
||
113 | |||
114 | /** |
||
115 | * @var Address|null |
||
116 | * @JMS\Type("Xsolve\SalesforceClient\Model\ValueObject\Address") |
||
117 | */ |
||
118 | protected $address; |
||
119 | |||
120 | /** |
||
121 | * @var string|null |
||
122 | * @JMS\Type("string") |
||
123 | * @JMS\Groups({"update", "create"}) |
||
124 | */ |
||
125 | protected $phone; |
||
126 | |||
127 | /** |
||
128 | * @var string|null |
||
129 | * @JMS\Type("string") |
||
130 | * @JMS\Groups({"update", "create"}) |
||
131 | */ |
||
132 | protected $mobilePhone; |
||
133 | |||
134 | /** |
||
135 | * @var string|null |
||
136 | * @JMS\Type("string") |
||
137 | * @JMS\Groups({"update", "create"}) |
||
138 | */ |
||
139 | protected $fax; |
||
140 | |||
141 | /** |
||
142 | * @var string|null |
||
143 | * @JMS\Type("string") |
||
144 | * @JMS\Groups({"update", "create"}) |
||
145 | */ |
||
146 | protected $email; |
||
147 | |||
148 | /** |
||
149 | * @var string|null |
||
150 | * @JMS\Type("string") |
||
151 | * @JMS\Groups({"update", "create"}) |
||
152 | */ |
||
153 | protected $website; |
||
154 | |||
155 | /** |
||
156 | * @var string|null |
||
157 | * @JMS\Type("string") |
||
158 | */ |
||
159 | protected $photoUrl; |
||
160 | |||
161 | /** |
||
162 | * @var string|null |
||
163 | * @JMS\Type("string") |
||
164 | * @JMS\Groups({"update", "create"}) |
||
165 | */ |
||
166 | protected $description; |
||
167 | |||
168 | /** |
||
169 | * @var string|null |
||
170 | * @JMS\Type("string") |
||
171 | * @JMS\Groups({"update", "create"}) |
||
172 | */ |
||
173 | protected $leadSource; |
||
174 | |||
175 | /** |
||
176 | * @var string|null |
||
177 | * @JMS\Type("string") |
||
178 | * @JMS\Groups({"update", "create"}) |
||
179 | */ |
||
180 | protected $status; |
||
181 | |||
182 | /** |
||
183 | * @var string|null |
||
184 | * @JMS\Type("string") |
||
185 | * @JMS\Groups({"update", "create"}) |
||
186 | */ |
||
187 | protected $industry; |
||
188 | |||
189 | /** |
||
190 | * @var string|null |
||
191 | * @JMS\Type("string") |
||
192 | * @JMS\Groups({"update", "create"}) |
||
193 | */ |
||
194 | protected $rating; |
||
195 | |||
196 | /** |
||
197 | * @var float|null |
||
198 | * @JMS\Type("float") |
||
199 | * @JMS\Groups({"update", "create"}) |
||
200 | */ |
||
201 | protected $annualRevenue; |
||
202 | |||
203 | /** |
||
204 | * @var int|null |
||
205 | * @JMS\Type("int") |
||
206 | * @JMS\Groups({"update", "create"}) |
||
207 | */ |
||
208 | protected $numberOfEmployees; |
||
209 | |||
210 | /** |
||
211 | * @var string|null |
||
212 | * @JMS\Type("string") |
||
213 | * @JMS\Groups({"update", "create"}) |
||
214 | */ |
||
215 | protected $ownerId; |
||
216 | |||
217 | /** |
||
218 | * @var bool|null |
||
219 | * @JMS\Type("boolean") |
||
220 | */ |
||
221 | protected $isConverted; |
||
222 | |||
223 | /** |
||
224 | * @var \DateTime|null |
||
225 | * @JMS\Type("DateTime<'Y-m-d\TH:i:s.\0\0\0O'>") |
||
226 | */ |
||
227 | protected $convertedDate; |
||
228 | |||
229 | /** |
||
230 | * @var string|null |
||
231 | * @JMS\Type("string") |
||
232 | */ |
||
233 | protected $convertedAccountId; |
||
234 | |||
235 | /** |
||
236 | * @var string|null |
||
237 | * @JMS\Type("string") |
||
238 | */ |
||
239 | protected $convertedContactId; |
||
240 | |||
241 | /** |
||
242 | * @var string|null |
||
243 | * @JMS\Type("string") |
||
244 | */ |
||
245 | protected $convertedOpportunityId; |
||
246 | |||
247 | /** |
||
248 | * @var bool |
||
249 | * @JMS\Type("boolean") |
||
250 | * @JMS\Groups({"update", "create"}) |
||
251 | */ |
||
252 | protected $isUnreadByOwner; |
||
253 | |||
254 | /** |
||
255 | * @var \DateTimeInterface|null |
||
256 | * @JMS\Type("DateTime<'Y-m-d\TH:i:s.\0\0\0O'>") |
||
257 | */ |
||
258 | protected $lastViewedDate; |
||
259 | |||
260 | /** |
||
261 | * @var \DateTimeInterface|null |
||
262 | * @JMS\Type("DateTime<'Y-m-d\TH:i:s.\0\0\0O'>") |
||
263 | */ |
||
264 | protected $lastReferencedDate; |
||
265 | |||
266 | /** |
||
267 | * @var string|null |
||
268 | * @JMS\Type("string") |
||
269 | * @JMS\Groups({"update", "create"}) |
||
270 | */ |
||
271 | protected $jigsaw; |
||
272 | |||
273 | /** |
||
274 | * @var string|null |
||
275 | * @JMS\Type("string") |
||
276 | */ |
||
277 | protected $jigsawContactId; |
||
278 | |||
279 | /** |
||
280 | * @var string|null |
||
281 | * @JMS\Type("string") |
||
282 | * @JMS\Groups({"update", "create"}) |
||
283 | */ |
||
284 | protected $cleanStatus; |
||
285 | |||
286 | /** |
||
287 | * @var string|null |
||
288 | * @JMS\Type("string") |
||
289 | * @JMS\Groups({"update", "create"}) |
||
290 | */ |
||
291 | protected $companyDunsNumber; |
||
292 | |||
293 | /** |
||
294 | * @var string|null |
||
295 | * @JMS\Type("string") |
||
296 | * @JMS\Groups({"update", "create"}) |
||
297 | */ |
||
298 | protected $dandbCompanyId; |
||
299 | |||
300 | /** |
||
301 | * @var string|null |
||
302 | * @JMS\Type("string") |
||
303 | * @JMS\Groups({"update", "create"}) |
||
304 | */ |
||
305 | protected $emailBouncedReason; |
||
306 | |||
307 | /** |
||
308 | * @var \DateTimeInterface|null |
||
309 | * @JMS\Type("DateTime<'Y-m-d\TH:i:s.\0\0\0O'>") |
||
310 | * @JMS\Groups({"update", "create"}) |
||
311 | */ |
||
312 | protected $emailBouncedDate; |
||
313 | |||
314 | /** |
||
315 | * {@inheritdoc} |
||
316 | */ |
||
317 | public static function getSObjectName(): AbstractSObjectType |
||
318 | { |
||
319 | return SObjectType::LEAD(); |
||
320 | } |
||
321 | |||
322 | /** |
||
323 | * @return bool |
||
324 | */ |
||
325 | public function isDeleted() |
||
326 | { |
||
327 | return $this->isDeleted; |
||
328 | } |
||
329 | |||
330 | /** |
||
331 | * @return string|null |
||
332 | */ |
||
333 | public function getMasterRecordId() |
||
334 | { |
||
335 | return $this->masterRecordId; |
||
336 | } |
||
337 | |||
338 | /** |
||
339 | * @return string|null |
||
340 | */ |
||
341 | public function getLastName() |
||
342 | { |
||
343 | return $this->lastName; |
||
344 | } |
||
345 | |||
346 | /** |
||
347 | * @return string|null |
||
348 | */ |
||
349 | public function getFirstName() |
||
350 | { |
||
351 | return $this->firstName; |
||
352 | } |
||
353 | |||
354 | /** |
||
355 | * @return string|null |
||
356 | */ |
||
357 | public function getSalutation() |
||
358 | { |
||
359 | return $this->salutation; |
||
360 | } |
||
361 | |||
362 | /** |
||
363 | * @return string|null |
||
364 | */ |
||
365 | public function getName() |
||
366 | { |
||
367 | return $this->name; |
||
368 | } |
||
369 | |||
370 | /** |
||
371 | * @return string|null |
||
372 | */ |
||
373 | public function getCompany() |
||
374 | { |
||
375 | return $this->company; |
||
376 | } |
||
377 | |||
378 | /** |
||
379 | * @return string|null |
||
380 | */ |
||
381 | public function getGeocodeAccuracy() |
||
382 | { |
||
383 | return $this->geocodeAccuracy; |
||
384 | } |
||
385 | |||
386 | /** |
||
387 | * @return Address|null |
||
388 | */ |
||
389 | public function getAddress() |
||
392 | } |
||
393 | |||
394 | /** |
||
395 | * @return string|null |
||
396 | */ |
||
397 | public function getPhone() |
||
398 | { |
||
399 | return $this->phone; |
||
400 | } |
||
401 | |||
402 | /** |
||
403 | * @return string|null |
||
404 | */ |
||
405 | public function getMobilePhone() |
||
406 | { |
||
407 | return $this->mobilePhone; |
||
408 | } |
||
409 | |||
410 | /** |
||
411 | * @return string|null |
||
412 | */ |
||
413 | public function getFax() |
||
414 | { |
||
415 | return $this->fax; |
||
416 | } |
||
417 | |||
418 | /** |
||
419 | * @return string|null |
||
420 | */ |
||
421 | public function getEmail() |
||
422 | { |
||
423 | return $this->email; |
||
424 | } |
||
425 | |||
426 | /** |
||
427 | * @return string|null |
||
428 | */ |
||
429 | public function getWebsite() |
||
430 | { |
||
431 | return $this->website; |
||
432 | } |
||
433 | |||
434 | /** |
||
435 | * @return string|null |
||
436 | */ |
||
437 | public function getPhotoUrl() |
||
438 | { |
||
439 | return $this->photoUrl; |
||
440 | } |
||
441 | |||
442 | /** |
||
443 | * @return string|null |
||
444 | */ |
||
445 | public function getDescription() |
||
446 | { |
||
447 | return $this->description; |
||
448 | } |
||
449 | |||
450 | /** |
||
451 | * @return string|null |
||
452 | */ |
||
453 | public function getLeadSource() |
||
454 | { |
||
455 | return $this->leadSource; |
||
456 | } |
||
457 | |||
458 | /** |
||
459 | * @return string|null |
||
460 | */ |
||
461 | public function getStatus() |
||
462 | { |
||
463 | return $this->status; |
||
464 | } |
||
465 | |||
466 | /** |
||
467 | * @return string|null |
||
468 | */ |
||
469 | public function getIndustry() |
||
470 | { |
||
471 | return $this->industry; |
||
472 | } |
||
473 | |||
474 | /** |
||
475 | * @return string|null |
||
476 | */ |
||
477 | public function getRating() |
||
478 | { |
||
479 | return $this->rating; |
||
480 | } |
||
481 | |||
482 | /** |
||
483 | * @return float|null |
||
484 | */ |
||
485 | public function getAnnualRevenue() |
||
486 | { |
||
487 | return $this->annualRevenue; |
||
488 | } |
||
489 | |||
490 | /** |
||
491 | * @return int|null |
||
492 | */ |
||
493 | public function getNumberOfEmployees() |
||
494 | { |
||
495 | return $this->numberOfEmployees; |
||
496 | } |
||
497 | |||
498 | /** |
||
499 | * @return string|null |
||
500 | */ |
||
501 | public function getOwnerId() |
||
502 | { |
||
503 | return $this->ownerId; |
||
504 | } |
||
505 | |||
506 | /** |
||
507 | * @return bool|null |
||
508 | */ |
||
509 | public function isConverted() |
||
510 | { |
||
511 | return $this->isConverted; |
||
512 | } |
||
513 | |||
514 | /** |
||
515 | * @return \DateTime|null |
||
516 | */ |
||
517 | public function getConvertedDate() |
||
520 | } |
||
521 | |||
522 | /** |
||
523 | * @return string|null |
||
524 | */ |
||
525 | public function getConvertedAccountId() |
||
526 | { |
||
527 | return $this->convertedAccountId; |
||
528 | } |
||
529 | |||
530 | /** |
||
531 | * @return string|null |
||
532 | */ |
||
533 | public function getConvertedContactId() |
||
534 | { |
||
535 | return $this->convertedContactId; |
||
536 | } |
||
537 | |||
538 | /** |
||
539 | * @return string|null |
||
540 | */ |
||
541 | public function getConvertedOpportunityId() |
||
542 | { |
||
543 | return $this->convertedOpportunityId; |
||
544 | } |
||
545 | |||
546 | /** |
||
547 | * @return bool |
||
548 | */ |
||
549 | public function isUnreadByOwner() |
||
550 | { |
||
551 | return $this->isUnreadByOwner; |
||
552 | } |
||
553 | |||
554 | /** |
||
555 | * @return \DateTimeInterface|null |
||
556 | */ |
||
557 | public function getLastViewedDate() |
||
558 | { |
||
559 | return $this->lastViewedDate; |
||
560 | } |
||
561 | |||
562 | /** |
||
563 | * @return \DateTimeInterface|null |
||
564 | */ |
||
565 | public function getLastReferencedDate() |
||
566 | { |
||
567 | return $this->lastReferencedDate; |
||
568 | } |
||
569 | |||
570 | /** |
||
571 | * @return string|null |
||
572 | */ |
||
573 | public function getJigsaw() |
||
574 | { |
||
575 | return $this->jigsaw; |
||
576 | } |
||
577 | |||
578 | /** |
||
579 | * @return string|null |
||
580 | */ |
||
581 | public function getJigsawContactId() |
||
582 | { |
||
583 | return $this->jigsawContactId; |
||
584 | } |
||
585 | |||
586 | /** |
||
587 | * @return string|null |
||
588 | */ |
||
589 | public function getCleanStatus() |
||
590 | { |
||
591 | return $this->cleanStatus; |
||
592 | } |
||
593 | |||
594 | /** |
||
595 | * @return string|null |
||
596 | */ |
||
597 | public function getCompanyDunsNumber() |
||
600 | } |
||
601 | |||
602 | /** |
||
603 | * @return string|null |
||
604 | */ |
||
605 | public function getDandbCompanyId() |
||
606 | { |
||
607 | return $this->dandbCompanyId; |
||
608 | } |
||
609 | |||
610 | /** |
||
611 | * @return string|null |
||
612 | */ |
||
613 | public function getEmailBouncedReason() |
||
616 | } |
||
617 | |||
618 | /** |
||
619 | * @return \DateTimeInterface|null |
||
620 | */ |
||
621 | public function getEmailBouncedDate() |
||
622 | { |
||
623 | return $this->emailBouncedDate; |
||
624 | } |
||
625 | |||
626 | public function setLastName(string $lastName): self |
||
627 | { |
||
628 | $this->lastName = $lastName; |
||
629 | |||
630 | return $this; |
||
631 | } |
||
632 | |||
633 | public function setFirstName(string $firstName = null): self |
||
634 | { |
||
635 | $this->firstName = $firstName; |
||
636 | |||
637 | return $this; |
||
638 | } |
||
639 | |||
640 | public function setSalutation(string $salutation = null): self |
||
641 | { |
||
642 | $this->salutation = $salutation; |
||
643 | |||
644 | return $this; |
||
645 | } |
||
646 | |||
647 | public function setCompany(string $company): self |
||
648 | { |
||
649 | $this->company = $company; |
||
650 | |||
651 | return $this; |
||
652 | } |
||
653 | |||
654 | public function setAddress(Address $address): self |
||
655 | { |
||
656 | $this->address = $address; |
||
657 | |||
658 | return $this; |
||
659 | } |
||
660 | |||
661 | public function setPhone(string $phone = null): self |
||
662 | { |
||
663 | $this->phone = $phone; |
||
664 | |||
665 | return $this; |
||
666 | } |
||
667 | |||
668 | public function setMobilePhone(string $mobilePhone = null): self |
||
669 | { |
||
670 | $this->mobilePhone = $mobilePhone; |
||
671 | |||
672 | return $this; |
||
673 | } |
||
674 | |||
675 | public function setFax(string $fax = null): self |
||
676 | { |
||
677 | $this->fax = $fax; |
||
678 | |||
679 | return $this; |
||
680 | } |
||
681 | |||
682 | public function setEmail(string $email = null): self |
||
683 | { |
||
684 | $this->email = $email; |
||
685 | |||
686 | return $this; |
||
687 | } |
||
688 | |||
689 | public function setWebsite(string $website = null): self |
||
690 | { |
||
691 | $this->website = $website; |
||
692 | |||
693 | return $this; |
||
694 | } |
||
695 | |||
696 | public function setDescription(string $description = null): self |
||
697 | { |
||
698 | $this->description = $description; |
||
699 | |||
700 | return $this; |
||
701 | } |
||
702 | |||
703 | public function setLeadSource(string $leadSource = null): self |
||
704 | { |
||
705 | $this->leadSource = $leadSource; |
||
706 | |||
707 | return $this; |
||
708 | } |
||
709 | |||
710 | public function setStatus(string $status): self |
||
711 | { |
||
712 | $this->status = $status; |
||
713 | |||
714 | return $this; |
||
715 | } |
||
716 | |||
717 | public function setIndustry(string $industry = null): self |
||
718 | { |
||
719 | $this->industry = $industry; |
||
720 | |||
721 | return $this; |
||
722 | } |
||
723 | |||
724 | public function setRating(string $rating = null): self |
||
729 | } |
||
730 | |||
731 | public function setAnnualRevenue(float $annualRevenue = null): self |
||
732 | { |
||
733 | $this->annualRevenue = $annualRevenue; |
||
734 | |||
735 | return $this; |
||
736 | } |
||
737 | |||
738 | public function setNumberOfEmployees(int $numberOfEmployees = null): self |
||
739 | { |
||
740 | $this->numberOfEmployees = $numberOfEmployees; |
||
741 | |||
742 | return $this; |
||
743 | } |
||
744 | |||
745 | public function setOwnerId(string $ownerId): self |
||
746 | { |
||
747 | $this->ownerId = $ownerId; |
||
748 | |||
749 | return $this; |
||
750 | } |
||
751 | |||
752 | public function setUnreadByOwner(bool $isUnreadByOwner): self |
||
753 | { |
||
754 | $this->isUnreadByOwner = $isUnreadByOwner; |
||
755 | |||
756 | return $this; |
||
757 | } |
||
758 | |||
759 | public function setLastViewedDate(\DateTimeInterface $lastViewedDate = null): self |
||
760 | { |
||
761 | $this->lastViewedDate = $lastViewedDate; |
||
762 | |||
763 | return $this; |
||
764 | } |
||
765 | |||
766 | public function setLastReferencedDate(\DateTimeInterface $lastReferencedDate = null): self |
||
771 | } |
||
772 | |||
773 | public function setJigsaw(string $jigsaw = null): self |
||
774 | { |
||
778 | } |
||
779 | |||
780 | public function setCleanStatus(string $cleanStatus = null): self |
||
781 | { |
||
782 | $this->cleanStatus = $cleanStatus; |
||
783 | |||
784 | return $this; |
||
785 | } |
||
786 | |||
787 | public function setCompanyDunsNumber(string $companyDunsNumber = null): self |
||
788 | { |
||
789 | $this->companyDunsNumber = $companyDunsNumber; |
||
790 | |||
791 | return $this; |
||
792 | } |
||
793 | |||
794 | public function setDandbCompanyId(string $dandbCompanyId = null): self |
||
795 | { |
||
796 | $this->dandbCompanyId = $dandbCompanyId; |
||
797 | |||
798 | return $this; |
||
799 | } |
||
800 | |||
801 | public function setEmailBouncedReason(string $emailBouncedReason = null): self |
||
802 | { |
||
803 | $this->emailBouncedReason = $emailBouncedReason; |
||
804 | |||
805 | return $this; |
||
806 | } |
||
807 | |||
808 | public function setEmailBouncedDate(\DateTimeInterface $emailBouncedDate = null): self |
||
809 | { |
||
810 | $this->emailBouncedDate = $emailBouncedDate; |
||
811 | |||
812 | return $this; |
||
813 | } |
||
814 | |||
815 | /** |
||
816 | * Because Adrress is not writable. |
||
817 | * |
||
818 | * @JMS\PreSerialize |
||
819 | */ |
||
820 | public function updateAddress() |
||
833 | } |
||
834 | } |
||
835 |