EventAggregator
class EventAggregator (View source)
The EventAggregator is responsible for removing duplicate events.
Events are determined to be identical based on their name and date. If the names are similar or the dates are the same, they can be considered identical events. The merge function combines two EventDTOs into one, preferring non-null values. This is useful when multiple sources provide slightly different information about the same event.
Example usage: $agg = new EventAggregator(); $event1 = new EventDTO(name: 'UFC 300', date: new DateTime('2024-07-01')); $event2 = new EventDTO(name: 'UFC 300: The Return', date: new DateTime('2024-07-01')); if ($agg->isSameEvent($event1, $event2)) { $merged = $agg->merge($event1, $event2); // $merged will have the name 'UFC 300: The Return' and the date '2024-07-01' }
Methods
Determines if two EventDTOs represent the same event based on their name and date.