class SherdogIdResolver (View source)

Resolves a Sherdog fighter ID from a list of candidates based on name similarity.

This is used to match a fighter's name to the correct Sherdog ID when multiple candidates are found in search results. The resolver uses a simple string similarity measure to determine the best match, and returns the ID of the best candidate if it exceeds a certain threshold.

Example usage: $resolver = new SherdogIdResolver(); $searchHtml = $searchScraper->search($fighter->name); $candidates = $parser($searchHtml); $sherdogId = $resolver->resolve($fighter->name, $candidates); $fighter->sherdogId = $sherdogId;

Methods

int|null
resolve(string $name, array $candidates)

Resolves a Sherdog fighter ID from a list of candidates based on name similarity.

Details

int|null resolve(string $name, array $candidates)

Resolves a Sherdog fighter ID from a list of candidates based on name similarity.

Parameters

string $name

The name of the fighter to resolve.

array $candidates

An array of candidate fighters, where each candidate is an associative array with 'id' and 'name' keys.

Return Value

int|null

The resolved Sherdog ID if a good match is found, or null if no suitable match is found.