Complex classes like Event 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 Event, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 56 | class Event extends Offer implements UpdateableWithCdbXmlInterface  | 
            ||
| 57 | { | 
            ||
| 58 | protected $eventId;  | 
            ||
| 59 | |||
| 60 | /**  | 
            ||
| 61 | * @var Audience  | 
            ||
| 62 | */  | 
            ||
| 63 | private $audience;  | 
            ||
| 64 | |||
| 65 | const MAIN_LANGUAGE_CODE = 'nl';  | 
            ||
| 66 | |||
| 67 | public function __construct()  | 
            ||
| 71 | |||
| 72 | /**  | 
            ||
| 73 | * Factory method to create a new event.  | 
            ||
| 74 | *  | 
            ||
| 75 | * @param Title $title  | 
            ||
| 76 | * @param EventType $eventType  | 
            ||
| 77 | * @param Location $location  | 
            ||
| 78 | * @param CalendarInterface $calendar  | 
            ||
| 79 | * @param Theme|null $theme  | 
            ||
| 80 | * @param \DateTimeImmutable|null $publicationDate  | 
            ||
| 81 | *  | 
            ||
| 82 | * @return Event  | 
            ||
| 83 | */  | 
            ||
| 84 | public static function create(  | 
            ||
| 115 | |||
| 116 | /**  | 
            ||
| 117 | * @param string $eventId  | 
            ||
| 118 | * @param string $cdbXml  | 
            ||
| 119 | * @param string $cdbXmlNamespaceUri  | 
            ||
| 120 | * @return Event  | 
            ||
| 121 | */  | 
            ||
| 122 | public static function importFromUDB2(  | 
            ||
| 138 | |||
| 139 | /**  | 
            ||
| 140 | * @param ImageCollection $images  | 
            ||
| 141 | */  | 
            ||
| 142 | public function updateImagesFromUDB2(ImageCollection $images)  | 
            ||
| 146 | |||
| 147 | /**  | 
            ||
| 148 | * @param ImageCollection $images  | 
            ||
| 149 | */  | 
            ||
| 150 | public function importImagesFromUDB2(ImageCollection $images)  | 
            ||
| 154 | |||
| 155 | /**  | 
            ||
| 156 |      * {@inheritdoc} | 
            ||
| 157 | */  | 
            ||
| 158 | public function getAggregateRootId()  | 
            ||
| 162 | |||
| 163 | /**  | 
            ||
| 164 | * @return UUID[]  | 
            ||
| 165 | */  | 
            ||
| 166 | public function getMediaObjects()  | 
            ||
| 170 | |||
| 171 | protected function applyEventCreated(EventCreated $eventCreated)  | 
            ||
| 176 | |||
| 177 | protected function applyEventImportedFromUDB2(  | 
            ||
| 183 | |||
| 184 | /**  | 
            ||
| 185 | * @param EventUpdatedFromUDB2 $eventUpdated  | 
            ||
| 186 | */  | 
            ||
| 187 | protected function applyEventUpdatedFromUDB2(  | 
            ||
| 192 | |||
| 193 | /**  | 
            ||
| 194 | * @param EventCdbXMLInterface $eventCdbXML  | 
            ||
| 195 | */  | 
            ||
| 196 | protected function setUDB2Data(  | 
            ||
| 207 | |||
| 208 | /**  | 
            ||
| 209 | * Update the major info.  | 
            ||
| 210 | *  | 
            ||
| 211 | * @param Title $title  | 
            ||
| 212 | * @param EventType $eventType  | 
            ||
| 213 | * @param Location $location  | 
            ||
| 214 | * @param CalendarInterface $calendar  | 
            ||
| 215 | * @param Theme|null $theme  | 
            ||
| 216 | */  | 
            ||
| 217 | public function updateMajorInfo(  | 
            ||
| 226 | |||
| 227 | /**  | 
            ||
| 228 | * @param Audience $audience  | 
            ||
| 229 | */  | 
            ||
| 230 | public function updateAudience(  | 
            ||
| 231 | Audience $audience  | 
            ||
| 232 |     ) { | 
            ||
| 233 |         if (is_null($this->audience) || !$this->audience->equals($audience)) { | 
            ||
| 234 | $this->apply(new AudienceUpdated(  | 
            ||
| 235 | $this->eventId,  | 
            ||
| 236 | $audience  | 
            ||
| 237 | ));  | 
            ||
| 238 | }  | 
            ||
| 239 | }  | 
            ||
| 240 | |||
| 241 | /**  | 
            ||
| 242 | * @param AudienceUpdated $audienceUpdated  | 
            ||
| 243 | */  | 
            ||
| 244 | public function applyAudienceUpdated(AudienceUpdated $audienceUpdated)  | 
            ||
| 248 | |||
| 249 | /**  | 
            ||
| 250 | * @inheritDoc  | 
            ||
| 251 | * @return ImagesImportedFromUDB2  | 
            ||
| 252 | */  | 
            ||
| 253 | protected function createImagesImportedFromUDB2(ImageCollection $images)  | 
            ||
| 257 | |||
| 258 | /**  | 
            ||
| 259 | * @inheritDoc  | 
            ||
| 260 | * @return ImagesUpdatedFromUDB2  | 
            ||
| 261 | */  | 
            ||
| 262 | protected function createImagesUpdatedFromUDB2(ImageCollection $images)  | 
            ||
| 266 | |||
| 267 | /**  | 
            ||
| 268 | * @inheritdoc  | 
            ||
| 269 | */  | 
            ||
| 270 | public function updateWithCdbXml($cdbXml, $cdbXmlNamespaceUri)  | 
            ||
| 280 | |||
| 281 | /**  | 
            ||
| 282 | * @param Label $label  | 
            ||
| 283 | * @return LabelAdded  | 
            ||
| 284 | */  | 
            ||
| 285 | protected function createLabelAddedEvent(Label $label)  | 
            ||
| 289 | |||
| 290 | /**  | 
            ||
| 291 | * @param Label $label  | 
            ||
| 292 | * @return LabelRemoved  | 
            ||
| 293 | */  | 
            ||
| 294 | protected function createLabelRemovedEvent(Label $label)  | 
            ||
| 298 | |||
| 299 | /**  | 
            ||
| 300 | * @param Image $image  | 
            ||
| 301 | * @return ImageAdded  | 
            ||
| 302 | */  | 
            ||
| 303 | protected function createImageAddedEvent(Image $image)  | 
            ||
| 307 | |||
| 308 | /**  | 
            ||
| 309 | * @param Image $image  | 
            ||
| 310 | * @return ImageRemoved  | 
            ||
| 311 | */  | 
            ||
| 312 | protected function createImageRemovedEvent(Image $image)  | 
            ||
| 316 | |||
| 317 | /**  | 
            ||
| 318 | * @param AbstractUpdateImage $updateImageCommand  | 
            ||
| 319 | * @return ImageUpdated  | 
            ||
| 320 | */  | 
            ||
| 321 | protected function createImageUpdatedEvent(  | 
            ||
| 331 | |||
| 332 | /**  | 
            ||
| 333 | * @param Image $image  | 
            ||
| 334 | * @return MainImageSelected  | 
            ||
| 335 | */  | 
            ||
| 336 | protected function createMainImageSelectedEvent(Image $image)  | 
            ||
| 340 | |||
| 341 | /**  | 
            ||
| 342 | * @param Language $language  | 
            ||
| 343 | * @param StringLiteral $title  | 
            ||
| 344 | * @return TitleTranslated  | 
            ||
| 345 | */  | 
            ||
| 346 | protected function createTitleTranslatedEvent(Language $language, StringLiteral $title)  | 
            ||
| 350 | |||
| 351 | /**  | 
            ||
| 352 | * @param Language $language  | 
            ||
| 353 | * @param StringLiteral $description  | 
            ||
| 354 | * @return DescriptionTranslated  | 
            ||
| 355 | */  | 
            ||
| 356 | protected function createDescriptionTranslatedEvent(Language $language, StringLiteral $description)  | 
            ||
| 360 | |||
| 361 | /**  | 
            ||
| 362 | * @param string $description  | 
            ||
| 363 | * @return DescriptionUpdated  | 
            ||
| 364 | */  | 
            ||
| 365 | protected function createDescriptionUpdatedEvent($description)  | 
            ||
| 369 | |||
| 370 | /**  | 
            ||
| 371 | * @param string $typicalAgeRange  | 
            ||
| 372 | * @return TypicalAgeRangeUpdated  | 
            ||
| 373 | */  | 
            ||
| 374 | protected function createTypicalAgeRangeUpdatedEvent($typicalAgeRange)  | 
            ||
| 378 | |||
| 379 | /**  | 
            ||
| 380 | * @return TypicalAgeRangeDeleted  | 
            ||
| 381 | */  | 
            ||
| 382 | protected function createTypicalAgeRangeDeletedEvent()  | 
            ||
| 386 | |||
| 387 | /**  | 
            ||
| 388 | * @param string $organizerId  | 
            ||
| 389 | * @return OrganizerUpdated  | 
            ||
| 390 | */  | 
            ||
| 391 | protected function createOrganizerUpdatedEvent($organizerId)  | 
            ||
| 395 | |||
| 396 | /**  | 
            ||
| 397 | * @param string $organizerId  | 
            ||
| 398 | * @return OrganizerDeleted  | 
            ||
| 399 | */  | 
            ||
| 400 | protected function createOrganizerDeletedEvent($organizerId)  | 
            ||
| 404 | |||
| 405 | /**  | 
            ||
| 406 | * @param ContactPoint $contactPoint  | 
            ||
| 407 | * @return ContactPointUpdated  | 
            ||
| 408 | */  | 
            ||
| 409 | protected function createContactPointUpdatedEvent(ContactPoint $contactPoint)  | 
            ||
| 413 | |||
| 414 | /**  | 
            ||
| 415 | * @param BookingInfo $bookingInfo  | 
            ||
| 416 | * @return BookingInfoUpdated  | 
            ||
| 417 | */  | 
            ||
| 418 | protected function createBookingInfoUpdatedEvent(BookingInfo $bookingInfo)  | 
            ||
| 422 | |||
| 423 | /**  | 
            ||
| 424 | * @param PriceInfo $priceInfo  | 
            ||
| 425 | * @return PriceInfoUpdated  | 
            ||
| 426 | */  | 
            ||
| 427 | protected function createPriceInfoUpdatedEvent(PriceInfo $priceInfo)  | 
            ||
| 431 | |||
| 432 | /**  | 
            ||
| 433 | * @return EventDeleted  | 
            ||
| 434 | */  | 
            ||
| 435 | protected function createOfferDeletedEvent()  | 
            ||
| 439 | |||
| 440 | /**  | 
            ||
| 441 | * @inheritdoc  | 
            ||
| 442 | */  | 
            ||
| 443 | protected function createPublishedEvent(\DateTimeInterface $publicationDate)  | 
            ||
| 447 | |||
| 448 | /**  | 
            ||
| 449 | * @inheritdoc  | 
            ||
| 450 | */  | 
            ||
| 451 | protected function createApprovedEvent()  | 
            ||
| 455 | |||
| 456 | /**  | 
            ||
| 457 | * @inheritdoc  | 
            ||
| 458 | */  | 
            ||
| 459 | protected function createRejectedEvent(StringLiteral $reason)  | 
            ||
| 463 | |||
| 464 | /**  | 
            ||
| 465 | * @inheritDoc  | 
            ||
| 466 | */  | 
            ||
| 467 | protected function createFlaggedAsDuplicate()  | 
            ||
| 471 | |||
| 472 | /**  | 
            ||
| 473 | * @inheritDoc  | 
            ||
| 474 | */  | 
            ||
| 475 | protected function createFlaggedAsInappropriate()  | 
            ||
| 479 | }  | 
            ||
| 480 |