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

merge(FighterDTO $a, FighterDTO $b)

Merges two FighterDTOs into one, preferring non-null values and resolving conflicts.

bool
isSameFighter(FighterDTO $a, FighterDTO $b)

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.

Parameters

FighterDTO $a

The first fighter to merge.

FighterDTO $b

The second fighter to merge.

Return Value

FighterDTO

The merged fighter.

Exceptions

InvalidArgumentException

bool isSameFighter(FighterDTO $a, FighterDTO $b)

Determines if two FighterDTOs represent the same fighter based on their Sherdog ID or similar names.

Parameters

FighterDTO $a

The first fighter to compare.

FighterDTO $b

The second fighter to compare.

Return Value

bool

True if the fighters are considered the same, false otherwise.