@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
| 126 | - * @return Player[]|Collection |
|
| 126 | + * @return Collection |
|
| 127 | 127 | */ |
| 128 | 128 | public function getPlayersA() |
| 129 | 129 | { |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
| 134 | - * @return Player[]|Collection |
|
| 134 | + * @return Collection |
|
| 135 | 135 | */ |
| 136 | 136 | public function getPlayersB() |
| 137 | 137 | { |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | /** |
| 4 | 4 | * Created by PhpStorm. |
| 5 | 5 | * User: benedikt |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @param int $gameNumber |
| 143 | 143 | * @return $this|Game |
| 144 | 144 | */ |
| 145 | - public function setGameNumber(int $gameNumber): Game |
|
| 145 | + public function setGameNumber( int $gameNumber ): Game |
|
| 146 | 146 | { |
| 147 | 147 | $this->gameNumber = $gameNumber; |
| 148 | 148 | return $this; |
@@ -152,9 +152,9 @@ discard block |
||
| 152 | 152 | * @param Match $match |
| 153 | 153 | * @return $this|Game |
| 154 | 154 | */ |
| 155 | - public function setMatch(Match $match): Game |
|
| 155 | + public function setMatch( Match $match ): Game |
|
| 156 | 156 | { |
| 157 | - if ($this->match !== null) { |
|
| 157 | + if ( $this->match !== null ) { |
|
| 158 | 158 | $this->match->getGames()->remove($this->getGameNumber()); |
| 159 | 159 | } |
| 160 | 160 | $this->match = $match; |
@@ -115,7 +115,7 @@ |
||
| 115 | 115 | //<editor-fold desc="Private Methods"> |
| 116 | 116 | /** |
| 117 | 117 | * @param RankingSystemChange[] $changes |
| 118 | - * @param Collection|Player[] $players |
|
| 118 | + * @param Collection $players |
|
| 119 | 119 | * @param TournamentHierarchyEntity $entity |
| 120 | 120 | * @param \Tfboe\FmLib\Entity\RankingSystem $ranking |
| 121 | 121 | */ |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | /** |
| 4 | 4 | * Created by PhpStorm. |
| 5 | 5 | * User: benedikt |
@@ -52,14 +52,14 @@ discard block |
||
| 52 | 52 | /** |
| 53 | 53 | * @inheritDoc |
| 54 | 54 | */ |
| 55 | - protected function getChanges(TournamentHierarchyEntity $entity, RankingSystemList $list): array |
|
| 55 | + protected function getChanges( TournamentHierarchyEntity $entity, RankingSystemList $list ): array |
|
| 56 | 56 | { |
| 57 | 57 | /** @var Game $game */ |
| 58 | 58 | $game = $entity; |
| 59 | 59 | $changes = []; |
| 60 | 60 | |
| 61 | - if (!$game->isPlayed() || $game->getResult() === Result::NOT_YET_FINISHED || |
|
| 62 | - $game->getResult() === Result::NULLED) { |
|
| 61 | + if ( !$game->isPlayed() || $game->getResult() === Result::NOT_YET_FINISHED || |
|
| 62 | + $game->getResult() === Result::NULLED ) { |
|
| 63 | 63 | //game gets not elo rated |
| 64 | 64 | $this->addNotRatedChanges($changes, $game->getPlayersA(), $entity, $list->getRankingSystem()); |
| 65 | 65 | $this->addNotRatedChanges($changes, $game->getPlayersB(), $entity, $list->getRankingSystem()); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | $resultA = 0.0; |
| 82 | 82 | |
| 83 | - switch ($game->getResult()) { |
|
| 83 | + switch ( $game->getResult() ) { |
|
| 84 | 84 | case Result::TEAM_A_WINS: |
| 85 | 85 | $resultA = 1.0; |
| 86 | 86 | break; |
@@ -119,10 +119,10 @@ discard block |
||
| 119 | 119 | * @param TournamentHierarchyEntity $entity |
| 120 | 120 | * @param \Tfboe\FmLib\Entity\RankingSystem $ranking |
| 121 | 121 | */ |
| 122 | - private function addNotRatedChanges(array &$changes, Collection $players, TournamentHierarchyEntity $entity, |
|
| 123 | - RankingSystem $ranking) |
|
| 122 | + private function addNotRatedChanges( array &$changes, Collection $players, TournamentHierarchyEntity $entity, |
|
| 123 | + RankingSystem $ranking ) |
|
| 124 | 124 | { |
| 125 | - foreach ($players as $player) { |
|
| 125 | + foreach ( $players as $player ) { |
|
| 126 | 126 | $change = $this->getOrCreateChange($entity, $ranking, $player); |
| 127 | 127 | $change->setPointsChange(0.0); |
| 128 | 128 | $change->setPlayedGames(0); |
@@ -144,24 +144,24 @@ discard block |
||
| 144 | 144 | * @param bool $teamHasProvisory |
| 145 | 145 | * @param bool $opponentHasProvisory |
| 146 | 146 | */ |
| 147 | - private function computeChanges(array &$changes, array $entries, float $result, float $expectationDiff, Game $game, |
|
| 147 | + private function computeChanges( array &$changes, array $entries, float $result, float $expectationDiff, Game $game, |
|
| 148 | 148 | float $teamAverage, float $opponentAverage, bool $teamHasProvisory, |
| 149 | - bool $opponentHasProvisory) |
|
| 149 | + bool $opponentHasProvisory ) |
|
| 150 | 150 | { |
| 151 | - foreach ($entries as $entry) { |
|
| 151 | + foreach ( $entries as $entry ) { |
|
| 152 | 152 | $change = $this->getOrCreateChange($game, $entry->getRankingSystemList()->getRankingSystem(), |
| 153 | 153 | $entry->getPlayer()); |
| 154 | 154 | $change->setPlayedGames(1); |
| 155 | 155 | $factor = 2 * $result - 1; |
| 156 | - if ($entry->getPlayedGames() < self::NUM_PROVISORY_GAMES) { |
|
| 156 | + if ( $entry->getPlayedGames() < self::NUM_PROVISORY_GAMES ) { |
|
| 157 | 157 | //provisory entry => recalculate |
| 158 | - if (count($entries) > 1) { |
|
| 158 | + if ( count($entries) > 1 ) { |
|
| 159 | 159 | $teamMatesAverage = ($teamAverage * count($entries) - $entry->getProvisoryRanking()) / |
| 160 | 160 | (count($entries) - 1); |
| 161 | - if ($teamMatesAverage > $opponentAverage + self::MAX_DIFF_TO_OPPONENT_FOR_PROVISORY) { |
|
| 161 | + if ( $teamMatesAverage > $opponentAverage + self::MAX_DIFF_TO_OPPONENT_FOR_PROVISORY ) { |
|
| 162 | 162 | $teamMatesAverage = $opponentAverage + self::MAX_DIFF_TO_OPPONENT_FOR_PROVISORY; |
| 163 | 163 | } |
| 164 | - if ($teamMatesAverage < $opponentAverage - self::MAX_DIFF_TO_OPPONENT_FOR_PROVISORY) { |
|
| 164 | + if ( $teamMatesAverage < $opponentAverage - self::MAX_DIFF_TO_OPPONENT_FOR_PROVISORY ) { |
|
| 165 | 165 | $teamMatesAverage = $opponentAverage - self::MAX_DIFF_TO_OPPONENT_FOR_PROVISORY; |
| 166 | 166 | } |
| 167 | 167 | $performance = $opponentAverage * (1 + self::PROVISORY_PARTNER_FACTOR) - |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | } else { |
| 170 | 170 | $performance = $opponentAverage; |
| 171 | 171 | } |
| 172 | - if ($performance < self::START) { |
|
| 172 | + if ( $performance < self::START ) { |
|
| 173 | 173 | $performance = self::START; |
| 174 | 174 | } |
| 175 | 175 | $performance += self::EXP_DIFF * $factor; |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | $change->setProvisoryRanking(($performance - $entry->getProvisoryRanking()) / ($entry->getRatedGames() + 1)); |
| 183 | 183 | $change->setPointsChange(0.0); |
| 184 | 184 | $change->setRatedGames(1); |
| 185 | - } else if (!$teamHasProvisory && !$opponentHasProvisory) { |
|
| 185 | + } else if ( !$teamHasProvisory && !$opponentHasProvisory ) { |
|
| 186 | 186 | //real elo ranking |
| 187 | 187 | $change->setProvisoryRanking(0.0); |
| 188 | 188 | $change->setPointsChange(self::K * $expectationDiff); |
@@ -202,10 +202,10 @@ discard block |
||
| 202 | 202 | * @param RankingSystemListEntry[] $entries must be nonempty |
| 203 | 203 | * @return float |
| 204 | 204 | */ |
| 205 | - private function getEloAverage(array $entries): float |
|
| 205 | + private function getEloAverage( array $entries ): float |
|
| 206 | 206 | { |
| 207 | 207 | $sum = 0; |
| 208 | - foreach ($entries as $entry) { |
|
| 208 | + foreach ( $entries as $entry ) { |
|
| 209 | 209 | $sum += $entry->getRatedGames() < self::NUM_PROVISORY_GAMES ? $entry->getProvisoryRanking() : $entry->getPoints(); |
| 210 | 210 | } |
| 211 | 211 | return $sum / count($entries); |
@@ -216,10 +216,10 @@ discard block |
||
| 216 | 216 | * @param RankingSystemListEntry[] $entries |
| 217 | 217 | * @return bool |
| 218 | 218 | */ |
| 219 | - private function hasProvisoryEntry(array $entries): bool |
|
| 219 | + private function hasProvisoryEntry( array $entries ): bool |
|
| 220 | 220 | { |
| 221 | - foreach ($entries as $entry) { |
|
| 222 | - if ($entry->getPlayedGames() < self::NUM_PROVISORY_GAMES) { |
|
| 221 | + foreach ( $entries as $entry ) { |
|
| 222 | + if ( $entry->getPlayedGames() < self::NUM_PROVISORY_GAMES ) { |
|
| 223 | 223 | return true; |
| 224 | 224 | } |
| 225 | 225 | } |
@@ -206,7 +206,7 @@ |
||
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
| 209 | - * @param Collection|Player[] $players |
|
| 209 | + * @param Collection $players |
|
| 210 | 210 | * @param RankingSystemList $list |
| 211 | 211 | * @return RankingSystemListEntry[] $entries |
| 212 | 212 | */ |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | /** |
| 4 | 4 | * Created by PhpStorm. |
| 5 | 5 | * User: benedikt |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | * @param TimeServiceInterface $timeService |
| 67 | 67 | * @param EntityComparerInterface $entityComparer |
| 68 | 68 | */ |
| 69 | - public function __construct(EntityManagerInterface $entityManager, TimeServiceInterface $timeService, |
|
| 70 | - EntityComparerInterface $entityComparer) |
|
| 69 | + public function __construct( EntityManagerInterface $entityManager, TimeServiceInterface $timeService, |
|
| 70 | + EntityComparerInterface $entityComparer ) |
|
| 71 | 71 | { |
| 72 | 72 | $this->entityManager = $entityManager; |
| 73 | 73 | $this->timeService = $timeService; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | /** |
| 83 | 83 | * @inheritDoc |
| 84 | 84 | */ |
| 85 | - public function getEarliestInfluence(RankingSystem $ranking, Tournament $tournament): ?\DateTime |
|
| 85 | + public function getEarliestInfluence( RankingSystem $ranking, Tournament $tournament ): ?\DateTime |
|
| 86 | 86 | { |
| 87 | 87 | return $this->getEarliestEntityInfluence($ranking, $tournament, false); |
| 88 | 88 | } |
@@ -90,15 +90,15 @@ discard block |
||
| 90 | 90 | /** |
| 91 | 91 | * @inheritdoc |
| 92 | 92 | */ |
| 93 | - public function updateRankingForTournament(RankingSystem $ranking, Tournament $tournament, |
|
| 94 | - ?\DateTime $oldInfluence) |
|
| 93 | + public function updateRankingForTournament( RankingSystem $ranking, Tournament $tournament, |
|
| 94 | + ?\DateTime $oldInfluence ) |
|
| 95 | 95 | { |
| 96 | 96 | $earliestInfluence = $this->getEarliestInfluence($ranking, $tournament); |
| 97 | - if ($oldInfluence !== null && |
|
| 98 | - ($earliestInfluence === null || $oldInfluence < $earliestInfluence)) { |
|
| 97 | + if ( $oldInfluence !== null && |
|
| 98 | + ($earliestInfluence === null || $oldInfluence < $earliestInfluence) ) { |
|
| 99 | 99 | $earliestInfluence = $oldInfluence; |
| 100 | 100 | } |
| 101 | - if ($earliestInfluence !== null) { |
|
| 101 | + if ( $earliestInfluence !== null ) { |
|
| 102 | 102 | $this->updateRankingFrom($ranking, $earliestInfluence); |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -106,10 +106,10 @@ discard block |
||
| 106 | 106 | /** |
| 107 | 107 | * @inheritDoc |
| 108 | 108 | */ |
| 109 | - public function updateRankingFrom(RankingSystem $ranking, \DateTime $from) |
|
| 109 | + public function updateRankingFrom( RankingSystem $ranking, \DateTime $from ) |
|
| 110 | 110 | { |
| 111 | 111 | // can only be called once per ranking system!!! |
| 112 | - if (array_key_exists($ranking->getId(), $this->updateRankingCalls)) { |
|
| 112 | + if ( array_key_exists($ranking->getId(), $this->updateRankingCalls) ) { |
|
| 113 | 113 | throw new PreconditionFailedException(); |
| 114 | 114 | } |
| 115 | 115 | $this->updateRankingCalls[$ranking->getId()] = $ranking; |
@@ -122,40 +122,40 @@ discard block |
||
| 122 | 122 | $lastReusable = null; |
| 123 | 123 | $toUpdate = []; |
| 124 | 124 | |
| 125 | - foreach ($lists as $list) { |
|
| 126 | - if ($list->isCurrent()) { |
|
| 125 | + foreach ( $lists as $list ) { |
|
| 126 | + if ( $list->isCurrent() ) { |
|
| 127 | 127 | $current = $list; |
| 128 | - } else if ($list->getLastEntryTime() >= $from) { |
|
| 128 | + } else if ( $list->getLastEntryTime() >= $from ) { |
|
| 129 | 129 | $toUpdate[] = $list; |
| 130 | - } else if ($lastReusable === null || $list->getLastEntryTime() > $lastReusable->getLastEntryTime()) { |
|
| 130 | + } else if ( $lastReusable === null || $list->getLastEntryTime() > $lastReusable->getLastEntryTime() ) { |
|
| 131 | 131 | $lastReusable = $list; |
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - if ($lastReusable === null) { |
|
| 135 | + if ( $lastReusable === null ) { |
|
| 136 | 136 | $lastReusable = new RankingSystemList(); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - usort($toUpdate, function (RankingSystemList $list1, RankingSystemList $list2) { |
|
| 139 | + usort($toUpdate, function( RankingSystemList $list1, RankingSystemList $list2 ) { |
|
| 140 | 140 | return $list1->getLastEntryTime() <=> $list2->getLastEntryTime(); |
| 141 | 141 | }); |
| 142 | 142 | |
| 143 | 143 | $entities = $this->getEntities($ranking, $lastReusable->getLastEntryTime()); |
| 144 | 144 | //sort entities |
| 145 | 145 | $this->timeService->clearTimes(); |
| 146 | - usort($entities, function ($entity1, $entity2) { |
|
| 146 | + usort($entities, function( $entity1, $entity2 ) { |
|
| 147 | 147 | return $this->entityComparer->compareEntities($entity1, $entity2); |
| 148 | 148 | }); |
| 149 | 149 | |
| 150 | 150 | $this->deleteOldChanges($ranking, $entities); |
| 151 | 151 | |
| 152 | 152 | $nextEntityIndex = 0; |
| 153 | - foreach ($toUpdate as $list) { |
|
| 153 | + foreach ( $toUpdate as $list ) { |
|
| 154 | 154 | $this->recomputeBasedOn($list, $lastReusable, $entities, $nextEntityIndex); |
| 155 | 155 | $lastReusable = $list; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - if ($current === null) { |
|
| 158 | + if ( $current === null ) { |
|
| 159 | 159 | $current = new RankingSystemList(); |
| 160 | 160 | $current->setCurrent(true); |
| 161 | 161 | $this->entityManager->persist($current); |
@@ -171,13 +171,13 @@ discard block |
||
| 171 | 171 | * @param RankingSystemListEntry[] $entries |
| 172 | 172 | * @return float |
| 173 | 173 | */ |
| 174 | - protected final function getAverage(array $entries): float |
|
| 174 | + protected final function getAverage( array $entries ): float |
|
| 175 | 175 | { |
| 176 | 176 | $sum = 0.0; |
| 177 | - foreach ($entries as $entry) { |
|
| 177 | + foreach ( $entries as $entry ) { |
|
| 178 | 178 | $sum += $entry->getPoints(); |
| 179 | 179 | } |
| 180 | - if (count($entries) === 0) { |
|
| 180 | + if ( count($entries) === 0 ) { |
|
| 181 | 181 | return 0.0; |
| 182 | 182 | } else { |
| 183 | 183 | return $sum / count($entries); |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * time value exactly $from |
| 192 | 192 | * @return TournamentHierarchyEntity[] |
| 193 | 193 | */ |
| 194 | - protected final function getEntities(RankingSystem $ranking, \DateTime $from): array |
|
| 194 | + protected final function getEntities( RankingSystem $ranking, \DateTime $from ): array |
|
| 195 | 195 | { |
| 196 | 196 | $query = $this->getEntitiesQueryBuilder($ranking, $from); |
| 197 | 197 | return $query->getQuery()->getResult(); |
@@ -210,10 +210,10 @@ discard block |
||
| 210 | 210 | * @param RankingSystemList $list |
| 211 | 211 | * @return RankingSystemListEntry[] $entries |
| 212 | 212 | */ |
| 213 | - protected final function getEntriesOfPlayers(Collection $players, RankingSystemList $list): array |
|
| 213 | + protected final function getEntriesOfPlayers( Collection $players, RankingSystemList $list ): array |
|
| 214 | 214 | { |
| 215 | 215 | $result = []; |
| 216 | - foreach ($players as $player) { |
|
| 216 | + foreach ( $players as $player ) { |
|
| 217 | 217 | $result[] = $this->getOrCreateRankingSystemListEntry($list, $player); |
| 218 | 218 | } |
| 219 | 219 | return $result; |
@@ -227,35 +227,35 @@ discard block |
||
| 227 | 227 | * @param Player $player the player to search for |
| 228 | 228 | * @return RankingSystemChange the found or newly created ranking system change |
| 229 | 229 | */ |
| 230 | - protected final function getOrCreateChange(TournamentHierarchyEntity $entity, RankingSystem $ranking, |
|
| 231 | - Player $player) |
|
| 230 | + protected final function getOrCreateChange( TournamentHierarchyEntity $entity, RankingSystem $ranking, |
|
| 231 | + Player $player ) |
|
| 232 | 232 | { |
| 233 | 233 | $key1 = $entity->getId(); |
| 234 | 234 | $key2 = $ranking->getId(); |
| 235 | 235 | $key3 = $player->getPlayerId(); |
| 236 | - if (!array_key_exists($key1, $this->changes) || !array_key_exists($key2, $this->changes[$key1]) || |
|
| 237 | - !array_key_exists($key3, $this->changes[$key1][$key2])) { |
|
| 236 | + if ( !array_key_exists($key1, $this->changes) || !array_key_exists($key2, $this->changes[$key1]) || |
|
| 237 | + !array_key_exists($key3, $this->changes[$key1][$key2]) ) { |
|
| 238 | 238 | /** @var RankingSystemChange[] $changes */ |
| 239 | 239 | $changes = $this->entityManager->getRepository(RankingSystemChange::class)->findBy( |
| 240 | 240 | ['hierarchyEntity' => $entity]); |
| 241 | 241 | $this->changes[$key1] = []; |
| 242 | - foreach ($changes as $change) { |
|
| 242 | + foreach ( $changes as $change ) { |
|
| 243 | 243 | |
| 244 | 244 | $newKey2 = $change->getRankingSystem()->getId(); |
| 245 | 245 | $newKey3 = $change->getPlayer()->getPlayerId(); |
| 246 | - if (!array_key_exists($key1, $this->deletedChanges) || !array_key_exists($key2, $this->deletedChanges[$key1]) || |
|
| 247 | - !array_key_exists($key3, $this->deletedChanges[$key1][$key2])) { |
|
| 248 | - if (!array_key_exists($newKey2, $this->changes)) { |
|
| 246 | + if ( !array_key_exists($key1, $this->deletedChanges) || !array_key_exists($key2, $this->deletedChanges[$key1]) || |
|
| 247 | + !array_key_exists($key3, $this->deletedChanges[$key1][$key2]) ) { |
|
| 248 | + if ( !array_key_exists($newKey2, $this->changes) ) { |
|
| 249 | 249 | $this->changes[$key1][$newKey2] = []; |
| 250 | 250 | } |
| 251 | 251 | $this->changes[$key1][$newKey2][$newKey3] = $change; |
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | - if (!array_key_exists($key2, $this->changes[$key1]) || !array_key_exists($key3, $this->changes[$key1][$key2])) { |
|
| 255 | + if ( !array_key_exists($key2, $this->changes[$key1]) || !array_key_exists($key3, $this->changes[$key1][$key2]) ) { |
|
| 256 | 256 | //create new change |
| 257 | 257 | $change = new RankingSystemChange(array_keys($this->getAdditionalFields())); |
| 258 | - foreach ($this->getAdditionalFields() as $field => $value) { |
|
| 258 | + foreach ( $this->getAdditionalFields() as $field => $value ) { |
|
| 259 | 259 | // PropertyNotExistingException => we know for sure that the property exists (see 2 lines above) |
| 260 | 260 | /** @noinspection PhpUnhandledExceptionInspection */ |
| 261 | 261 | $change->setProperty($field, 0); |
@@ -265,8 +265,8 @@ discard block |
||
| 265 | 265 | $change->setPlayer($player); |
| 266 | 266 | $this->entityManager->persist($change); |
| 267 | 267 | $this->changes[$key1][$key2][$key3] = $change; |
| 268 | - if (array_key_exists($key1, $this->deletedChanges) && array_key_exists($key2, $this->deletedChanges[$key1]) && |
|
| 269 | - array_key_exists($key3, $this->deletedChanges[$key1][$key2])) { |
|
| 268 | + if ( array_key_exists($key1, $this->deletedChanges) && array_key_exists($key2, $this->deletedChanges[$key1]) && |
|
| 269 | + array_key_exists($key3, $this->deletedChanges[$key1][$key2]) ) { |
|
| 270 | 270 | unset($this->deletedChanges[$key1][$key2][$key3]); |
| 271 | 271 | } |
| 272 | 272 | } |
@@ -279,16 +279,16 @@ discard block |
||
| 279 | 279 | * @param Player $player the player to search for |
| 280 | 280 | * @return RankingSystemListEntry the found or the new entry |
| 281 | 281 | */ |
| 282 | - protected final function getOrCreateRankingSystemListEntry(RankingSystemList $list, |
|
| 283 | - Player $player): RankingSystemListEntry |
|
| 282 | + protected final function getOrCreateRankingSystemListEntry( RankingSystemList $list, |
|
| 283 | + Player $player ): RankingSystemListEntry |
|
| 284 | 284 | { |
| 285 | 285 | $playerId = $player->getPlayerId(); |
| 286 | - if (!$list->getEntries()->containsKey($playerId)) { |
|
| 286 | + if ( !$list->getEntries()->containsKey($playerId) ) { |
|
| 287 | 287 | $entry = new RankingSystemListEntry(array_keys($this->getAdditionalFields())); |
| 288 | 288 | $entry->setPoints($this->startPoints()); |
| 289 | 289 | $entry->setPlayer($player); |
| 290 | 290 | $entry->setRankingSystemList($list); |
| 291 | - foreach ($this->getAdditionalFields() as $field => $value) { |
|
| 291 | + foreach ( $this->getAdditionalFields() as $field => $value ) { |
|
| 292 | 292 | // PropertyNotExistingException => we know for sure that the property exists (see 2 lines above) |
| 293 | 293 | /** @noinspection PhpUnhandledExceptionInspection */ |
| 294 | 294 | $entry->setProperty($field, $value); |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | * @param RankingSystemList $list the list for which to compute the ranking changes |
| 314 | 314 | * @return RankingSystemChange[] the changes |
| 315 | 315 | */ |
| 316 | - protected abstract function getChanges(TournamentHierarchyEntity $entity, RankingSystemList $list): array; |
|
| 316 | + protected abstract function getChanges( TournamentHierarchyEntity $entity, RankingSystemList $list ): array; |
|
| 317 | 317 | |
| 318 | 318 | /** |
| 319 | 319 | * Gets a query for getting the relevant entities for updating |
@@ -322,8 +322,8 @@ discard block |
||
| 322 | 322 | * time value exactly $from |
| 323 | 323 | * @return QueryBuilder |
| 324 | 324 | */ |
| 325 | - protected abstract function getEntitiesQueryBuilder(RankingSystem $ranking, |
|
| 326 | - \DateTime $from): QueryBuilder; |
|
| 325 | + protected abstract function getEntitiesQueryBuilder( RankingSystem $ranking, |
|
| 326 | + \DateTime $from ): QueryBuilder; |
|
| 327 | 327 | |
| 328 | 328 | /** |
| 329 | 329 | * Gets the level of the ranking system service (see Level Enum) |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | * @param RankingSystemList $list the ranking list to change |
| 349 | 349 | * @param RankingSystemList $base the ranking list to use as base list, this doesn't get changed |
| 350 | 350 | */ |
| 351 | - private function cloneInto(RankingSystemList $list, RankingSystemList $base) |
|
| 351 | + private function cloneInto( RankingSystemList $list, RankingSystemList $base ) |
|
| 352 | 352 | { |
| 353 | 353 | /*//first remove all entries from list |
| 354 | 354 | foreach($list->getEntries()->toArray() as $entry) |
@@ -359,10 +359,10 @@ discard block |
||
| 359 | 359 | |
| 360 | 360 | $clonedPlayers = []; |
| 361 | 361 | |
| 362 | - foreach ($base->getEntries() as $entry) { |
|
| 362 | + foreach ( $base->getEntries() as $entry ) { |
|
| 363 | 363 | $playerId = $entry->getPlayer()->getPlayerId(); |
| 364 | 364 | $clonedPlayers[$playerId] = true; |
| 365 | - if (!$list->getEntries()->containsKey($playerId)) { |
|
| 365 | + if ( !$list->getEntries()->containsKey($playerId) ) { |
|
| 366 | 366 | //create new entry |
| 367 | 367 | $clone = new RankingSystemListEntry([]); |
| 368 | 368 | $clone->cloneSubClassDataFrom($entry); |
@@ -376,8 +376,8 @@ discard block |
||
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | //remove all unused entries from list |
| 379 | - foreach ($list->getEntries()->toArray() as $playerId => $entry) { |
|
| 380 | - if (!array_key_exists($playerId, $clonedPlayers)) { |
|
| 379 | + foreach ( $list->getEntries()->toArray() as $playerId => $entry ) { |
|
| 380 | + if ( !array_key_exists($playerId, $clonedPlayers) ) { |
|
| 381 | 381 | $list->getEntries()->removeElement($entry); |
| 382 | 382 | $this->entityManager->remove($entry); |
| 383 | 383 | } |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | * @param RankingSystem $ranking |
| 390 | 390 | * @param TournamentHierarchyEntity[] $entities |
| 391 | 391 | */ |
| 392 | - private function deleteOldChanges(RankingSystem $ranking, array $entities) |
|
| 392 | + private function deleteOldChanges( RankingSystem $ranking, array $entities ) |
|
| 393 | 393 | { |
| 394 | 394 | //delete old changes |
| 395 | 395 | $queryBuilder = $this->entityManager->createQueryBuilder(); |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | ->where($queryBuilder->expr()->in('c.hierarchyEntity', ':entities')) |
| 402 | 402 | ->setParameter('entities', $entities) |
| 403 | 403 | ->getQuery()->getResult(); |
| 404 | - foreach ($changes as $change) { |
|
| 404 | + foreach ( $changes as $change ) { |
|
| 405 | 405 | $this->deletedChanges[$change->getHierarchyEntity()->getId()][$ranking |
| 406 | 406 | ->getId()][$change->getPlayer()->getPlayerId()] = $change; |
| 407 | 407 | $this->entityManager->remove($change); |
@@ -416,13 +416,13 @@ discard block |
||
| 416 | 416 | * @return \DateTime|null the earliest influence or null if $parentIsRanked is false and the entity and all its |
| 417 | 417 | * successors do not have the ranking in its ranking systems |
| 418 | 418 | */ |
| 419 | - private function getEarliestEntityInfluence(RankingSystem $ranking, TournamentHierarchyInterface $entity, |
|
| 420 | - bool $parentIsRanked): ?\DateTime |
|
| 419 | + private function getEarliestEntityInfluence( RankingSystem $ranking, TournamentHierarchyInterface $entity, |
|
| 420 | + bool $parentIsRanked ): ?\DateTime |
|
| 421 | 421 | { |
| 422 | 422 | $this->timeService->clearTimes(); |
| 423 | 423 | $entityIsRanked = $parentIsRanked || $entity->getRankingSystems()->containsKey($ranking->getId()); |
| 424 | - if ($entity->getLevel() === $this->getLevel()) { |
|
| 425 | - if ($entityIsRanked) { |
|
| 424 | + if ( $entity->getLevel() === $this->getLevel() ) { |
|
| 425 | + if ( $entityIsRanked ) { |
|
| 426 | 426 | return $this->timeService->getTime($entity); |
| 427 | 427 | } else { |
| 428 | 428 | return null; |
@@ -430,9 +430,9 @@ discard block |
||
| 430 | 430 | } |
| 431 | 431 | $result = null; |
| 432 | 432 | |
| 433 | - foreach ($entity->getChildren() as $child) { |
|
| 433 | + foreach ( $entity->getChildren() as $child ) { |
|
| 434 | 434 | $earliest = $this->getEarliestEntityInfluence($ranking, $child, $entityIsRanked); |
| 435 | - if ($result === null || ($earliest !== null && $earliest < $result)) { |
|
| 435 | + if ( $result === null || ($earliest !== null && $earliest < $result) ) { |
|
| 436 | 436 | $result = $earliest; |
| 437 | 437 | } |
| 438 | 438 | } |
@@ -449,30 +449,30 @@ discard block |
||
| 449 | 449 | * @param TournamentHierarchyEntity[] $entities the list of entities to use for the computation |
| 450 | 450 | * @param int $nextEntityIndex the first index in the entities list to consider |
| 451 | 451 | */ |
| 452 | - private function recomputeBasedOn(RankingSystemList $list, RankingSystemList $base, array $entities, |
|
| 453 | - int &$nextEntityIndex) |
|
| 452 | + private function recomputeBasedOn( RankingSystemList $list, RankingSystemList $base, array $entities, |
|
| 453 | + int &$nextEntityIndex ) |
|
| 454 | 454 | { |
| 455 | 455 | $this->cloneInto($list, $base); |
| 456 | - for ($i = $nextEntityIndex; $i < count($entities); $i++) { |
|
| 456 | + for ( $i = $nextEntityIndex; $i < count($entities); $i++ ) { |
|
| 457 | 457 | $time = $this->timeService->getTime($entities[$i]); |
| 458 | - if (!$list->isCurrent() && $time > $list->getLastEntryTime()) { |
|
| 458 | + if ( !$list->isCurrent() && $time > $list->getLastEntryTime() ) { |
|
| 459 | 459 | $nextEntityIndex = $i; |
| 460 | 460 | return; |
| 461 | 461 | } |
| 462 | 462 | $changes = $this->getChanges($entities[$nextEntityIndex], $list); |
| 463 | - foreach ($changes as $change) { |
|
| 463 | + foreach ( $changes as $change ) { |
|
| 464 | 464 | $entry = $this->getOrCreateRankingSystemListEntry($list, $change->getPlayer()); |
| 465 | 465 | $entry->setNumberRankedEntities($entry->getNumberRankedEntities() + 1); |
| 466 | 466 | $pointsAfterwards = $entry->getPoints() + $change->getPointsChange(); |
| 467 | 467 | $entry->setPoints($pointsAfterwards); |
| 468 | 468 | $change->setPointsAfterwards($pointsAfterwards); |
| 469 | 469 | //apply further changes |
| 470 | - foreach ($this->getAdditionalFields() as $field => $value) { |
|
| 470 | + foreach ( $this->getAdditionalFields() as $field => $value ) { |
|
| 471 | 471 | // PropertyNotExistingException => entry and field have exactly the static properties from getAdditionalFields |
| 472 | 472 | /** @noinspection PhpUnhandledExceptionInspection */ |
| 473 | 473 | $entry->setProperty($field, $entry->getProperty($field) + $change->getProperty($field)); |
| 474 | 474 | } |
| 475 | - if ($time > $list->getLastEntryTime()) { |
|
| 475 | + if ( $time > $list->getLastEntryTime() ) { |
|
| 476 | 476 | $list->setLastEntryTime($time); |
| 477 | 477 | } |
| 478 | 478 | $this->entityManager->persist($change); |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | /* |
| 5 | 5 | * This file is part of jwt-auth. |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | return [ |
| 5 | 5 | /* |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | return [ |
| 5 | 5 | 'defaults' => [ |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | return [ |
| 5 | 5 | |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | return [ |
| 5 | 5 | /* |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | /** |
| 4 | 4 | * Created by PhpStorm. |
| 5 | 5 | * User: benedikt |