Passed
Branch master (73ca69)
by Boudry
03:33
created

SchulzeRatio::schulzeVariant()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 2
crap 2
1
<?php
2
/*
3
    Schulze part of the Condorcet PHP Class
4
5
    By Julien Boudry - MIT LICENSE (Please read LICENSE.txt)
6
    https://github.com/julien-boudry/Condorcet
7
*/
8
declare(strict_types=1);
9
10
namespace Condorcet\Algo\Methods;
11
12
use Condorcet\Algo\Methods\Schulze_Core;
13
use Condorcet\CondorcetException;
14
15
class SchulzeRatio extends Schulze_Core
16
{
17
    // Method Name
18
    public const METHOD_NAME = ['Schulze Ratio','SchulzeRatio','Schulze_Ratio'];
19
20 1
    protected function schulzeVariant (int &$i, int &$j) : float {
21 1
        return (float) ($this->_selfElection->getPairwise(false)[$j]['win'][$i] !== 0) ?
22 1
            ($this->_selfElection->getPairwise(false)[$i]['win'][$j] / $this->_selfElection->getPairwise(false)[$j]['win'][$i]) :
23 1
                0;
24
    }
25
}
26