Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Offer 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. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
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 Offer, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
64 | abstract class Offer extends EventSourcedAggregateRoot implements LabelAwareAggregateRoot |
||
65 | { |
||
66 | const DUPLICATE_REASON = 'duplicate'; |
||
67 | const INAPPROPRIATE_REASON = 'inappropriate'; |
||
68 | |||
69 | /** |
||
70 | * @var LabelCollection |
||
71 | */ |
||
72 | protected $labels; |
||
73 | |||
74 | /** |
||
75 | * @var ImageCollection |
||
76 | */ |
||
77 | protected $images; |
||
78 | |||
79 | /** |
||
80 | * @var string |
||
81 | * |
||
82 | * Organizer ids can come from UDB2 which does not strictly use UUIDs. |
||
83 | */ |
||
84 | protected $organizerId; |
||
85 | |||
86 | /** |
||
87 | * @var WorkflowStatus |
||
88 | */ |
||
89 | protected $workflowStatus; |
||
90 | |||
91 | /** |
||
92 | * @var StringLiteral|null |
||
93 | */ |
||
94 | protected $rejectedReason; |
||
95 | |||
96 | /** |
||
97 | * @var PriceInfo |
||
98 | */ |
||
99 | protected $priceInfo; |
||
100 | |||
101 | /** |
||
102 | * @var StringLiteral[] |
||
103 | */ |
||
104 | protected $titles; |
||
105 | |||
106 | /** |
||
107 | * @var Description[] |
||
108 | */ |
||
109 | protected $descriptions; |
||
110 | |||
111 | /** |
||
112 | * @var Language |
||
113 | */ |
||
114 | protected $mainLanguage; |
||
115 | |||
116 | /** |
||
117 | * @var string; |
||
118 | */ |
||
119 | protected $typeId; |
||
120 | |||
121 | /** |
||
122 | * @var string; |
||
123 | */ |
||
124 | protected $themeId; |
||
125 | |||
126 | /** |
||
127 | * @var array |
||
128 | */ |
||
129 | protected $facilities; |
||
130 | |||
131 | /** |
||
132 | * @var ContactPoint |
||
133 | */ |
||
134 | protected $contactPoint; |
||
135 | |||
136 | /** |
||
137 | * @var Calendar |
||
138 | */ |
||
139 | protected $calendar; |
||
140 | |||
141 | /** |
||
142 | * @var AgeRange |
||
143 | */ |
||
144 | protected $typicalAgeRange; |
||
145 | |||
146 | /** |
||
147 | * @var BookingInfo |
||
148 | */ |
||
149 | protected $bookingInfo; |
||
150 | |||
151 | /** |
||
152 | * @var bool |
||
153 | */ |
||
154 | protected $isDeleted = false; |
||
155 | |||
156 | /** |
||
157 | * Offer constructor. |
||
158 | */ |
||
159 | public function __construct() |
||
171 | |||
172 | /** |
||
173 | * @param EventType $type |
||
174 | */ |
||
175 | public function updateType(EventType $type) |
||
181 | |||
182 | /** |
||
183 | * @param Theme $theme |
||
184 | */ |
||
185 | public function updateTheme(Theme $theme) |
||
191 | |||
192 | /** |
||
193 | * @param array $facilities |
||
194 | */ |
||
195 | public function updateFacilities(array $facilities) |
||
201 | |||
202 | /** |
||
203 | * @param AbstractFacilitiesUpdated $facilitiesUpdated |
||
204 | */ |
||
205 | protected function applyFacilitiesUpdated(AbstractFacilitiesUpdated $facilitiesUpdated) |
||
209 | |||
210 | /** |
||
211 | * @param array $facilities1 |
||
212 | * @param array $facilities2 |
||
213 | * @return bool |
||
214 | */ |
||
215 | private function sameFacilities($facilities1, $facilities2) |
||
231 | |||
232 | /** |
||
233 | * Get the id of the main image if one is selected for this offer. |
||
234 | * |
||
235 | * @return UUID|null |
||
236 | */ |
||
237 | protected function getMainImageId() |
||
242 | |||
243 | /** |
||
244 | * @inheritdoc |
||
245 | */ |
||
246 | public function addLabel(Label $label) |
||
254 | |||
255 | /** |
||
256 | * @inheritdoc |
||
257 | */ |
||
258 | public function removeLabel(Label $label) |
||
266 | |||
267 | /** |
||
268 | * @param Labels $labels |
||
269 | * @param Labels $labelsToKeepIfAlreadyOnOffer |
||
270 | */ |
||
271 | public function importLabels(Labels $labels, Labels $labelsToKeepIfAlreadyOnOffer, Labels $labelsToRemoveWhenOnOffer) |
||
332 | |||
333 | /** |
||
334 | * @param Language $language |
||
335 | * @param Title $title |
||
336 | */ |
||
337 | public function updateTitle(Language $language, Title $title) |
||
349 | |||
350 | /** |
||
351 | * @param AbstractTitleTranslated $titleTranslated |
||
352 | */ |
||
353 | public function applyTitleTranslated(AbstractTitleTranslated $titleTranslated) |
||
357 | |||
358 | |||
359 | /** |
||
360 | * @param AbstractTitleUpdated $titleUpdated |
||
361 | */ |
||
362 | public function applyTitleUpdated(AbstractTitleUpdated $titleUpdated) |
||
366 | |||
367 | /** |
||
368 | * @param Description $description |
||
369 | * @param Language $language |
||
370 | */ |
||
371 | public function updateDescription(Description $description, Language $language) |
||
383 | |||
384 | /** |
||
385 | * @param Calendar $calendar |
||
386 | */ |
||
387 | public function updateCalendar(Calendar $calendar) |
||
395 | |||
396 | /** |
||
397 | * @param AbstractCalendarUpdated $calendarUpdated |
||
398 | */ |
||
399 | protected function applyCalendarUpdated(AbstractCalendarUpdated $calendarUpdated) |
||
403 | |||
404 | /** |
||
405 | * @param AgeRange $typicalAgeRange |
||
406 | */ |
||
407 | public function updateTypicalAgeRange(AgeRange $typicalAgeRange) |
||
415 | |||
416 | /** |
||
417 | * @param AbstractTypicalAgeRangeUpdated $typicalAgeRangeUpdated |
||
418 | */ |
||
419 | protected function applyTypicalAgeRangeUpdated(AbstractTypicalAgeRangeUpdated $typicalAgeRangeUpdated) |
||
423 | |||
424 | public function deleteTypicalAgeRange() |
||
432 | |||
433 | /** |
||
434 | * @param AbstractTypicalAgeRangeDeleted $typicalAgeRangeDeleted |
||
435 | */ |
||
436 | public function applyTypicalAgeRangeDeleted(AbstractTypicalAgeRangeDeleted $typicalAgeRangeDeleted) |
||
440 | |||
441 | /** |
||
442 | * @param string $organizerId |
||
443 | */ |
||
444 | public function updateOrganizer($organizerId) |
||
452 | |||
453 | /** |
||
454 | * Delete the given organizer. |
||
455 | * |
||
456 | * @param string $organizerId |
||
457 | */ |
||
458 | public function deleteOrganizer($organizerId) |
||
466 | |||
467 | /** |
||
468 | * Delete the current organizer regardless of the id. |
||
469 | */ |
||
470 | public function deleteCurrentOrganizer() |
||
478 | |||
479 | /** |
||
480 | * Updated the contact info. |
||
481 | * @param ContactPoint $contactPoint |
||
482 | */ |
||
483 | public function updateContactPoint(ContactPoint $contactPoint) |
||
491 | |||
492 | /** |
||
493 | * @param AbstractContactPointUpdated $contactPointUpdated |
||
494 | */ |
||
495 | protected function applyContactPointUpdated(AbstractContactPointUpdated $contactPointUpdated) |
||
499 | |||
500 | /** |
||
501 | * @param Coordinates $coordinates |
||
502 | */ |
||
503 | public function updateGeoCoordinates(Coordinates $coordinates) |
||
513 | |||
514 | /** |
||
515 | * Updated the booking info. |
||
516 | * |
||
517 | * @param BookingInfo $bookingInfo |
||
518 | */ |
||
519 | public function updateBookingInfo(BookingInfo $bookingInfo) |
||
527 | |||
528 | /** |
||
529 | * @param AbstractBookingInfoUpdated $bookingInfoUpdated |
||
530 | */ |
||
531 | public function applyBookingInfoUpdated(AbstractBookingInfoUpdated $bookingInfoUpdated) |
||
535 | |||
536 | /** |
||
537 | * @param PriceInfo $priceInfo |
||
538 | */ |
||
539 | public function updatePriceInfo(PriceInfo $priceInfo) |
||
547 | |||
548 | /** |
||
549 | * @param AbstractPriceInfoUpdated $priceInfoUpdated |
||
550 | */ |
||
551 | protected function applyPriceInfoUpdated(AbstractPriceInfoUpdated $priceInfoUpdated) |
||
555 | |||
556 | /** |
||
557 | * @param AbstractLabelAdded $labelAdded |
||
558 | */ |
||
559 | protected function applyLabelAdded(AbstractLabelAdded $labelAdded) |
||
563 | |||
564 | /** |
||
565 | * @param AbstractLabelRemoved $labelRemoved |
||
566 | */ |
||
567 | protected function applyLabelRemoved(AbstractLabelRemoved $labelRemoved) |
||
571 | |||
572 | /** |
||
573 | * @param AbstractThemeUpdated $themeUpdated |
||
574 | */ |
||
575 | protected function applyThemeUpdated(AbstractThemeUpdated $themeUpdated) |
||
579 | |||
580 | /** |
||
581 | * @param AbstractTypeUpdated $themeUpdated |
||
582 | */ |
||
583 | protected function applyTypeUpdated(AbstractTypeUpdated $themeUpdated) |
||
587 | |||
588 | protected function applyDescriptionUpdated(AbstractDescriptionUpdated $descriptionUpdated) |
||
593 | |||
594 | protected function applyDescriptionTranslated(AbstractDescriptionTranslated $descriptionTranslated) |
||
599 | |||
600 | /** |
||
601 | * Add a new image. |
||
602 | * |
||
603 | * @param Image $image |
||
604 | */ |
||
605 | public function addImage(Image $image) |
||
616 | |||
617 | /** |
||
618 | * @param UUID $mediaObjectId |
||
619 | * @param StringLiteral $description |
||
620 | * @param StringLiteral $copyrightHolder |
||
621 | */ |
||
622 | public function updateImage( |
||
637 | |||
638 | /** |
||
639 | * @param UUID $mediaObjectId |
||
640 | * @param StringLiteral $description |
||
641 | * @param StringLiteral $copyrightHolder |
||
642 | * @return bool |
||
643 | */ |
||
644 | private function updateImageAllowed( |
||
660 | |||
661 | /** |
||
662 | * Remove an image. |
||
663 | * |
||
664 | * @param Image $image |
||
665 | */ |
||
666 | public function removeImage(Image $image) |
||
678 | |||
679 | /** |
||
680 | * Make an existing image of the item the main image. |
||
681 | * |
||
682 | * @param Image $image |
||
683 | */ |
||
684 | public function selectMainImage(Image $image) |
||
698 | |||
699 | /** |
||
700 | * @param ImageCollection $imageCollection |
||
701 | */ |
||
702 | public function importImages(ImageCollection $imageCollection) |
||
747 | |||
748 | /** |
||
749 | * Delete the offer. |
||
750 | */ |
||
751 | public function delete() |
||
757 | |||
758 | /** |
||
759 | * @param CultureFeed_Cdb_Item_Base $cdbItem |
||
760 | */ |
||
761 | protected function importWorkflowStatus(CultureFeed_Cdb_Item_Base $cdbItem) |
||
770 | |||
771 | /** |
||
772 | * Publish the offer when it has workflowstatus draft. |
||
773 | * @param \DateTimeInterface $publicationDate |
||
774 | */ |
||
775 | public function publish(\DateTimeInterface $publicationDate) |
||
781 | |||
782 | /** |
||
783 | * @return bool |
||
784 | * @throws Exception |
||
785 | */ |
||
786 | View Code Duplication | private function guardPublish() |
|
798 | |||
799 | /** |
||
800 | * Approve the offer when it's waiting for validation. |
||
801 | */ |
||
802 | public function approve() |
||
806 | |||
807 | /** |
||
808 | * @return bool |
||
809 | * @throws Exception |
||
810 | */ |
||
811 | View Code Duplication | private function guardApprove() |
|
823 | |||
824 | /** |
||
825 | * Reject an offer that is waiting for validation with a given reason. |
||
826 | * @param StringLiteral $reason |
||
827 | */ |
||
828 | public function reject(StringLiteral $reason) |
||
832 | |||
833 | public function flagAsDuplicate() |
||
838 | |||
839 | public function flagAsInappropriate() |
||
844 | |||
845 | /** |
||
846 | * @param StringLiteral $reason |
||
847 | * @return bool |
||
848 | * false when the offer can still be rejected, true when the offer is already rejected for the same reason |
||
849 | * @throws Exception |
||
850 | */ |
||
851 | private function guardRejection(StringLiteral $reason) |
||
867 | |||
868 | /** |
||
869 | * @param Title $title |
||
870 | * @param Language $language |
||
871 | * @return bool |
||
872 | */ |
||
873 | View Code Duplication | private function isTitleChanged(Title $title, Language $language) |
|
880 | |||
881 | /** |
||
882 | * @param Description $description |
||
883 | * @param Language $language |
||
884 | * @return bool |
||
885 | */ |
||
886 | View Code Duplication | private function isDescriptionChanged(Description $description, Language $language) |
|
893 | |||
894 | /** |
||
895 | * Overwrites or resets the main image and all media objects |
||
896 | * by importing a new collection of images from UDB2. |
||
897 | * |
||
898 | * @param ImageCollection $images |
||
899 | */ |
||
900 | public function importImagesFromUDB2(ImageCollection $images) |
||
904 | |||
905 | /** |
||
906 | * Overwrites or resets the main image and all media objects |
||
907 | * by updating with a new collection of images from UDB2. |
||
908 | * |
||
909 | * @param ImageCollection $images |
||
910 | */ |
||
911 | public function updateImagesFromUDB2(ImageCollection $images) |
||
915 | |||
916 | /** |
||
917 | * @param AbstractPublished $published |
||
918 | */ |
||
919 | protected function applyPublished(AbstractPublished $published) |
||
923 | |||
924 | /** |
||
925 | * @param AbstractApproved $approved |
||
926 | */ |
||
927 | protected function applyApproved(AbstractApproved $approved) |
||
931 | |||
932 | /** |
||
933 | * @param AbstractRejected $rejected |
||
934 | */ |
||
935 | protected function applyRejected(AbstractRejected $rejected) |
||
940 | |||
941 | /** |
||
942 | * @param AbstractFlaggedAsDuplicate $flaggedAsDuplicate |
||
943 | */ |
||
944 | protected function applyFlaggedAsDuplicate(AbstractFlaggedAsDuplicate $flaggedAsDuplicate) |
||
949 | |||
950 | /** |
||
951 | * @param AbstractFlaggedAsInappropriate $flaggedAsInappropriate |
||
952 | */ |
||
953 | protected function applyFlaggedAsInappropriate(AbstractFlaggedAsInappropriate $flaggedAsInappropriate) |
||
958 | |||
959 | protected function applyImageAdded(AbstractImageAdded $imageAdded) |
||
963 | |||
964 | protected function applyImageUpdated(AbstractImageUpdated $imageUpdated) |
||
981 | |||
982 | protected function applyImageRemoved(AbstractImageRemoved $imageRemoved) |
||
989 | |||
990 | protected function applyMainImageSelected(AbstractMainImageSelected $mainImageSelected) |
||
994 | |||
995 | protected function applyOrganizerUpdated(AbstractOrganizerUpdated $organizerUpdated) |
||
999 | |||
1000 | protected function applyOrganizerDeleted(AbstractOrganizerDeleted $organizerDeleted) |
||
1004 | |||
1005 | /** |
||
1006 | * @param AbstractImagesImportedFromUDB2 $imagesImportedFromUDB2 |
||
1007 | */ |
||
1008 | protected function applyImagesImportedFromUDB2(AbstractImagesImportedFromUDB2 $imagesImportedFromUDB2) |
||
1012 | |||
1013 | /** |
||
1014 | * @param AbstractImagesUpdatedFromUDB2 $imagesUpdatedFromUDB2 |
||
1015 | */ |
||
1016 | protected function applyImagesUpdatedFromUDB2(AbstractImagesUpdatedFromUDB2 $imagesUpdatedFromUDB2) |
||
1020 | |||
1021 | /** |
||
1022 | * This indirect apply method can be called internally to deal with images coming from UDB2. |
||
1023 | * Imports from UDB2 only contain the native Dutch content. |
||
1024 | * @see https://github.com/cultuurnet/udb3-udb2-bridge/blob/db0a7ab2444f55bb3faae3d59b82b39aaeba253b/test/Media/ImageCollectionFactoryTest.php#L79-L103 |
||
1025 | * Because of this we have to make sure translated images are left in place. |
||
1026 | * |
||
1027 | * @param AbstractImagesEvent $imagesEvent |
||
1028 | */ |
||
1029 | protected function applyUdb2ImagesEvent(AbstractImagesEvent $imagesEvent) |
||
1045 | |||
1046 | /** |
||
1047 | * @param Label $label |
||
1048 | * @return AbstractLabelAdded |
||
1049 | */ |
||
1050 | abstract protected function createLabelAddedEvent(Label $label); |
||
1051 | |||
1052 | /** |
||
1053 | * @param Label $label |
||
1054 | * @return AbstractLabelRemoved |
||
1055 | */ |
||
1056 | abstract protected function createLabelRemovedEvent(Label $label); |
||
1057 | |||
1058 | /** |
||
1059 | * @param Labels $labels |
||
1060 | * @return AbstractLabelsImported |
||
1061 | */ |
||
1062 | abstract protected function createLabelsImportedEvent(Labels $labels); |
||
1063 | |||
1064 | /** |
||
1065 | * @param Language $language |
||
1066 | * @param Title $title |
||
1067 | * @return AbstractTitleTranslated |
||
1068 | */ |
||
1069 | abstract protected function createTitleTranslatedEvent(Language $language, Title $title); |
||
1070 | |||
1071 | /** |
||
1072 | * @param Language $language |
||
1073 | * @param Description $description |
||
1074 | * @return AbstractDescriptionTranslated |
||
1075 | */ |
||
1076 | abstract protected function createDescriptionTranslatedEvent(Language $language, Description $description); |
||
1077 | |||
1078 | /** |
||
1079 | * @param Image $image |
||
1080 | * @return AbstractImageAdded |
||
1081 | */ |
||
1082 | abstract protected function createImageAddedEvent(Image $image); |
||
1083 | |||
1084 | /** |
||
1085 | * @param Image $image |
||
1086 | * @return AbstractImageRemoved |
||
1087 | */ |
||
1088 | abstract protected function createImageRemovedEvent(Image $image); |
||
1089 | |||
1090 | /** |
||
1091 | * @param UUID $uuid |
||
1092 | * @param StringLiteral $description |
||
1093 | * @param StringLiteral $copyrightHolder |
||
1094 | * @return AbstractImageUpdated |
||
1095 | */ |
||
1096 | abstract protected function createImageUpdatedEvent( |
||
1101 | |||
1102 | /** |
||
1103 | * @param Image $image |
||
1104 | * @return AbstractMainImageSelected |
||
1105 | */ |
||
1106 | abstract protected function createMainImageSelectedEvent(Image $image); |
||
1107 | |||
1108 | /** |
||
1109 | * @return AbstractOfferDeleted |
||
1110 | */ |
||
1111 | abstract protected function createOfferDeletedEvent(); |
||
1112 | |||
1113 | /** |
||
1114 | * @param Title $title |
||
1115 | * @return AbstractTitleUpdated |
||
1116 | */ |
||
1117 | abstract protected function createTitleUpdatedEvent(Title $title); |
||
1118 | |||
1119 | /** |
||
1120 | * @param Description $description |
||
1121 | * @return AbstractDescriptionUpdated |
||
1122 | */ |
||
1123 | abstract protected function createDescriptionUpdatedEvent(Description $description); |
||
1124 | |||
1125 | /** |
||
1126 | * @param Calendar $calendar |
||
1127 | * @return AbstractCalendarUpdated |
||
1128 | */ |
||
1129 | abstract protected function createCalendarUpdatedEvent(Calendar $calendar); |
||
1130 | |||
1131 | /** |
||
1132 | * @param string $typicalAgeRange |
||
1133 | * @return AbstractTypicalAgeRangeUpdated |
||
1134 | */ |
||
1135 | abstract protected function createTypicalAgeRangeUpdatedEvent($typicalAgeRange); |
||
1136 | |||
1137 | /** |
||
1138 | * @return AbstractTypicalAgeRangeDeleted |
||
1139 | */ |
||
1140 | abstract protected function createTypicalAgeRangeDeletedEvent(); |
||
1141 | |||
1142 | /** |
||
1143 | * @param string $organizerId |
||
1144 | * @return AbstractOrganizerUpdated |
||
1145 | */ |
||
1146 | abstract protected function createOrganizerUpdatedEvent($organizerId); |
||
1147 | |||
1148 | /** |
||
1149 | * @param string $organizerId |
||
1150 | * @return AbstractOrganizerDeleted |
||
1151 | */ |
||
1152 | abstract protected function createOrganizerDeletedEvent($organizerId); |
||
1153 | |||
1154 | /** |
||
1155 | * @param ContactPoint $contactPoint |
||
1156 | * @return AbstractContactPointUpdated |
||
1157 | */ |
||
1158 | abstract protected function createContactPointUpdatedEvent(ContactPoint $contactPoint); |
||
1159 | |||
1160 | /** |
||
1161 | * @param Coordinates $coordinates |
||
1162 | * @return AbstractGeoCoordinatesUpdated |
||
1163 | */ |
||
1164 | abstract protected function createGeoCoordinatesUpdatedEvent(Coordinates $coordinates); |
||
1165 | |||
1166 | /** |
||
1167 | * @param BookingInfo $bookingInfo |
||
1168 | * @return AbstractBookingInfoUpdated |
||
1169 | */ |
||
1170 | abstract protected function createBookingInfoUpdatedEvent(BookingInfo $bookingInfo); |
||
1171 | |||
1172 | /** |
||
1173 | * @param PriceInfo $priceInfo |
||
1174 | * @return AbstractPriceInfoUpdated |
||
1175 | */ |
||
1176 | abstract protected function createPriceInfoUpdatedEvent(PriceInfo $priceInfo); |
||
1177 | |||
1178 | /** |
||
1179 | * @param \DateTimeInterface $publicationDate |
||
1180 | * @return AbstractPublished |
||
1181 | */ |
||
1182 | abstract protected function createPublishedEvent(\DateTimeInterface $publicationDate); |
||
1183 | |||
1184 | /** |
||
1185 | * @return AbstractApproved |
||
1186 | */ |
||
1187 | abstract protected function createApprovedEvent(); |
||
1188 | |||
1189 | /** |
||
1190 | * @param StringLiteral $reason |
||
1191 | * @return AbstractRejected |
||
1192 | */ |
||
1193 | abstract protected function createRejectedEvent(StringLiteral $reason); |
||
1194 | |||
1195 | /** |
||
1196 | * @return AbstractFlaggedAsDuplicate |
||
1197 | */ |
||
1198 | abstract protected function createFlaggedAsDuplicate(); |
||
1199 | |||
1200 | /** |
||
1201 | * @return AbstractFlaggedAsInappropriate |
||
1202 | */ |
||
1203 | abstract protected function createFlaggedAsInappropriate(); |
||
1204 | |||
1205 | /** |
||
1206 | * @param ImageCollection $images |
||
1207 | * @return AbstractImagesImportedFromUDB2 |
||
1208 | */ |
||
1209 | abstract protected function createImagesImportedFromUDB2(ImageCollection $images); |
||
1210 | |||
1211 | /** |
||
1212 | * @param ImageCollection $images |
||
1213 | * @return AbstractImagesUpdatedFromUDB2 |
||
1214 | */ |
||
1215 | abstract protected function createImagesUpdatedFromUDB2(ImageCollection $images); |
||
1216 | |||
1217 | /** |
||
1218 | * @param EventType $type |
||
1219 | * @return AbstractTypeUpdated |
||
1220 | */ |
||
1221 | abstract protected function createTypeUpdatedEvent(EventType $type); |
||
1222 | |||
1223 | /** |
||
1224 | * @param Theme $theme |
||
1225 | * @return AbstractThemeUpdated |
||
1226 | */ |
||
1227 | abstract protected function createThemeUpdatedEvent(Theme $theme); |
||
1228 | |||
1229 | /** |
||
1230 | * @param array $facilities |
||
1231 | * @return AbstractFacilitiesUpdated |
||
1232 | */ |
||
1233 | abstract protected function createFacilitiesUpdatedEvent(array $facilities); |
||
1234 | } |
||
1235 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.