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