1 | <?php |
||
5 | class Election |
||
6 | { |
||
7 | /** |
||
8 | * Count of candidates in election. |
||
9 | * |
||
10 | * @var int |
||
11 | */ |
||
12 | protected $candidateCount; |
||
13 | |||
14 | /** |
||
15 | * Count of number of seats/winners. |
||
16 | * |
||
17 | * @var int |
||
18 | */ |
||
19 | protected $winnersCount; |
||
20 | |||
21 | /** |
||
22 | * Array of candidates competing in election. |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $candidates; |
||
27 | |||
28 | /** |
||
29 | * Array of ballots cast in election. |
||
30 | * |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $ballots; |
||
34 | |||
35 | /** |
||
36 | * Constructor. |
||
37 | * |
||
38 | * @param int $winnersCount Number of winners to allocate |
||
39 | * @param array $candidates Array of candidates competing |
||
40 | * @param array $ballots Array of all ballots cast in election |
||
41 | */ |
||
42 | 5 | public function __construct(int $winnersCount, array $candidates, array $ballots) |
|
49 | |||
50 | /** |
||
51 | * Get a specific candidate object by their ID. |
||
52 | * |
||
53 | * @param int $id ID of the candidate to get |
||
54 | * |
||
55 | * @return \Michaelc\Voting\STV\Candidate |
||
56 | */ |
||
57 | 1 | public function getCandidate(int $id): Candidate |
|
61 | |||
62 | /** |
||
63 | * Get a count of candidates competing. |
||
64 | * |
||
65 | * @return int |
||
66 | */ |
||
67 | 3 | public function getCandidateCount(): int |
|
71 | |||
72 | /** |
||
73 | * Get an array of candidates still running (not elected or defeated). |
||
74 | * |
||
75 | * @return \Michaelc\Voting\STV\Candidate[] |
||
76 | */ |
||
77 | 2 | public function getActiveCandidates(): array |
|
81 | |||
82 | public function getActiveCandidateIds(): array |
||
92 | |||
93 | /** |
||
94 | * Get an array of candidates elected. |
||
95 | * |
||
96 | * @return \Michaelc\Voting\STV\Candidate[] |
||
97 | */ |
||
98 | 1 | public function getElectedCandidates(): array |
|
102 | |||
103 | /** |
||
104 | * Get an array of candidates defeated. |
||
105 | * |
||
106 | * @return \Michaelc\Voting\STV\Candidate[] |
||
107 | */ |
||
108 | 1 | public function getDefeatedCandidates(): array |
|
112 | |||
113 | /** |
||
114 | * Get all candidates of a specific state. |
||
115 | * |
||
116 | * @param int $state A candidate state (See Candidate constants) |
||
117 | * |
||
118 | * @return \Michaelc\Voting\STV\Candidate[] |
||
119 | */ |
||
120 | 2 | public function getStateCandidates(int $state): array |
|
132 | |||
133 | /** |
||
134 | * Get a count of candidates still running (not elected or defeated). |
||
135 | * |
||
136 | * @return int |
||
137 | */ |
||
138 | 1 | public function getActiveCandidateCount(): int |
|
142 | |||
143 | /** |
||
144 | * Get an array of candidate ids. |
||
145 | * |
||
146 | * @return int[] |
||
147 | */ |
||
148 | 2 | public function getCandidateIds(): array |
|
158 | |||
159 | /** |
||
160 | * Gets the value of winnersCount. |
||
161 | * |
||
162 | * @return int |
||
163 | */ |
||
164 | 1 | public function getWinnersCount(): int |
|
168 | |||
169 | /** |
||
170 | * Gets the value of candidates. |
||
171 | * |
||
172 | * @return array |
||
173 | */ |
||
174 | 2 | public function getCandidates(): array |
|
178 | |||
179 | /** |
||
180 | * Gets the value of ballots. |
||
181 | * |
||
182 | * @return array |
||
183 | */ |
||
184 | 2 | public function getBallots(): array |
|
188 | |||
189 | /** |
||
190 | * Get the number of ballots. |
||
191 | * |
||
192 | * @return int |
||
193 | */ |
||
194 | 3 | public function getNumBallots(): int |
|
198 | |||
199 | /** |
||
200 | * Get status of all candidates. |
||
201 | * |
||
202 | * @return array |
||
203 | */ |
||
204 | public function getCandidatesStatus(): array |
||
222 | } |
||
223 |