@@ -16,20 +16,20 @@ |
||
16 | 16 | public $sumScore = 0; |
17 | 17 | |
18 | 18 | /** |
19 | - * ARRAY WITH GROUPS AND IT'S RESULTS |
|
20 | - * array ( |
|
21 | - * * groupId => array ( |
|
22 | - * * * "group" => Group, # GROUP OBJECT |
|
23 | - * * * "points" => int 0, # NUMBER OF POINTS AQUIRED |
|
24 | - * * * "score" => int 0, # SUM OF SCORE AQUIRED |
|
25 | - * * * "wins" => int 0, # NUMBER OF WINS |
|
26 | - * * * "draws" => int 0, # NUMBER OF DRAWS |
|
27 | - * * * "losses" => int 0, # NUMBER OF LOSSES |
|
28 | - * * * "second" => int 0, # NUMBER OF TIMES BEING SECOND (ONLY FOR INGAME OPTION OF 3 OR 4) |
|
29 | - * * * "third" => int 0 # NUMBER OF TIMES BEING THIRD (ONLY FOR INGAME OPTION OF 4) |
|
30 | - * * ) |
|
31 | - *) |
|
32 | - */ |
|
19 | + * ARRAY WITH GROUPS AND IT'S RESULTS |
|
20 | + * array ( |
|
21 | + * * groupId => array ( |
|
22 | + * * * "group" => Group, # GROUP OBJECT |
|
23 | + * * * "points" => int 0, # NUMBER OF POINTS AQUIRED |
|
24 | + * * * "score" => int 0, # SUM OF SCORE AQUIRED |
|
25 | + * * * "wins" => int 0, # NUMBER OF WINS |
|
26 | + * * * "draws" => int 0, # NUMBER OF DRAWS |
|
27 | + * * * "losses" => int 0, # NUMBER OF LOSSES |
|
28 | + * * * "second" => int 0, # NUMBER OF TIMES BEING SECOND (ONLY FOR INGAME OPTION OF 3 OR 4) |
|
29 | + * * * "third" => int 0 # NUMBER OF TIMES BEING THIRD (ONLY FOR INGAME OPTION OF 4) |
|
30 | + * * ) |
|
31 | + *) |
|
32 | + */ |
|
33 | 33 | public $groupResults = []; |
34 | 34 | |
35 | 35 | function __construct(string $name = 'team', $id = null) { |
@@ -18,19 +18,19 @@ discard block |
||
18 | 18 | { |
19 | 19 | |
20 | 20 | /** |
21 | - * @var array $ids Stores ids of groups get scores and points from |
|
22 | - */ |
|
21 | + * @var array $ids Stores ids of groups get scores and points from |
|
22 | + */ |
|
23 | 23 | protected static $ids = []; |
24 | 24 | |
25 | 25 | /** |
26 | - * Sort teams in group by defined ordering type |
|
27 | - * |
|
28 | - * @param array &$teams Array of teams to be sorted |
|
29 | - * @param \TournamentGenerator\Group $group Group to get the results from |
|
30 | - * @param string $ordering What to order by (\TournamentGenerator\Constants::POINTS / \TournamentGenerator\Constants::SCORE) |
|
31 | - * |
|
32 | - * @return array Sorted array of teams |
|
33 | - */ |
|
26 | + * Sort teams in group by defined ordering type |
|
27 | + * |
|
28 | + * @param array &$teams Array of teams to be sorted |
|
29 | + * @param \TournamentGenerator\Group $group Group to get the results from |
|
30 | + * @param string $ordering What to order by (\TournamentGenerator\Constants::POINTS / \TournamentGenerator\Constants::SCORE) |
|
31 | + * |
|
32 | + * @return array Sorted array of teams |
|
33 | + */ |
|
34 | 34 | public static function sortGroup(array &$teams, \TournamentGenerator\Group $group, string $ordering = \TournamentGenerator\Constants::POINTS) { |
35 | 35 | if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) throw new \Exception('Unknown ordering type `'.$ordering.'`'); |
36 | 36 | |
@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | - * Sort teams in round by defined ordering type |
|
53 | - * |
|
54 | - * @param array &$teams Array of teams to be sorted |
|
55 | - * @param \TournamentGenerator\Round $round Round to get the results from |
|
56 | - * @param string $ordering What to order by (\TournamentGenerator\Constants::POINTS / \TournamentGenerator\Constants::SCORE) |
|
57 | - * |
|
58 | - * @return array Sorted array of teams |
|
59 | - */ |
|
52 | + * Sort teams in round by defined ordering type |
|
53 | + * |
|
54 | + * @param array &$teams Array of teams to be sorted |
|
55 | + * @param \TournamentGenerator\Round $round Round to get the results from |
|
56 | + * @param string $ordering What to order by (\TournamentGenerator\Constants::POINTS / \TournamentGenerator\Constants::SCORE) |
|
57 | + * |
|
58 | + * @return array Sorted array of teams |
|
59 | + */ |
|
60 | 60 | public static function sortRound(array &$teams, \TournamentGenerator\Round $round, string $ordering = \TournamentGenerator\Constants::POINTS) { |
61 | 61 | if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) throw new \Exception('Unknown ordering type `'.$ordering.'`'); |
62 | 62 | |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
78 | - * Sorter function for uasort by points |
|
79 | - */ |
|
78 | + * Sorter function for uasort by points |
|
79 | + */ |
|
80 | 80 | private static function sortTeamsByPoints($a, $b) { |
81 | 81 | $groupsIds = self::$ids; |
82 | 82 | if ($a->sumPoints($groupsIds) === $b->sumPoints($groupsIds) && $a->sumScore($groupsIds) === $b->sumScore($groupsIds)) return 0; |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | return ($a->sumPoints($groupsIds) > $b->sumPoints($groupsIds) ? -1 : 1); |
85 | 85 | } |
86 | 86 | /** |
87 | - * Sorter function for uasort by score |
|
88 | - */ |
|
87 | + * Sorter function for uasort by score |
|
88 | + */ |
|
89 | 89 | private static function sortTeamsByScore($a, $b) { |
90 | 90 | $groupsIds = self::$ids; |
91 | 91 | if ($a->sumScore($groupsIds) === $b->sumScore($groupsIds)) return 0; |
@@ -80,10 +80,10 @@ |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | - * $results = array ( |
|
84 | - * * team->getId() => team->score |
|
85 | - * ) |
|
86 | - */ |
|
83 | + * $results = array ( |
|
84 | + * * team->getId() => team->score |
|
85 | + * ) |
|
86 | + */ |
|
87 | 87 | public function setResults(array $results = []) { |
88 | 88 | if (count($this->results) === 0) $this->resetResults(); |
89 | 89 | arsort($results); |