FighterAggregator
class FighterAggregator (View source)
The FighterAggregator is responsible for merging two FighterDTOs that represent the same fighter.
The merge function combines two FighterDTOs into one, preferring non-null values and resolving conflicts. The isSameFighter function determines if two FighterDTOs represent the same fighter based on their Sherdog ID or similar names.
Example usage: $agg = new FighterAggregator(); $fighter1 = new FighterDTO(name: 'Fighter A', sherdogId: 123); $fighter2 = new FighterDTO(name: 'Fighter A', sherdogId: 123); if ($agg->isSameFighter($fighter1, $fighter2)) { $merged = $agg->merge($fighter1, $fighter2); // $merged will have merged information from both fighters }
Methods
Merges two FighterDTOs into one, preferring non-null values and resolving conflicts.
Determines if two FighterDTOs represent the same fighter based on their Sherdog ID or similar names.
Details
FighterDTO
merge(FighterDTO $a, FighterDTO $b)
Merges two FighterDTOs into one, preferring non-null values and resolving conflicts.
Throws an exception if the fighters are determined to be different.
bool
isSameFighter(FighterDTO $a, FighterDTO $b)
Determines if two FighterDTOs represent the same fighter based on their Sherdog ID or similar names.