Total Complexity | 60 |
Total Lines | 756 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like Customer 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 Customer, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
16 | class Customer extends AbstractEntity implements CustomerInterface |
||
17 | { |
||
18 | use CustomerTrait; |
||
19 | |||
20 | /** |
||
21 | * @var int |
||
22 | * |
||
23 | * @ORM\Id |
||
24 | * @ORM\GeneratedValue |
||
25 | * @ORM\Column(type="integer") |
||
26 | **/ |
||
27 | protected $id; |
||
28 | |||
29 | /** |
||
30 | * This is the customer id in Dandomain |
||
31 | * |
||
32 | * @var int |
||
33 | * |
||
34 | * @ORM\Column(type="integer", unique=true) |
||
35 | */ |
||
36 | protected $externalId; |
||
37 | |||
38 | /** |
||
39 | * @var string|null |
||
40 | * |
||
41 | * @ORM\Column(nullable=true, type="string") |
||
42 | */ |
||
43 | protected $address; |
||
44 | |||
45 | /** |
||
46 | * @var string|null |
||
47 | * |
||
48 | * @ORM\Column(nullable=true, type="string") |
||
49 | */ |
||
50 | protected $address2; |
||
51 | |||
52 | /** |
||
53 | * @var string|null |
||
54 | * |
||
55 | * @ORM\Column(nullable=true, type="string") |
||
56 | */ |
||
57 | protected $attention; |
||
58 | |||
59 | /** |
||
60 | * @var string|null |
||
61 | * |
||
62 | * @ORM\Column(nullable=true, type="string") |
||
63 | */ |
||
64 | protected $city; |
||
65 | |||
66 | /** |
||
67 | * @var string|null |
||
68 | * |
||
69 | * @ORM\Column(nullable=true, type="string") |
||
70 | */ |
||
71 | protected $country; |
||
72 | |||
73 | /** |
||
74 | * @var int|null |
||
75 | * |
||
76 | * @ORM\Column(nullable=true, type="integer") |
||
77 | */ |
||
78 | protected $countryId; |
||
79 | |||
80 | /** |
||
81 | * @var string|null |
||
82 | * |
||
83 | * @ORM\Column(nullable=true, type="string") |
||
84 | */ |
||
85 | protected $ean; |
||
86 | |||
87 | /** |
||
88 | * @var string|null |
||
89 | * |
||
90 | * @ORM\Column(nullable=true, type="string") |
||
91 | */ |
||
92 | protected $email; |
||
93 | |||
94 | /** |
||
95 | * @var string|null |
||
96 | * |
||
97 | * @ORM\Column(nullable=true, type="string") |
||
98 | */ |
||
99 | protected $fax; |
||
100 | |||
101 | /** |
||
102 | * @var string|null |
||
103 | * |
||
104 | * @ORM\Column(nullable=true, type="string") |
||
105 | */ |
||
106 | protected $name; |
||
107 | |||
108 | /** |
||
109 | * @var string|null |
||
110 | * |
||
111 | * @ORM\Column(nullable=true, type="string") |
||
112 | */ |
||
113 | protected $phone; |
||
114 | |||
115 | /** |
||
116 | * @var string|null |
||
117 | * |
||
118 | * @ORM\Column(nullable=true, type="string") |
||
119 | */ |
||
120 | protected $state; |
||
121 | |||
122 | /** |
||
123 | * @var string|null |
||
124 | * |
||
125 | * @ORM\Column(nullable=true, type="string") |
||
126 | */ |
||
127 | protected $zipCode; |
||
128 | |||
129 | /** |
||
130 | * @var string|null |
||
131 | * |
||
132 | * @ORM\Column(nullable=true, type="string") |
||
133 | */ |
||
134 | protected $cvr; |
||
135 | |||
136 | /** |
||
137 | * @var string|null |
||
138 | * |
||
139 | * @ORM\Column(nullable=true, type="string") |
||
140 | */ |
||
141 | protected $b2bGroupId; |
||
142 | |||
143 | /** |
||
144 | * @var string|null |
||
145 | * |
||
146 | * @ORM\Column(nullable=true, type="text") |
||
147 | */ |
||
148 | protected $comments; |
||
149 | |||
150 | /** |
||
151 | * @var \DateTimeImmutable|null |
||
152 | * |
||
153 | * @ORM\Column(nullable=true, type="datetime_immutable") |
||
154 | */ |
||
155 | protected $createdDate; |
||
156 | |||
157 | /** |
||
158 | * @var string|null |
||
159 | * |
||
160 | * @ORM\Column(nullable=true, type="string") |
||
161 | */ |
||
162 | protected $customerGroupId; |
||
163 | |||
164 | /** |
||
165 | * @var string|null |
||
166 | * |
||
167 | * @ORM\Column(nullable=true, type="string") |
||
168 | */ |
||
169 | protected $customerType; |
||
170 | |||
171 | /** |
||
172 | * @var bool|null |
||
173 | * |
||
174 | * @ORM\Column(nullable=true, type="boolean") |
||
175 | */ |
||
176 | protected $b2b; |
||
177 | |||
178 | /** |
||
179 | * @var \DateTimeImmutable|null |
||
180 | * |
||
181 | * @ORM\Column(nullable=true, type="datetime_immutable") |
||
182 | */ |
||
183 | protected $lastLoginDate; |
||
184 | |||
185 | /** |
||
186 | * @var int|null |
||
187 | * |
||
188 | * @ORM\Column(nullable=true, type="integer") |
||
189 | */ |
||
190 | protected $loginCount; |
||
191 | |||
192 | /** |
||
193 | * @var string|null |
||
194 | * |
||
195 | * @ORM\Column(nullable=true, type="string") |
||
196 | */ |
||
197 | protected $password; |
||
198 | |||
199 | /** |
||
200 | * @var string|null |
||
201 | * |
||
202 | * @ORM\Column(nullable=true, type="string") |
||
203 | */ |
||
204 | protected $reservedField1; |
||
205 | |||
206 | /** |
||
207 | * @var string|null |
||
208 | * |
||
209 | * @ORM\Column(nullable=true, type="string") |
||
210 | */ |
||
211 | protected $reservedField2; |
||
212 | |||
213 | /** |
||
214 | * @var string|null |
||
215 | * |
||
216 | * @ORM\Column(nullable=true, type="string") |
||
217 | */ |
||
218 | protected $reservedField3; |
||
219 | |||
220 | /** |
||
221 | * @var string|null |
||
222 | * |
||
223 | * @ORM\Column(nullable=true, type="string") |
||
224 | */ |
||
225 | protected $reservedField4; |
||
226 | |||
227 | /** |
||
228 | * @var string|null |
||
229 | * |
||
230 | * @ORM\Column(nullable=true, type="string") |
||
231 | */ |
||
232 | protected $reservedField5; |
||
233 | |||
234 | /** |
||
235 | * @return int |
||
236 | */ |
||
237 | public function getId(): int |
||
238 | { |
||
239 | return (int)$this->id; |
||
240 | } |
||
241 | |||
242 | /** |
||
243 | * @param int $id |
||
244 | * @return CustomerInterface |
||
245 | */ |
||
246 | public function setId($id) |
||
247 | { |
||
248 | $this->id = $id; |
||
249 | return $this; |
||
250 | } |
||
251 | |||
252 | /** |
||
253 | * @return int |
||
254 | */ |
||
255 | public function getExternalId(): int |
||
256 | { |
||
257 | return (int)$this->externalId; |
||
258 | } |
||
259 | |||
260 | /** |
||
261 | * @param int $externalId |
||
262 | * @return CustomerInterface |
||
263 | */ |
||
264 | public function setExternalId($externalId) |
||
265 | { |
||
266 | $this->externalId = $externalId; |
||
267 | return $this; |
||
268 | } |
||
269 | |||
270 | /** |
||
271 | * @return null|string |
||
272 | */ |
||
273 | public function getAddress() |
||
274 | { |
||
275 | return $this->address; |
||
276 | } |
||
277 | |||
278 | /** |
||
279 | * @param null|string $address |
||
280 | * @return CustomerInterface |
||
281 | */ |
||
282 | public function setAddress($address) |
||
283 | { |
||
284 | $this->address = $address; |
||
285 | return $this; |
||
286 | } |
||
287 | |||
288 | /** |
||
289 | * @return null|string |
||
290 | */ |
||
291 | public function getAddress2() |
||
292 | { |
||
293 | return $this->address2; |
||
294 | } |
||
295 | |||
296 | /** |
||
297 | * @param null|string $address2 |
||
298 | * @return CustomerInterface |
||
299 | */ |
||
300 | public function setAddress2($address2) |
||
301 | { |
||
302 | $this->address2 = $address2; |
||
303 | return $this; |
||
304 | } |
||
305 | |||
306 | /** |
||
307 | * @return null|string |
||
308 | */ |
||
309 | public function getAttention() |
||
310 | { |
||
311 | return $this->attention; |
||
312 | } |
||
313 | |||
314 | /** |
||
315 | * @param null|string $attention |
||
316 | * @return CustomerInterface |
||
317 | */ |
||
318 | public function setAttention($attention) |
||
319 | { |
||
320 | $this->attention = $attention; |
||
321 | return $this; |
||
322 | } |
||
323 | |||
324 | /** |
||
325 | * @return null|string |
||
326 | */ |
||
327 | public function getCity() |
||
328 | { |
||
329 | return $this->city; |
||
330 | } |
||
331 | |||
332 | /** |
||
333 | * @param null|string $city |
||
334 | * @return CustomerInterface |
||
335 | */ |
||
336 | public function setCity($city) |
||
337 | { |
||
338 | $this->city = $city; |
||
339 | return $this; |
||
340 | } |
||
341 | |||
342 | /** |
||
343 | * @return null|string |
||
344 | */ |
||
345 | public function getCountry() |
||
346 | { |
||
347 | return $this->country; |
||
348 | } |
||
349 | |||
350 | /** |
||
351 | * @param null|string $country |
||
352 | * @return CustomerInterface |
||
353 | */ |
||
354 | public function setCountry($country) |
||
355 | { |
||
356 | $this->country = $country; |
||
357 | return $this; |
||
358 | } |
||
359 | |||
360 | /** |
||
361 | * @return null|string |
||
362 | */ |
||
363 | public function getEan() |
||
364 | { |
||
365 | return $this->ean; |
||
366 | } |
||
367 | |||
368 | /** |
||
369 | * @param null|string $ean |
||
370 | * @return CustomerInterface |
||
371 | */ |
||
372 | public function setEan($ean) |
||
373 | { |
||
374 | $this->ean = $ean; |
||
375 | return $this; |
||
376 | } |
||
377 | |||
378 | /** |
||
379 | * @return null|string |
||
380 | */ |
||
381 | public function getEmail() |
||
382 | { |
||
383 | return $this->email; |
||
384 | } |
||
385 | |||
386 | /** |
||
387 | * @param null|string $email |
||
388 | * @return CustomerInterface |
||
389 | */ |
||
390 | public function setEmail($email) |
||
391 | { |
||
392 | $this->email = $email; |
||
393 | return $this; |
||
394 | } |
||
395 | |||
396 | /** |
||
397 | * @return null|string |
||
398 | */ |
||
399 | public function getFax() |
||
400 | { |
||
401 | return $this->fax; |
||
402 | } |
||
403 | |||
404 | /** |
||
405 | * @param null|string $fax |
||
406 | * @return CustomerInterface |
||
407 | */ |
||
408 | public function setFax($fax) |
||
409 | { |
||
410 | $this->fax = $fax; |
||
411 | return $this; |
||
412 | } |
||
413 | |||
414 | /** |
||
415 | * @return null|string |
||
416 | */ |
||
417 | public function getName() |
||
418 | { |
||
419 | return $this->name; |
||
420 | } |
||
421 | |||
422 | /** |
||
423 | * @param null|string $name |
||
424 | * @return CustomerInterface |
||
425 | */ |
||
426 | public function setName($name) |
||
427 | { |
||
428 | $this->name = $name; |
||
429 | return $this; |
||
430 | } |
||
431 | |||
432 | /** |
||
433 | * @return null|string |
||
434 | */ |
||
435 | public function getPhone() |
||
436 | { |
||
437 | return $this->phone; |
||
438 | } |
||
439 | |||
440 | /** |
||
441 | * @param null|string $phone |
||
442 | * @return CustomerInterface |
||
443 | */ |
||
444 | public function setPhone($phone) |
||
445 | { |
||
446 | $this->phone = $phone; |
||
447 | return $this; |
||
448 | } |
||
449 | |||
450 | /** |
||
451 | * @return null|string |
||
452 | */ |
||
453 | public function getState() |
||
454 | { |
||
455 | return $this->state; |
||
456 | } |
||
457 | |||
458 | /** |
||
459 | * @param null|string $state |
||
460 | * @return CustomerInterface |
||
461 | */ |
||
462 | public function setState($state) |
||
463 | { |
||
464 | $this->state = $state; |
||
465 | return $this; |
||
466 | } |
||
467 | |||
468 | /** |
||
469 | * @return null|string |
||
470 | */ |
||
471 | public function getZipCode() |
||
472 | { |
||
473 | return $this->zipCode; |
||
474 | } |
||
475 | |||
476 | /** |
||
477 | * @param null|string $zipCode |
||
478 | * @return CustomerInterface |
||
479 | */ |
||
480 | public function setZipCode($zipCode) |
||
481 | { |
||
482 | $this->zipCode = $zipCode; |
||
483 | return $this; |
||
484 | } |
||
485 | |||
486 | /** |
||
487 | * @return null|string |
||
488 | */ |
||
489 | public function getCvr() |
||
490 | { |
||
491 | return $this->cvr; |
||
492 | } |
||
493 | |||
494 | /** |
||
495 | * @param null|string $cvr |
||
496 | * @return CustomerInterface |
||
497 | */ |
||
498 | public function setCvr($cvr) |
||
499 | { |
||
500 | $this->cvr = $cvr; |
||
501 | return $this; |
||
502 | } |
||
503 | |||
504 | /** |
||
505 | * @return null|string |
||
506 | */ |
||
507 | public function getB2bGroupId() |
||
508 | { |
||
509 | return $this->b2bGroupId; |
||
510 | } |
||
511 | |||
512 | /** |
||
513 | * @param null|string $b2bGroupId |
||
514 | * @return CustomerInterface |
||
515 | */ |
||
516 | public function setB2bGroupId($b2bGroupId) |
||
517 | { |
||
518 | $this->b2bGroupId = $b2bGroupId; |
||
519 | return $this; |
||
520 | } |
||
521 | |||
522 | /** |
||
523 | * @return null|string |
||
524 | */ |
||
525 | public function getComments() |
||
526 | { |
||
527 | return $this->comments; |
||
528 | } |
||
529 | |||
530 | /** |
||
531 | * @param null|string $comments |
||
532 | * @return CustomerInterface |
||
533 | */ |
||
534 | public function setComments($comments) |
||
535 | { |
||
536 | $this->comments = $comments; |
||
537 | return $this; |
||
538 | } |
||
539 | |||
540 | /** |
||
541 | * @return int|null |
||
542 | */ |
||
543 | public function getCountryId() |
||
544 | { |
||
545 | return $this->countryId; |
||
546 | } |
||
547 | |||
548 | /** |
||
549 | * @param int|null $countryId |
||
550 | * @return CustomerInterface |
||
551 | */ |
||
552 | public function setCountryId($countryId) |
||
553 | { |
||
554 | $this->countryId = $countryId; |
||
555 | return $this; |
||
556 | } |
||
557 | |||
558 | /** |
||
559 | * @return \DateTimeImmutable|null |
||
560 | */ |
||
561 | public function getCreatedDate() |
||
562 | { |
||
563 | return $this->createdDate; |
||
564 | } |
||
565 | |||
566 | /** |
||
567 | * @param \DateTimeImmutable|null $createdDate |
||
568 | * @return CustomerInterface |
||
569 | */ |
||
570 | public function setCreatedDate($createdDate) |
||
571 | { |
||
572 | $this->createdDate = $createdDate; |
||
573 | return $this; |
||
574 | } |
||
575 | |||
576 | /** |
||
577 | * @return null|string |
||
578 | */ |
||
579 | public function getCustomerGroupId() |
||
582 | } |
||
583 | |||
584 | /** |
||
585 | * @param null|string $customerGroupId |
||
586 | * @return CustomerInterface |
||
587 | */ |
||
588 | public function setCustomerGroupId($customerGroupId) |
||
592 | } |
||
593 | |||
594 | /** |
||
595 | * @return null|string |
||
596 | */ |
||
597 | public function getCustomerType() |
||
600 | } |
||
601 | |||
602 | /** |
||
603 | * @param null|string $customerType |
||
604 | * @return CustomerInterface |
||
605 | */ |
||
606 | public function setCustomerType($customerType) |
||
607 | { |
||
608 | $this->customerType = $customerType; |
||
609 | return $this; |
||
610 | } |
||
611 | |||
612 | /** |
||
613 | * @return bool|null |
||
614 | */ |
||
615 | public function getB2b() |
||
616 | { |
||
617 | return $this->b2b; |
||
618 | } |
||
619 | |||
620 | /** |
||
621 | * @param bool|null $b2b |
||
622 | * @return CustomerInterface |
||
623 | */ |
||
624 | public function setB2b($b2b) |
||
625 | { |
||
626 | $this->b2b = $b2b; |
||
627 | return $this; |
||
628 | } |
||
629 | |||
630 | /** |
||
631 | * @return \DateTimeImmutable|null |
||
632 | */ |
||
633 | public function getLastLoginDate() |
||
634 | { |
||
635 | return $this->lastLoginDate; |
||
636 | } |
||
637 | |||
638 | /** |
||
639 | * @param \DateTimeImmutable|null $lastLoginDate |
||
640 | * @return CustomerInterface |
||
641 | */ |
||
642 | public function setLastLoginDate($lastLoginDate) |
||
643 | { |
||
644 | $this->lastLoginDate = $lastLoginDate; |
||
645 | return $this; |
||
646 | } |
||
647 | |||
648 | /** |
||
649 | * @return int|null |
||
650 | */ |
||
651 | public function getLoginCount() |
||
652 | { |
||
653 | return $this->loginCount; |
||
654 | } |
||
655 | |||
656 | /** |
||
657 | * @param int|null $loginCount |
||
658 | * @return CustomerInterface |
||
659 | */ |
||
660 | public function setLoginCount($loginCount) |
||
661 | { |
||
662 | $this->loginCount = $loginCount; |
||
663 | return $this; |
||
664 | } |
||
665 | |||
666 | /** |
||
667 | * @return null|string |
||
668 | */ |
||
669 | public function getPassword() |
||
670 | { |
||
671 | return $this->password; |
||
672 | } |
||
673 | |||
674 | /** |
||
675 | * @param null|string $password |
||
676 | * @return CustomerInterface |
||
677 | */ |
||
678 | public function setPassword($password) |
||
679 | { |
||
680 | $this->password = $password; |
||
681 | return $this; |
||
682 | } |
||
683 | |||
684 | /** |
||
685 | * @return null|string |
||
686 | */ |
||
687 | public function getReservedField1() |
||
688 | { |
||
689 | return $this->reservedField1; |
||
690 | } |
||
691 | |||
692 | /** |
||
693 | * @param null|string $reservedField1 |
||
694 | * @return CustomerInterface |
||
695 | */ |
||
696 | public function setReservedField1($reservedField1) |
||
700 | } |
||
701 | |||
702 | /** |
||
703 | * @return null|string |
||
704 | */ |
||
705 | public function getReservedField2() |
||
706 | { |
||
708 | } |
||
709 | |||
710 | /** |
||
711 | * @param null|string $reservedField2 |
||
712 | * @return CustomerInterface |
||
713 | */ |
||
714 | public function setReservedField2($reservedField2) |
||
715 | { |
||
716 | $this->reservedField2 = $reservedField2; |
||
717 | return $this; |
||
718 | } |
||
719 | |||
720 | /** |
||
721 | * @return null|string |
||
722 | */ |
||
723 | public function getReservedField3() |
||
726 | } |
||
727 | |||
728 | /** |
||
729 | * @param null|string $reservedField3 |
||
730 | * @return CustomerInterface |
||
731 | */ |
||
732 | public function setReservedField3($reservedField3) |
||
733 | { |
||
734 | $this->reservedField3 = $reservedField3; |
||
735 | return $this; |
||
736 | } |
||
737 | |||
738 | /** |
||
739 | * @return null|string |
||
740 | */ |
||
741 | public function getReservedField4() |
||
742 | { |
||
743 | return $this->reservedField4; |
||
744 | } |
||
745 | |||
746 | /** |
||
747 | * @param null|string $reservedField4 |
||
748 | * @return CustomerInterface |
||
749 | */ |
||
750 | public function setReservedField4($reservedField4) |
||
751 | { |
||
752 | $this->reservedField4 = $reservedField4; |
||
753 | return $this; |
||
754 | } |
||
755 | |||
756 | /** |
||
757 | * @return null|string |
||
758 | */ |
||
759 | public function getReservedField5() |
||
762 | } |
||
763 | |||
764 | /** |
||
765 | * @param null|string $reservedField5 |
||
766 | * @return CustomerInterface |
||
767 | */ |
||
768 | public function setReservedField5($reservedField5) |
||
769 | { |
||
770 | $this->reservedField5 = $reservedField5; |
||
771 | return $this; |
||
772 | } |
||
773 | } |
||
774 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths