BasicUsageBench   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 59
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
B benchSimpleManyVotes() 0 50 5
1
<?php
2
declare(strict_types=1);
3
4
namespace CondorcetPHP\Condorcet\Benchmarks;
5
6
use CondorcetPHP\Condorcet\Condorcet;
7
use CondorcetPHP\Condorcet\Election;
8
use CondorcetPHP\Condorcet\Candidate;
9
use CondorcetPHP\Condorcet\CondorcetUtil;
10
use CondorcetPHP\Condorcet\Vote;
11
12
13
class BasicUsageBench
14
{
15
    /**
16
     * @Iterations(2)
17
     * @Warmup(1)
18
     * @Revs(4)
19
     */
20
    public function benchSimpleManyVotes () : void
21
    {
22
       $election = new Election;
23
       $election->allowVoteWeight(true);
24
25
       $election->parseCandidates('A;B;C;D;E;F');
26
27
       $election->parseVotes('
28
       		Ultimate Question of Life || A>B>C ^42 * 42
29
          C=A>B ^2 * 200
30
          B>C
31
          E > B > C > A ^80 *50
32
          F > B > G > H > A* 250
33
          D = B = E > F ^6 * 48
34
       ');
35
36
       $election->getWinner();
37
       $election->getLoser();
38
39
       foreach (Condorcet::getAuthMethods() as $method) :
40
         $election->getResult($method);
41
       endforeach;
42
43
       $election->setImplicitRanking(false);
44
45
       foreach (Condorcet::getAuthMethods() as $method) :
46
         $election->getResult($method);
47
       endforeach;
48
49
       $election->allowVoteWeight(false);
50
51
       foreach (Condorcet::getAuthMethods() as $method) :
52
         $election->getResult($method);
53
       endforeach;
54
55
       $election->parseVotes('
56
          Ultimate Question of Life || C>B>A ^42 * 42
57
          C=A=B ^2 * 200
58
          B>C
59
          A > C >E ^80 *50
60
          G > B > G > H > F* 250
61
          C = B = E > A ^6 * 48
62
       ');
63
64
       foreach (Condorcet::getAuthMethods() as $method) :
65
         $election->getResult($method);
66
       endforeach;
67
68
       $votes = $election->getVotesListAsString();
0 ignored issues
show
Unused Code introduced by
$votes is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
69
    }
70
71
}