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

SchulzeRatio   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 11
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A schulzeVariant() 0 5 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