Completed
Push — master ( a23f84...2e53d7 )
by Michael
04:05
created

Ballot::getRanking()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Michaelc\Voting\STV;
4
5
class Ballot
6
{
7
	/**
8
	 * Ranking of candidates ids
9
	 *
10
	 * @var array
11
	 */
12
	protected $ranking;
13
14
	/**
15
	 * The current weighting or value of this person's vote
16
	 *
17
	 * @var float
18
	 */
19
	protected $weight;
20
21
	/**
22
	 * The current preference in use from this ballot
23
	 *
24
	 * @var integer
25
	 */
26
	protected $levelUsed;
27
28
	/**
29
	 * Constructor
30
	 *
31
	 * @param array $ranking The ranking of candidates Key being ranking,
32
	 *                       value being a candidate id
33
	 */
34
	public function __construct(array $ranking)
35
	{
36
	    $this->weight = 1.0;
37
	    $this->ranking = $ranking;
38
	    $this->levelUsed = 0;
39
    }
40
41
    /**
42
     * Gets the Ranking of candidates ids.
43
     *
44
     * @return array
45
     */
46
    public function getRanking(): array
47
    {
48
        return $this->ranking;
49
    }
50
51
    /**
52
     * Sets the Ranking of candidates ids.
53
     *
54
     * @param array $ranking the ranking
55
     *
56
     * @return self
57
     */
58
    protected function setRanking(array $ranking)
59
    {
60
        $this->ranking = $ranking;
61
62
        return $this;
63
    }
64
65
    /**
66
     * Gets the The current weighting or value of this person's vote.
67
     *
68
     * @return float
69
     */
70
    public function getWeight(): float
71
    {
72
        return $this->weight;
73
    }
74
75
    /**
76
     * Sets the The current weighting or value of this person's vote.
77
     *
78
     * @param float $weight the weight
79
     *
80
     * @return self
81
     */
82
    protected function setWeight(float $weight)
83
    {
84
        $this->weight = $weight;
85
86
        return $this;
87
    }
88
89
    /**
90
     * Gets the the current preference in use from this ballot.
91
     *
92
     * @return integer
93
     */
94
    public function getLevelUsed(): int
95
    {
96
        return $this->levelUsed;
97
    }
98
99
    /**
100
     * Sets the the current preference in use from this ballot.
101
     *
102
     * @param integer $levelUsed
103
     *
104
     * @return self
105
     */
106
    protected function setLevelUsed(int $levelUsed)
107
    {
108
        $this->levelUsed = $levelUsed;
109
110
        return $this;
111
    }
112
}
113