Completed
Branch dev-2.0 (210bc7)
by Boudry
06:33
created

SchulzeRatio::schulzeVariant()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 8
rs 10
c 0
b 0
f 0
ccs 3
cts 4
cp 0.75
crap 2.0625
1
<?php
2
/*
3
    Part of SCHULZE method Module - From the original Condorcet PHP
4
5
    Condorcet PHP - Election manager and results calculator.
6
    Designed for the Condorcet method. Integrating a large number of algorithms extending Condorcet. Expandable for all types of voting systems.
7
8
    By Julien Boudry and contributors - MIT LICENSE (Please read LICENSE.txt)
9
    https://github.com/julien-boudry/Condorcet
10
*/
11
declare(strict_types=1);
12
13
namespace CondorcetPHP\Condorcet\Algo\Methods;
14
15
16
class SchulzeRatio extends Schulze_Core
17
{
18
    // Method Name
19
    public const METHOD_NAME = ['Schulze Ratio','SchulzeRatio','Schulze_Ratio'];
20
21 2
    protected function schulzeVariant (int &$i, int &$j) : float
22
    {
23 2
        if ($this->_selfElection->getPairwise()[$j]['win'][$i] !== 0) :
24 2
            return (float) $this->_selfElection->getPairwise()[$i]['win'][$j] / $this->_selfElection->getPairwise()[$j]['win'][$i];
25
        else :
26
            return (float) 0;
27
        endif;
28
    }
29
}
30