1 | <?php |
||
12 | abstract class TreeGen implements TreeGenerable |
||
13 | { |
||
14 | protected $groupBy; |
||
15 | protected $tree; |
||
16 | public $championship; |
||
17 | public $settings; |
||
18 | protected $numFighters; |
||
19 | |||
20 | abstract protected function generateAllTrees(); |
||
21 | |||
22 | abstract protected function generateFights(); |
||
23 | |||
24 | abstract protected function addFighterToGroup(FightersGroup $group, $fighter, $fighterToUpdate); |
||
25 | |||
26 | abstract protected function getByeGroup($fighters); |
||
27 | |||
28 | abstract protected function getNumRounds($fightersCount); |
||
29 | |||
30 | abstract protected function chunk(Collection $fightersByEntity); |
||
31 | |||
32 | abstract protected function syncGroup(FightersGroup $group, $fighters); |
||
33 | |||
34 | abstract protected function generateGroupsForRound(Collection $fightersByArea, $round); |
||
35 | |||
36 | /** |
||
37 | * @param Championship $championship |
||
38 | * @param $groupBy |
||
39 | */ |
||
40 | public function __construct(Championship $championship, $groupBy) |
||
47 | |||
48 | /** |
||
49 | * Generate tree groups for a championship. |
||
50 | * |
||
51 | * @throws TreeGenerationException |
||
52 | */ |
||
53 | public function run() |
||
59 | |||
60 | |||
61 | |||
62 | /** |
||
63 | * Get Competitor's list ordered by entities |
||
64 | * Countries for Internation Tournament, State for a National Tournament, etc. |
||
65 | * |
||
66 | * @param $fighters |
||
67 | * |
||
68 | * @return Collection |
||
69 | */ |
||
70 | private function getFightersByEntity($fighters): Collection |
||
82 | |||
83 | /** |
||
84 | * Get the size the first round will have. |
||
85 | * |
||
86 | * @param $fighterCount |
||
87 | * @param $groupSize |
||
88 | * |
||
89 | * @return int |
||
90 | */ |
||
91 | protected function getTreeSize($fighterCount, $groupSize) |
||
113 | |||
114 | |||
115 | |||
116 | /** |
||
117 | * @param $order |
||
118 | * @param $round |
||
119 | * @param $parent |
||
120 | * |
||
121 | * @return FightersGroup |
||
122 | */ |
||
123 | protected function saveGroup($order, $round, $parent): FightersGroup |
||
140 | |||
141 | /** |
||
142 | * @param int $groupSize |
||
143 | * |
||
144 | * @return Collection |
||
145 | */ |
||
146 | public function createByeGroup($groupSize): Collection |
||
156 | |||
157 | |||
158 | |||
159 | /** |
||
160 | * Get All Groups on previous round. |
||
161 | * |
||
162 | * @param $currentRound |
||
163 | * |
||
164 | * @return Collection |
||
165 | */ |
||
166 | private function getPreviousRound($currentRound) |
||
172 | |||
173 | /** |
||
174 | * Get the next group on the right ( parent ), final round being the ancestor. |
||
175 | * |
||
176 | * @param $matchNumber |
||
177 | * @param Collection $previousRound |
||
178 | * |
||
179 | * @return mixed |
||
180 | */ |
||
181 | private function getParentGroup($matchNumber, $previousRound) |
||
188 | |||
189 | /** |
||
190 | * Group Fighters by area. |
||
191 | * Here is where we fill with empty fighters |
||
192 | * |
||
193 | * @throws TreeGenerationException |
||
194 | * |
||
195 | * @return Collection |
||
196 | */ |
||
197 | protected function getFightersByArea() |
||
205 | |||
206 | /** |
||
207 | * Logically build the tree ( attach a parent to every child for nestedSet Navigation ) |
||
208 | * |
||
209 | * @param $numFighters |
||
210 | */ |
||
211 | protected function addParentToChildren($numFighters) |
||
230 | |||
231 | |||
232 | /** |
||
233 | * Destroy Previous Fights for demo. |
||
234 | */ |
||
235 | protected function destroyPreviousFights() |
||
243 | |||
244 | /** |
||
245 | * Generate Fights for next rounds. |
||
246 | */ |
||
247 | public function generateNextRoundsFights() |
||
256 | |||
257 | /** |
||
258 | * @param $groupsByRound |
||
259 | */ |
||
260 | protected function updateParentFight($groupsByRound) |
||
273 | |||
274 | /** |
||
275 | * @param $group |
||
276 | * @param $parentFight |
||
277 | */ |
||
278 | protected function chooseAndUpdateParentFight($keyGroup, FightersGroup $group, Fight $parentFight) |
||
295 | |||
296 | /** |
||
297 | * Calculate the area of the group ( group is still not created ). |
||
298 | * |
||
299 | * @param $round |
||
300 | * @param $order |
||
301 | * |
||
302 | * @return int |
||
303 | */ |
||
304 | protected function getNumArea($round, $order) |
||
315 | |||
316 | protected function generateAllFights() |
||
322 | } |
||
323 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.