PHP code example of austinw / selection-procedures
1. Go to this page and download the library: Download austinw/selection-procedures library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
austinw / selection-procedures example snippets
use AustinW\SelectionProcedures\RankingService;
use Illuminate\Support\Collection;
// Get your results collection (must implement ResultContract)
$results = new Collection([/* your result objects */]);
// Inject or resolve the ranking service
$rankingService = app(RankingService::class);
// Get ranked athletes
$rankedAthletes = $rankingService->rank(
'world_championships', // procedure key as defined in config
'trampoline', // apparatus
'senior_elite', // division
$results // collection of results
);
// Process ranked athletes
foreach ($rankedAthletes as $rankedAthlete) {
echo $rankedAthlete->getAthlete()->getName() . ': ' . $rankedAthlete->getTotalPoints();
}
use AustinW\SelectionProcedures\Contracts\AthleteContract;
use AustinW\SelectionProcedures\Contracts\ResultContract;
class Athlete implements AthleteContract
{
// Implement class Result implements ResultContract
{
// Implement e(): float
{
// Return the score
}
// Additional
use AustinW\SelectionProcedures\Contracts\ProcedureCalculatorContract;
class MyCustomCalculator implements ProcedureCalculatorContract
{
public function calculateRanking(string $apparatus, string $division, Collection $results, array $config): Collection
{
// Your custom ranking logic here
return new Collection([/* ranked athletes */]);
}
}