/** * Execute the console command. * * @return mixed */ public function handle() { $election = new Election(); $candidates = [1 => new Candidate('Bjørnar Moxnes'), 2 => new Candidate('Kari Elisabeth Kaski'), 3 => new Candidate('Lan Marie Nguyen Berg'), 4 => new Candidate('Abid Raja'), 5 => new Candidate('Per Sandberg')]; foreach ($candidates as $candidate) { $election->addCandidate($candidate); } $votes = [[$candidates[1], $candidates[3], $candidates[2]], [$candidates[1], $candidates[3], $candidates[4]], [$candidates[1], $candidates[2], $candidates[4]], [$candidates[1], $candidates[2]], [$candidates[1], $candidates[2], $candidates[4]], [$candidates[5]], [$candidates[1], $candidates[2], $candidates[5]], [$candidates[1], $candidates[5]], [$candidates[1]], [$candidates[1]], [$candidates[2], $candidates[1], $candidates[3], $candidates[4]], [$candidates[2], $candidates[3], $candidates[4], $candidates[1], $candidates[5]], [$candidates[5], $candidates[4], $candidates[3]]]; foreach ($votes as $vote) { $election->addVote($vote); } $result = $election->getResult('RankedPairs'); Condorcet::format($result); }
<br><br><hr> <h2>Debug Data :</h2> <h4>Defaut method (not used explicitly before) :</h4> <pre> <?php Condorcet::format(Condorcet::getDefaultMethod()); ?> </pre> <h4>About object :</h4> <pre> <?php Condorcet::format($election->getConfig()); ?> </pre> <!-- <h4>Condorcet::format (for debug only) :</h4> <pre> <?php // Condorcet::format($election); ?> </pre> --> </body> </html>
public function getLoser() { Condorcet::format($this[count($this)], false, false); }