majority judgment library php
1.0.0
故意多數判決民意調查。
使用作曲家在自己的項目中需要它:
composer require mieuxvoter/majority-judgment
使用它:
use MieuxVoter MajorityJudgment MajorityJudgmentDeliberator ;
use MieuxVoter MajorityJudgment Model Settings MajorityJudgmentSettings ;
use MieuxVoter MajorityJudgment Model Tally ArrayPollTally ;
$ tally = new ArrayPollTally ([
' Proposal A ' => [ 1 , 1 , 4 , 3 , 7 , 4 , 1 ], // amount of judgments for each grade
' Proposal B ' => [ 0 , 2 , 4 , 6 , 4 , 2 , 3 ], // (worst grade to best grade)
]);
$ deliberator = new MajorityJudgmentDeliberator ();
$ result = $ deliberator -> deliberate ( $ tally );
// $result is a PollResultInterface
foreach ( $ result -> getProposalResults () as $ proposalResult ) {
// … Do something
print ( $ proposalResult -> getProposal ());
print ( $ proposalResult -> getRank ());
}任何實現PollTallyInterface的對像都可以用作輸入。
請參閱test/中的測試。
composer install --dev
vendor/phpunit/phpunit/phpunit -v test