class FightDeduplicator (View source)

The FightDeduplicator is responsible for deduplicating a list of FightDTOs by grouping them based on their similarity and merging them using a FightAggregator.

The group function groups fights that are considered the same based on the FightAggregator's isSameFight method. The deduplicate function merges each group of similar fights into a single FightDTO using the FightAggregator's merge method.

Example usage: $agg = new FightAggregator(new FighterAggregator()); $dedup = new FightDeduplicator($agg); $fights = [...]; // An array of FightDTOs $result = $dedup->deduplicate($fights); // $result will contain deduplicated and merged FightDTOs

Methods

__construct(FightAggregator $aggregator)

Constructs a new FightDeduplicator with a FightAggregator dependency.

array
group(array $fights)

Groups fights that are considered the same based on the FightAggregator's isSameFight method.

array
deduplicate(array $fights)

Deduplicates a list of FightDTOs by grouping them based on their similarity and merging them using a FightAggregator.

Details

__construct(FightAggregator $aggregator)

Constructs a new FightDeduplicator with a FightAggregator dependency.

Parameters

FightAggregator $aggregator

The FightAggregator to use for merging fights.

array group(array $fights)

Groups fights that are considered the same based on the FightAggregator's isSameFight method.

Parameters

array $fights

An array of FightDTOs to group.

Return Value

array

An array of groups, where each group is an array of FightDTOs that are considered the same fight.

array deduplicate(array $fights)

Deduplicates a list of FightDTOs by grouping them based on their similarity and merging them using a FightAggregator.

Parameters

array $fights

An array of FightDTOs to deduplicate.

Return Value

array

An array of deduplicated and merged FightDTOs.