FightAggregator
class FightAggregator (View source)
The FightAggregator is responsible for merging two FightDTOs that represent the same fight.
It uses a FighterAggregator to merge the fighter information for both the red and blue corners. The merge function combines two FightDTOs into one, preferring non-null values and resolving conflicts. The isSameFight function determines if two FightDTOs represent the same fight based on their fighters.
Example usage: $agg = new FightAggregator(new FighterAggregator()); $fight1 = new FightDTO(redFighter: new FighterDTO(name: 'Fighter A'), blueFighter: new FighterDTO(name: 'Fighter B')); $fight2 = new FightDTO(redFighter: new FighterDTO(name: 'Fighter A'), blueFighter: new FighterDTO(name: 'Fighter B')); if ($agg->isSameFight($fight1, $fight2)) { $merged = $agg->merge($fight1, $fight2); // $merged will have merged fighter information and other details from both fights }
Methods
Constructs a new FightAggregator with a FighterAggregator dependency.
Determines if two FightDTOs represent the same fight based on their fighters.
Details
__construct(FighterAggregator $fighterAggregator)
Constructs a new FightAggregator with a FighterAggregator dependency.
FightDTO
merge(FightDTO $a, FightDTO $b)
Merges two FightDTOs into one, preferring non-null values and resolving conflicts.
Throws an exception if the fights are determined to be different.