1 | <?php |
||
7 | class Election |
||
8 | { |
||
9 | /** |
||
10 | * Count of candidates in election |
||
11 | * |
||
12 | * @var int |
||
13 | */ |
||
14 | protected $candidateCount; |
||
15 | |||
16 | /** |
||
17 | * Count of number of seats/winners |
||
18 | * |
||
19 | * @var int |
||
20 | */ |
||
21 | protected $winnersCount; |
||
22 | |||
23 | /** |
||
24 | * Array of candidates competing in election |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $candidates; |
||
29 | |||
30 | /** |
||
31 | * Array of ballots cast in election |
||
32 | * |
||
33 | * @var array |
||
34 | */ |
||
35 | protected $ballots; |
||
36 | |||
37 | /** |
||
38 | * Constructor |
||
39 | * |
||
40 | * @param int $winnersCount Number of winners to allocate |
||
41 | * @param array $candidates Array of candidates competing |
||
42 | * @param array $ballots Array of all ballots cast in election |
||
43 | */ |
||
44 | 2 | public function __construct(int $winnersCount, array $candidates, array $ballots) |
|
51 | |||
52 | /** |
||
53 | * Get a specific candidate object by their ID |
||
54 | * |
||
55 | * @param int $id ID of the candidate to get |
||
56 | * @return \Michaelc\Voting\STV\Candidate |
||
57 | */ |
||
58 | 1 | public function getCandidate(int $id): Candidate |
|
62 | |||
63 | /** |
||
64 | * Get a count of candidates competing |
||
65 | * |
||
66 | * @return int |
||
67 | */ |
||
68 | 1 | public function getCandidateCount(): int |
|
72 | |||
73 | /** |
||
74 | * Get an array of candidates still running (not elected or defeated) |
||
75 | * |
||
76 | * @return \Michaelc\Voting\STV\Candidate[] |
||
77 | */ |
||
78 | 1 | public function getActiveCandidates(): array |
|
82 | |||
83 | /** |
||
84 | * Get an array of candidates elected |
||
85 | * |
||
86 | * @return \Michaelc\Voting\STV\Candidate[] |
||
87 | */ |
||
88 | public function getElectedCandidates(): array |
||
92 | |||
93 | /** |
||
94 | * Get all candidates of a specific state |
||
95 | * |
||
96 | * @param int $state A candidate state (See Candidate constants) |
||
97 | * @return \Michaelc\Voting\STV\Candidate[] |
||
98 | */ |
||
99 | 1 | public function getStateCandidates(int $state): array |
|
113 | |||
114 | /** |
||
115 | * Get a count of candidates still running (not elected or defeated) |
||
116 | * |
||
117 | * @return int |
||
118 | */ |
||
119 | 1 | public function getActiveCandidateCount(): int |
|
123 | |||
124 | /** |
||
125 | * Gets the value of winnersCount. |
||
126 | * |
||
127 | * @return int |
||
128 | */ |
||
129 | 2 | public function getWinnersCount(): int |
|
133 | |||
134 | /** |
||
135 | * Gets the value of candidates. |
||
136 | * |
||
137 | * @return array |
||
138 | */ |
||
139 | public function getCandidates(): array |
||
143 | |||
144 | /** |
||
145 | * Gets the value of ballots. |
||
146 | * |
||
147 | * @return array |
||
148 | */ |
||
149 | 1 | public function getBallots(): array |
|
153 | |||
154 | /** |
||
155 | * Get the number of ballots |
||
156 | * |
||
157 | * @return int |
||
158 | */ |
||
159 | 2 | public function getNumBallots(): int |
|
163 | } |
||
164 |