PHP code example of astronati / fantasy-football-calculator

1. Go to this page and download the library: Download astronati/fantasy-football-calculator 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/ */

    

astronati / fantasy-football-calculator example snippets


// Prepare formation
$formation = new Formation();
$formation->addFirstString(new Footballer())...

// Configure calculator
$configuration = new Configuration();
$configuration
  ->addRule(RuleFactory::create(RuleFactory::BEST_DEFENDERS_RULE))
  ->addRule(RuleFactory::create(RuleFactory::HOME_RULE))
;
$calculator = new Calculator($quotations, $configuration);

// Show match results...
$matchResult = $calculator->getMatchResult($formationA, $formationB);
$homeResult = $matchResult->getHomeResult();
echo '(' . $homeResult->getMagicPoints() . ' ' . $homeResult->getBonus() . ') '. $matchResult->getHomeGoals();

// Show single result...
$singleResult = $calculator->getSingleResult($formation);
echo $singleResult->getMagicPoints() . ' ' . $singleResult->getBonus();