Completed
Branch master (0dfbed)
by Benedikt
07:50
created
src/Entity/Game.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
131 131
   }
132 132
 
133 133
   /**
134
-   * @return Player[]|Collection
134
+   * @return Collection
135 135
    */
136 136
   public function getPlayersB()
137 137
   {
Please login to merge, or discard this patch.
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
    */
68 68
   public function __construct()
69 69
   {
70
-    parent::__construct();
71
-    $this->playersA = new ArrayCollection();
72
-    $this->playersB = new ArrayCollection();
70
+	parent::__construct();
71
+	$this->playersA = new ArrayCollection();
72
+	$this->playersB = new ArrayCollection();
73 73
   }
74 74
 //</editor-fold desc="Constructor">
75 75
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
    */
80 80
   public function getChildren(): Collection
81 81
   {
82
-    return new ArrayCollection();
82
+	return new ArrayCollection();
83 83
   }
84 84
 
85 85
   /**
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
    */
88 88
   public function getGameNumber(): int
89 89
   {
90
-    return $this->gameNumber;
90
+	return $this->gameNumber;
91 91
   }
92 92
 
93 93
   /**
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
    */
96 96
   public function getLevel(): int
97 97
   {
98
-    return Level::GAME;
98
+	return Level::GAME;
99 99
   }
100 100
 
101 101
   /**
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
    */
104 104
   public function getLocalIdentifier()
105 105
   {
106
-    return $this->getGameNumber();
106
+	return $this->getGameNumber();
107 107
   }
108 108
 
109 109
   /**
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
    */
112 112
   public function getMatch(): Match
113 113
   {
114
-    return $this->match;
114
+	return $this->match;
115 115
   }
116 116
 
117 117
   /**
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
    */
120 120
   public function getParent(): ?TournamentHierarchyInterface
121 121
   {
122
-    return $this->getMatch();
122
+	return $this->getMatch();
123 123
   }
124 124
 
125 125
   /**
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
    */
128 128
   public function getPlayersA()
129 129
   {
130
-    return $this->playersA;
130
+	return $this->playersA;
131 131
   }
132 132
 
133 133
   /**
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
    */
136 136
   public function getPlayersB()
137 137
   {
138
-    return $this->playersB;
138
+	return $this->playersB;
139 139
   }
140 140
 
141 141
   /**
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
    */
145 145
   public function setGameNumber(int $gameNumber): Game
146 146
   {
147
-    $this->gameNumber = $gameNumber;
148
-    return $this;
147
+	$this->gameNumber = $gameNumber;
148
+	return $this;
149 149
   }
150 150
 
151 151
   /**
@@ -154,12 +154,12 @@  discard block
 block discarded – undo
154 154
    */
155 155
   public function setMatch(Match $match): Game
156 156
   {
157
-    if ($this->match !== null) {
158
-      $this->match->getGames()->remove($this->getGameNumber());
159
-    }
160
-    $this->match = $match;
161
-    $match->getGames()->set($this->getGameNumber(), $this);
162
-    return $this;
157
+	if ($this->match !== null) {
158
+	  $this->match->getGames()->remove($this->getGameNumber());
159
+	}
160
+	$this->match = $match;
161
+	$match->getGames()->set($this->getGameNumber(), $this);
162
+	return $this;
163 163
   }
164 164
 //</editor-fold desc="Public Methods">
165 165
 }
166 166
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -24,8 +24,7 @@  discard block
 block discarded – undo
24 24
  * @ORM\Entity
25 25
  * @ORM\Table(name="games")
26 26
  */
27
-class Game extends TournamentHierarchyEntity
28
-{
27
+class Game extends TournamentHierarchyEntity {
29 28
   use ResultEntity;
30 29
 
31 30
 //<editor-fold desc="Fields">
@@ -65,8 +64,7 @@  discard block
 block discarded – undo
65 64
   /**
66 65
    * Match constructor.
67 66
    */
68
-  public function __construct()
69
-  {
67
+  public function __construct() {
70 68
     parent::__construct();
71 69
     $this->playersA = new ArrayCollection();
72 70
     $this->playersB = new ArrayCollection();
@@ -101,8 +99,7 @@  discard block
 block discarded – undo
101 99
   /**
102 100
    * @inheritDoc
103 101
    */
104
-  public function getLocalIdentifier()
105
-  {
102
+  public function getLocalIdentifier() {
106 103
     return $this->getGameNumber();
107 104
   }
108 105
 
@@ -125,16 +122,14 @@  discard block
 block discarded – undo
125 122
   /**
126 123
    * @return Player[]|Collection
127 124
    */
128
-  public function getPlayersA()
129
-  {
125
+  public function getPlayersA() {
130 126
     return $this->playersA;
131 127
   }
132 128
 
133 129
   /**
134 130
    * @return Player[]|Collection
135 131
    */
136
-  public function getPlayersB()
137
-  {
132
+  public function getPlayersB() {
138 133
     return $this->playersB;
139 134
   }
140 135
 
Please login to merge, or discard this patch.
src/Service/RankingSystem/EloRanking.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@
 block discarded – undo
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
    */
Please login to merge, or discard this patch.
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
    */
47 47
   protected function getAdditionalFields(): array
48 48
   {
49
-    return ['playedGames' => 0, 'ratedGames' => 0, 'provisoryRanking' => 1200.0];
49
+	return ['playedGames' => 0, 'ratedGames' => 0, 'provisoryRanking' => 1200.0];
50 50
   }
51 51
 
52 52
   /**
@@ -54,51 +54,51 @@  discard block
 block discarded – undo
54 54
    */
55 55
   protected function getChanges(TournamentHierarchyEntity $entity, RankingSystemList $list): array
56 56
   {
57
-    /** @var Game $game */
58
-    $game = $entity;
59
-    $changes = [];
60
-
61
-    if (!$game->isPlayed() || $game->getResult() === Result::NOT_YET_FINISHED ||
62
-      $game->getResult() === Result::NULLED) {
63
-      //game gets not elo rated
64
-      $this->addNotRatedChanges($changes, $game->getPlayersA(), $entity, $list->getRankingSystem());
65
-      $this->addNotRatedChanges($changes, $game->getPlayersB(), $entity, $list->getRankingSystem());
66
-      return $changes;
67
-    }
68
-
69
-    $entriesA = $this->getEntriesOfPlayers($game->getPlayersA(), $list);
70
-    $entriesB = $this->getEntriesOfPlayers($game->getPlayersB(), $list);
71
-
72
-    $isAProvisory = $this->hasProvisoryEntry($entriesA);
73
-    $isBProvisory = $this->hasProvisoryEntry($entriesB);
74
-
75
-    $averageA = $this->getEloAverage($entriesA);
76
-    $averageB = $this->getEloAverage($entriesB);
77
-
78
-    $expectationA = 1 / (1 + 10 ** (($averageB - $averageA) / self::EXP_DIFF));
79
-    $expectationB = 1 - $expectationA;
80
-
81
-    $resultA = 0.0;
82
-
83
-    switch ($game->getResult()) {
84
-      case Result::TEAM_A_WINS:
85
-        $resultA = 1.0;
86
-        break;
87
-      case Result::DRAW:
88
-        $resultA = 0.5;
89
-        break;
90
-    }
91
-    $resultB = 1 - $resultA;
92
-
93
-    $expectationDiffA = $resultA - $expectationA;
94
-    $expectationDiffB = $resultB - $expectationB;
95
-
96
-
97
-    $this->computeChanges($changes, $entriesA, $resultA, $expectationDiffA, $game, $averageA, $averageB,
98
-      $isAProvisory, $isBProvisory);
99
-    $this->computeChanges($changes, $entriesB, $resultB, $expectationDiffB, $game, $averageB, $averageA,
100
-      $isBProvisory, $isAProvisory);
101
-    return $changes;
57
+	/** @var Game $game */
58
+	$game = $entity;
59
+	$changes = [];
60
+
61
+	if (!$game->isPlayed() || $game->getResult() === Result::NOT_YET_FINISHED ||
62
+	  $game->getResult() === Result::NULLED) {
63
+	  //game gets not elo rated
64
+	  $this->addNotRatedChanges($changes, $game->getPlayersA(), $entity, $list->getRankingSystem());
65
+	  $this->addNotRatedChanges($changes, $game->getPlayersB(), $entity, $list->getRankingSystem());
66
+	  return $changes;
67
+	}
68
+
69
+	$entriesA = $this->getEntriesOfPlayers($game->getPlayersA(), $list);
70
+	$entriesB = $this->getEntriesOfPlayers($game->getPlayersB(), $list);
71
+
72
+	$isAProvisory = $this->hasProvisoryEntry($entriesA);
73
+	$isBProvisory = $this->hasProvisoryEntry($entriesB);
74
+
75
+	$averageA = $this->getEloAverage($entriesA);
76
+	$averageB = $this->getEloAverage($entriesB);
77
+
78
+	$expectationA = 1 / (1 + 10 ** (($averageB - $averageA) / self::EXP_DIFF));
79
+	$expectationB = 1 - $expectationA;
80
+
81
+	$resultA = 0.0;
82
+
83
+	switch ($game->getResult()) {
84
+	  case Result::TEAM_A_WINS:
85
+		$resultA = 1.0;
86
+		break;
87
+	  case Result::DRAW:
88
+		$resultA = 0.5;
89
+		break;
90
+	}
91
+	$resultB = 1 - $resultA;
92
+
93
+	$expectationDiffA = $resultA - $expectationA;
94
+	$expectationDiffB = $resultB - $expectationB;
95
+
96
+
97
+	$this->computeChanges($changes, $entriesA, $resultA, $expectationDiffA, $game, $averageA, $averageB,
98
+	  $isAProvisory, $isBProvisory);
99
+	$this->computeChanges($changes, $entriesB, $resultB, $expectationDiffB, $game, $averageB, $averageA,
100
+	  $isBProvisory, $isAProvisory);
101
+	return $changes;
102 102
   }
103 103
 
104 104
   /** @noinspection PhpMissingParentCallCommonInspection */
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
    */
108 108
   protected function startPoints(): float
109 109
   {
110
-    return 1200.0;
110
+	return 1200.0;
111 111
   }
112 112
 //</editor-fold desc="Protected Methods">
113 113
 
@@ -120,16 +120,16 @@  discard block
 block discarded – undo
120 120
    * @param \Tfboe\FmLib\Entity\RankingSystem $ranking
121 121
    */
122 122
   private function addNotRatedChanges(array &$changes, Collection $players, TournamentHierarchyEntity $entity,
123
-                                      RankingSystem $ranking)
123
+									  RankingSystem $ranking)
124 124
   {
125
-    foreach ($players as $player) {
126
-      $change = $this->getOrCreateChange($entity, $ranking, $player);
127
-      $change->setPointsChange(0.0);
128
-      $change->setPlayedGames(0);
129
-      $change->setRatedGames(0);
130
-      $change->setProvisoryRanking(0.0);
131
-      $changes[] = $change;
132
-    }
125
+	foreach ($players as $player) {
126
+	  $change = $this->getOrCreateChange($entity, $ranking, $player);
127
+	  $change->setPointsChange(0.0);
128
+	  $change->setPlayedGames(0);
129
+	  $change->setRatedGames(0);
130
+	  $change->setProvisoryRanking(0.0);
131
+	  $changes[] = $change;
132
+	}
133 133
   }
134 134
 
135 135
   /** @noinspection PhpTooManyParametersInspection */ //TODO refactor this method
@@ -145,56 +145,56 @@  discard block
 block discarded – undo
145 145
    * @param bool $opponentHasProvisory
146 146
    */
147 147
   private function computeChanges(array &$changes, array $entries, float $result, float $expectationDiff, Game $game,
148
-                                  float $teamAverage, float $opponentAverage, bool $teamHasProvisory,
149
-                                  bool $opponentHasProvisory)
148
+								  float $teamAverage, float $opponentAverage, bool $teamHasProvisory,
149
+								  bool $opponentHasProvisory)
150 150
   {
151
-    foreach ($entries as $entry) {
152
-      $change = $this->getOrCreateChange($game, $entry->getRankingSystemList()->getRankingSystem(),
153
-        $entry->getPlayer());
154
-      $change->setPlayedGames(1);
155
-      $factor = 2 * $result - 1;
156
-      if ($entry->getPlayedGames() < self::NUM_PROVISORY_GAMES) {
157
-        //provisory entry => recalculate
158
-        if (count($entries) > 1) {
159
-          $teamMatesAverage = ($teamAverage * count($entries) - $entry->getProvisoryRanking()) /
160
-            (count($entries) - 1);
161
-          if ($teamMatesAverage > $opponentAverage + self::MAX_DIFF_TO_OPPONENT_FOR_PROVISORY) {
162
-            $teamMatesAverage = $opponentAverage + self::MAX_DIFF_TO_OPPONENT_FOR_PROVISORY;
163
-          }
164
-          if ($teamMatesAverage < $opponentAverage - self::MAX_DIFF_TO_OPPONENT_FOR_PROVISORY) {
165
-            $teamMatesAverage = $opponentAverage - self::MAX_DIFF_TO_OPPONENT_FOR_PROVISORY;
166
-          }
167
-          $performance = $opponentAverage * (1 + self::PROVISORY_PARTNER_FACTOR) -
168
-            $teamMatesAverage * self::PROVISORY_PARTNER_FACTOR;
169
-        } else {
170
-          $performance = $opponentAverage;
171
-        }
172
-        if ($performance < self::START) {
173
-          $performance = self::START;
174
-        }
175
-        $performance += self::EXP_DIFF * $factor;
176
-        //old average performance = $entry->getProvisoryRating()
177
-        //=> new average performance = ($entry->getProvisoryRating() * $entry->getRatedGames() + $performance) /
178
-        //                             ($entry->getRatedGames() + 1)
179
-        //=> performance change = ($entry->getProvisoryRating() * $entry->getRatedGames() + $performance) /
180
-        //                        ($entry->getRatedGames() + 1) - $entry->getProvisoryRating()
181
-        //                      = ($performance - $entry->getProvisoryRating()) / ($entry->getRatedGames() + 1)
182
-        $change->setProvisoryRanking(($performance - $entry->getProvisoryRanking()) / ($entry->getRatedGames() + 1));
183
-        $change->setPointsChange(0.0);
184
-        $change->setRatedGames(1);
185
-      } else if (!$teamHasProvisory && !$opponentHasProvisory) {
186
-        //real elo ranking
187
-        $change->setProvisoryRanking(0.0);
188
-        $change->setPointsChange(self::K * $expectationDiff);
189
-        $change->setRatedGames(1);
190
-      } else {
191
-        //does not get rated
192
-        $change->setProvisoryRanking(0.0);
193
-        $change->setPointsChange(0.0);
194
-        $change->setRatedGames(0);
195
-      }
196
-      $changes[] = $change;
197
-    }
151
+	foreach ($entries as $entry) {
152
+	  $change = $this->getOrCreateChange($game, $entry->getRankingSystemList()->getRankingSystem(),
153
+		$entry->getPlayer());
154
+	  $change->setPlayedGames(1);
155
+	  $factor = 2 * $result - 1;
156
+	  if ($entry->getPlayedGames() < self::NUM_PROVISORY_GAMES) {
157
+		//provisory entry => recalculate
158
+		if (count($entries) > 1) {
159
+		  $teamMatesAverage = ($teamAverage * count($entries) - $entry->getProvisoryRanking()) /
160
+			(count($entries) - 1);
161
+		  if ($teamMatesAverage > $opponentAverage + self::MAX_DIFF_TO_OPPONENT_FOR_PROVISORY) {
162
+			$teamMatesAverage = $opponentAverage + self::MAX_DIFF_TO_OPPONENT_FOR_PROVISORY;
163
+		  }
164
+		  if ($teamMatesAverage < $opponentAverage - self::MAX_DIFF_TO_OPPONENT_FOR_PROVISORY) {
165
+			$teamMatesAverage = $opponentAverage - self::MAX_DIFF_TO_OPPONENT_FOR_PROVISORY;
166
+		  }
167
+		  $performance = $opponentAverage * (1 + self::PROVISORY_PARTNER_FACTOR) -
168
+			$teamMatesAverage * self::PROVISORY_PARTNER_FACTOR;
169
+		} else {
170
+		  $performance = $opponentAverage;
171
+		}
172
+		if ($performance < self::START) {
173
+		  $performance = self::START;
174
+		}
175
+		$performance += self::EXP_DIFF * $factor;
176
+		//old average performance = $entry->getProvisoryRating()
177
+		//=> new average performance = ($entry->getProvisoryRating() * $entry->getRatedGames() + $performance) /
178
+		//                             ($entry->getRatedGames() + 1)
179
+		//=> performance change = ($entry->getProvisoryRating() * $entry->getRatedGames() + $performance) /
180
+		//                        ($entry->getRatedGames() + 1) - $entry->getProvisoryRating()
181
+		//                      = ($performance - $entry->getProvisoryRating()) / ($entry->getRatedGames() + 1)
182
+		$change->setProvisoryRanking(($performance - $entry->getProvisoryRanking()) / ($entry->getRatedGames() + 1));
183
+		$change->setPointsChange(0.0);
184
+		$change->setRatedGames(1);
185
+	  } else if (!$teamHasProvisory && !$opponentHasProvisory) {
186
+		//real elo ranking
187
+		$change->setProvisoryRanking(0.0);
188
+		$change->setPointsChange(self::K * $expectationDiff);
189
+		$change->setRatedGames(1);
190
+	  } else {
191
+		//does not get rated
192
+		$change->setProvisoryRanking(0.0);
193
+		$change->setPointsChange(0.0);
194
+		$change->setRatedGames(0);
195
+	  }
196
+	  $changes[] = $change;
197
+	}
198 198
   }
199 199
 
200 200
   /**
@@ -204,11 +204,11 @@  discard block
 block discarded – undo
204 204
    */
205 205
   private function getEloAverage(array $entries): float
206 206
   {
207
-    $sum = 0;
208
-    foreach ($entries as $entry) {
209
-      $sum += $entry->getRatedGames() < self::NUM_PROVISORY_GAMES ? $entry->getProvisoryRanking() : $entry->getPoints();
210
-    }
211
-    return $sum / count($entries);
207
+	$sum = 0;
208
+	foreach ($entries as $entry) {
209
+	  $sum += $entry->getRatedGames() < self::NUM_PROVISORY_GAMES ? $entry->getProvisoryRanking() : $entry->getPoints();
210
+	}
211
+	return $sum / count($entries);
212 212
   }
213 213
 
214 214
   /**
@@ -218,12 +218,12 @@  discard block
 block discarded – undo
218 218
    */
219 219
   private function hasProvisoryEntry(array $entries): bool
220 220
   {
221
-    foreach ($entries as $entry) {
222
-      if ($entry->getPlayedGames() < self::NUM_PROVISORY_GAMES) {
223
-        return true;
224
-      }
225
-    }
226
-    return false;
221
+	foreach ($entries as $entry) {
222
+	  if ($entry->getPlayedGames() < self::NUM_PROVISORY_GAMES) {
223
+		return true;
224
+	  }
225
+	}
226
+	return false;
227 227
   }
228 228
 //</editor-fold desc="Private Methods">
229 229
 }
230 230
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@  discard block
 block discarded – undo
23 23
  * Class EloRanking
24 24
  * @package Tfboe\FmLib\Service\TournamentRanking
25 25
  */
26
-class EloRanking extends GameRankingSystemService implements EloRankingInterface
27
-{
26
+class EloRanking extends GameRankingSystemService implements EloRankingInterface {
28 27
 //<editor-fold desc="Fields">
29 28
   const EXP_DIFF = 400;
30 29
   const K = 20;
@@ -120,8 +119,7 @@  discard block
 block discarded – undo
120 119
    * @param \Tfboe\FmLib\Entity\RankingSystem $ranking
121 120
    */
122 121
   private function addNotRatedChanges(array &$changes, Collection $players, TournamentHierarchyEntity $entity,
123
-                                      RankingSystem $ranking)
124
-  {
122
+                                      RankingSystem $ranking) {
125 123
     foreach ($players as $player) {
126 124
       $change = $this->getOrCreateChange($entity, $ranking, $player);
127 125
       $change->setPointsChange(0.0);
@@ -146,8 +144,7 @@  discard block
 block discarded – undo
146 144
    */
147 145
   private function computeChanges(array &$changes, array $entries, float $result, float $expectationDiff, Game $game,
148 146
                                   float $teamAverage, float $opponentAverage, bool $teamHasProvisory,
149
-                                  bool $opponentHasProvisory)
150
-  {
147
+                                  bool $opponentHasProvisory) {
151 148
     foreach ($entries as $entry) {
152 149
       $change = $this->getOrCreateChange($game, $entry->getRankingSystemList()->getRankingSystem(),
153 150
         $entry->getPlayer());
Please login to merge, or discard this patch.
src/Service/RankingSystem/RankingSystemService.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -206,7 +206,7 @@
 block discarded – undo
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
    */
Please login to merge, or discard this patch.
Indentation   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
    * @param EntityComparerInterface $entityComparer
68 68
    */
69 69
   public function __construct(EntityManagerInterface $entityManager, TimeServiceInterface $timeService,
70
-                              EntityComparerInterface $entityComparer)
70
+							  EntityComparerInterface $entityComparer)
71 71
   {
72
-    $this->entityManager = $entityManager;
73
-    $this->timeService = $timeService;
74
-    $this->entityComparer = $entityComparer;
75
-    $this->changes = [];
76
-    $this->deletedChanges = [];
77
-    $this->updateRankingCalls = [];
72
+	$this->entityManager = $entityManager;
73
+	$this->timeService = $timeService;
74
+	$this->entityComparer = $entityComparer;
75
+	$this->changes = [];
76
+	$this->deletedChanges = [];
77
+	$this->updateRankingCalls = [];
78 78
   }
79 79
 //</editor-fold desc="Constructor">
80 80
 
@@ -84,23 +84,23 @@  discard block
 block discarded – undo
84 84
    */
85 85
   public function getEarliestInfluence(RankingSystem $ranking, Tournament $tournament): ?\DateTime
86 86
   {
87
-    return $this->getEarliestEntityInfluence($ranking, $tournament, false);
87
+	return $this->getEarliestEntityInfluence($ranking, $tournament, false);
88 88
   }
89 89
 
90 90
   /**
91 91
    * @inheritdoc
92 92
    */
93 93
   public function updateRankingForTournament(RankingSystem $ranking, Tournament $tournament,
94
-                                             ?\DateTime $oldInfluence)
94
+											 ?\DateTime $oldInfluence)
95 95
   {
96
-    $earliestInfluence = $this->getEarliestInfluence($ranking, $tournament);
97
-    if ($oldInfluence !== null &&
98
-      ($earliestInfluence === null || $oldInfluence < $earliestInfluence)) {
99
-      $earliestInfluence = $oldInfluence;
100
-    }
101
-    if ($earliestInfluence !== null) {
102
-      $this->updateRankingFrom($ranking, $earliestInfluence);
103
-    }
96
+	$earliestInfluence = $this->getEarliestInfluence($ranking, $tournament);
97
+	if ($oldInfluence !== null &&
98
+	  ($earliestInfluence === null || $oldInfluence < $earliestInfluence)) {
99
+	  $earliestInfluence = $oldInfluence;
100
+	}
101
+	if ($earliestInfluence !== null) {
102
+	  $this->updateRankingFrom($ranking, $earliestInfluence);
103
+	}
104 104
   }
105 105
 
106 106
   /**
@@ -108,60 +108,60 @@  discard block
 block discarded – undo
108 108
    */
109 109
   public function updateRankingFrom(RankingSystem $ranking, \DateTime $from)
110 110
   {
111
-    // can only be called once per ranking system!!!
112
-    if (array_key_exists($ranking->getId(), $this->updateRankingCalls)) {
113
-      throw new PreconditionFailedException();
114
-    }
115
-    $this->updateRankingCalls[$ranking->getId()] = $ranking;
116
-    //find first reusable
117
-    /** @var RankingSystemList[] $lists */
118
-    $lists = array_values($ranking->getLists()->toArray());
119
-
120
-    $current = null;
121
-    /** @var RankingSystemList $lastReusable */
122
-    $lastReusable = null;
123
-    $toUpdate = [];
124
-
125
-    foreach ($lists as $list) {
126
-      if ($list->isCurrent()) {
127
-        $current = $list;
128
-      } else if ($list->getLastEntryTime() >= $from) {
129
-        $toUpdate[] = $list;
130
-      } else if ($lastReusable === null || $list->getLastEntryTime() > $lastReusable->getLastEntryTime()) {
131
-        $lastReusable = $list;
132
-      }
133
-    }
134
-
135
-    if ($lastReusable === null) {
136
-      $lastReusable = new RankingSystemList();
137
-    }
138
-
139
-    usort($toUpdate, function (RankingSystemList $list1, RankingSystemList $list2) {
140
-      return $list1->getLastEntryTime() <=> $list2->getLastEntryTime();
141
-    });
142
-
143
-    $entities = $this->getEntities($ranking, $lastReusable->getLastEntryTime());
144
-    //sort entities
145
-    $this->timeService->clearTimes();
146
-    usort($entities, function ($entity1, $entity2) {
147
-      return $this->entityComparer->compareEntities($entity1, $entity2);
148
-    });
149
-
150
-    $this->deleteOldChanges($ranking, $entities);
151
-
152
-    $nextEntityIndex = 0;
153
-    foreach ($toUpdate as $list) {
154
-      $this->recomputeBasedOn($list, $lastReusable, $entities, $nextEntityIndex);
155
-      $lastReusable = $list;
156
-    }
157
-
158
-    if ($current === null) {
159
-      $current = new RankingSystemList();
160
-      $current->setCurrent(true);
161
-      $this->entityManager->persist($current);
162
-      $current->setRankingSystem($ranking);
163
-    }
164
-    $this->recomputeBasedOn($current, $lastReusable, $entities, $nextEntityIndex);
111
+	// can only be called once per ranking system!!!
112
+	if (array_key_exists($ranking->getId(), $this->updateRankingCalls)) {
113
+	  throw new PreconditionFailedException();
114
+	}
115
+	$this->updateRankingCalls[$ranking->getId()] = $ranking;
116
+	//find first reusable
117
+	/** @var RankingSystemList[] $lists */
118
+	$lists = array_values($ranking->getLists()->toArray());
119
+
120
+	$current = null;
121
+	/** @var RankingSystemList $lastReusable */
122
+	$lastReusable = null;
123
+	$toUpdate = [];
124
+
125
+	foreach ($lists as $list) {
126
+	  if ($list->isCurrent()) {
127
+		$current = $list;
128
+	  } else if ($list->getLastEntryTime() >= $from) {
129
+		$toUpdate[] = $list;
130
+	  } else if ($lastReusable === null || $list->getLastEntryTime() > $lastReusable->getLastEntryTime()) {
131
+		$lastReusable = $list;
132
+	  }
133
+	}
134
+
135
+	if ($lastReusable === null) {
136
+	  $lastReusable = new RankingSystemList();
137
+	}
138
+
139
+	usort($toUpdate, function (RankingSystemList $list1, RankingSystemList $list2) {
140
+	  return $list1->getLastEntryTime() <=> $list2->getLastEntryTime();
141
+	});
142
+
143
+	$entities = $this->getEntities($ranking, $lastReusable->getLastEntryTime());
144
+	//sort entities
145
+	$this->timeService->clearTimes();
146
+	usort($entities, function ($entity1, $entity2) {
147
+	  return $this->entityComparer->compareEntities($entity1, $entity2);
148
+	});
149
+
150
+	$this->deleteOldChanges($ranking, $entities);
151
+
152
+	$nextEntityIndex = 0;
153
+	foreach ($toUpdate as $list) {
154
+	  $this->recomputeBasedOn($list, $lastReusable, $entities, $nextEntityIndex);
155
+	  $lastReusable = $list;
156
+	}
157
+
158
+	if ($current === null) {
159
+	  $current = new RankingSystemList();
160
+	  $current->setCurrent(true);
161
+	  $this->entityManager->persist($current);
162
+	  $current->setRankingSystem($ranking);
163
+	}
164
+	$this->recomputeBasedOn($current, $lastReusable, $entities, $nextEntityIndex);
165 165
   }
166 166
 //</editor-fold desc="Public Methods">
167 167
 
@@ -173,15 +173,15 @@  discard block
 block discarded – undo
173 173
    */
174 174
   protected final function getAverage(array $entries): float
175 175
   {
176
-    $sum = 0.0;
177
-    foreach ($entries as $entry) {
178
-      $sum += $entry->getPoints();
179
-    }
180
-    if (count($entries) === 0) {
181
-      return 0.0;
182
-    } else {
183
-      return $sum / count($entries);
184
-    }
176
+	$sum = 0.0;
177
+	foreach ($entries as $entry) {
178
+	  $sum += $entry->getPoints();
179
+	}
180
+	if (count($entries) === 0) {
181
+	  return 0.0;
182
+	} else {
183
+	  return $sum / count($entries);
184
+	}
185 185
   }
186 186
 
187 187
   /**
@@ -193,8 +193,8 @@  discard block
 block discarded – undo
193 193
    */
194 194
   protected final function getEntities(RankingSystem $ranking, \DateTime $from): array
195 195
   {
196
-    $query = $this->getEntitiesQueryBuilder($ranking, $from);
197
-    return $query->getQuery()->getResult();
196
+	$query = $this->getEntitiesQueryBuilder($ranking, $from);
197
+	return $query->getQuery()->getResult();
198 198
   }
199 199
 
200 200
   /**
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
    */
203 203
   protected final function getEntityManager(): EntityManagerInterface
204 204
   {
205
-    return $this->entityManager;
205
+	return $this->entityManager;
206 206
   }
207 207
 
208 208
   /**
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
    */
213 213
   protected final function getEntriesOfPlayers(Collection $players, RankingSystemList $list): array
214 214
   {
215
-    $result = [];
216
-    foreach ($players as $player) {
217
-      $result[] = $this->getOrCreateRankingSystemListEntry($list, $player);
218
-    }
219
-    return $result;
215
+	$result = [];
216
+	foreach ($players as $player) {
217
+	  $result[] = $this->getOrCreateRankingSystemListEntry($list, $player);
218
+	}
219
+	return $result;
220 220
   }
221 221
 
222 222
   /** @noinspection PhpDocMissingThrowsInspection */ //PropertyNotExistingException
@@ -228,49 +228,49 @@  discard block
 block discarded – undo
228 228
    * @return RankingSystemChange the found or newly created ranking system change
229 229
    */
230 230
   protected final function getOrCreateChange(TournamentHierarchyEntity $entity, RankingSystem $ranking,
231
-                                             Player $player)
231
+											 Player $player)
232 232
   {
233
-    $key1 = $entity->getId();
234
-    $key2 = $ranking->getId();
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])) {
238
-      /** @var RankingSystemChange[] $changes */
239
-      $changes = $this->entityManager->getRepository(RankingSystemChange::class)->findBy(
240
-        ['hierarchyEntity' => $entity]);
241
-      $this->changes[$key1] = [];
242
-      foreach ($changes as $change) {
243
-
244
-        $newKey2 = $change->getRankingSystem()->getId();
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)) {
249
-            $this->changes[$key1][$newKey2] = [];
250
-          }
251
-          $this->changes[$key1][$newKey2][$newKey3] = $change;
252
-        }
253
-      }
254
-    }
255
-    if (!array_key_exists($key2, $this->changes[$key1]) || !array_key_exists($key3, $this->changes[$key1][$key2])) {
256
-      //create new change
257
-      $change = new RankingSystemChange(array_keys($this->getAdditionalFields()));
258
-      foreach ($this->getAdditionalFields() as $field => $value) {
259
-        // PropertyNotExistingException => we know for sure that the property exists (see 2 lines above)
260
-        /** @noinspection PhpUnhandledExceptionInspection */
261
-        $change->setProperty($field, 0);
262
-      }
263
-      $change->setHierarchyEntity($entity);
264
-      $change->setRankingSystem($ranking);
265
-      $change->setPlayer($player);
266
-      $this->entityManager->persist($change);
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])) {
270
-        unset($this->deletedChanges[$key1][$key2][$key3]);
271
-      }
272
-    }
273
-    return $this->changes[$key1][$key2][$key3];
233
+	$key1 = $entity->getId();
234
+	$key2 = $ranking->getId();
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])) {
238
+	  /** @var RankingSystemChange[] $changes */
239
+	  $changes = $this->entityManager->getRepository(RankingSystemChange::class)->findBy(
240
+		['hierarchyEntity' => $entity]);
241
+	  $this->changes[$key1] = [];
242
+	  foreach ($changes as $change) {
243
+
244
+		$newKey2 = $change->getRankingSystem()->getId();
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)) {
249
+			$this->changes[$key1][$newKey2] = [];
250
+		  }
251
+		  $this->changes[$key1][$newKey2][$newKey3] = $change;
252
+		}
253
+	  }
254
+	}
255
+	if (!array_key_exists($key2, $this->changes[$key1]) || !array_key_exists($key3, $this->changes[$key1][$key2])) {
256
+	  //create new change
257
+	  $change = new RankingSystemChange(array_keys($this->getAdditionalFields()));
258
+	  foreach ($this->getAdditionalFields() as $field => $value) {
259
+		// PropertyNotExistingException => we know for sure that the property exists (see 2 lines above)
260
+		/** @noinspection PhpUnhandledExceptionInspection */
261
+		$change->setProperty($field, 0);
262
+	  }
263
+	  $change->setHierarchyEntity($entity);
264
+	  $change->setRankingSystem($ranking);
265
+	  $change->setPlayer($player);
266
+	  $this->entityManager->persist($change);
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])) {
270
+		unset($this->deletedChanges[$key1][$key2][$key3]);
271
+	  }
272
+	}
273
+	return $this->changes[$key1][$key2][$key3];
274 274
   }
275 275
 
276 276
   /** @noinspection PhpDocMissingThrowsInspection */ //PropertyNotExistingException
@@ -280,22 +280,22 @@  discard block
 block discarded – undo
280 280
    * @return RankingSystemListEntry the found or the new entry
281 281
    */
282 282
   protected final function getOrCreateRankingSystemListEntry(RankingSystemList $list,
283
-                                                             Player $player): RankingSystemListEntry
283
+															 Player $player): RankingSystemListEntry
284 284
   {
285
-    $playerId = $player->getPlayerId();
286
-    if (!$list->getEntries()->containsKey($playerId)) {
287
-      $entry = new RankingSystemListEntry(array_keys($this->getAdditionalFields()));
288
-      $entry->setPoints($this->startPoints());
289
-      $entry->setPlayer($player);
290
-      $entry->setRankingSystemList($list);
291
-      foreach ($this->getAdditionalFields() as $field => $value) {
292
-        // PropertyNotExistingException => we know for sure that the property exists (see 2 lines above)
293
-        /** @noinspection PhpUnhandledExceptionInspection */
294
-        $entry->setProperty($field, $value);
295
-      }
296
-      $this->entityManager->persist($entry);
297
-    }
298
-    return $list->getEntries()->get($playerId);
285
+	$playerId = $player->getPlayerId();
286
+	if (!$list->getEntries()->containsKey($playerId)) {
287
+	  $entry = new RankingSystemListEntry(array_keys($this->getAdditionalFields()));
288
+	  $entry->setPoints($this->startPoints());
289
+	  $entry->setPlayer($player);
290
+	  $entry->setRankingSystemList($list);
291
+	  foreach ($this->getAdditionalFields() as $field => $value) {
292
+		// PropertyNotExistingException => we know for sure that the property exists (see 2 lines above)
293
+		/** @noinspection PhpUnhandledExceptionInspection */
294
+		$entry->setProperty($field, $value);
295
+	  }
296
+	  $this->entityManager->persist($entry);
297
+	}
298
+	return $list->getEntries()->get($playerId);
299 299
   }
300 300
 //</editor-fold desc="Protected Final Methods">
301 301
 
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
    * @return QueryBuilder
324 324
    */
325 325
   protected abstract function getEntitiesQueryBuilder(RankingSystem $ranking,
326
-                                                      \DateTime $from): QueryBuilder;
326
+													  \DateTime $from): QueryBuilder;
327 327
 
328 328
   /**
329 329
    * Gets the level of the ranking system service (see Level Enum)
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
    */
338 338
   protected function startPoints(): float
339 339
   {
340
-    return 0.0;
340
+	return 0.0;
341 341
   }
342 342
 //</editor-fold desc="Protected Methods">
343 343
 
@@ -350,38 +350,38 @@  discard block
 block discarded – undo
350 350
    */
351 351
   private function cloneInto(RankingSystemList $list, RankingSystemList $base)
352 352
   {
353
-    /*//first remove all entries from list
353
+	/*//first remove all entries from list
354 354
     foreach($list->getEntries()->toArray() as $entry)
355 355
     {
356 356
       $list->getEntries()->removeElement($entry);
357 357
       $this->entityManager->remove($entry);
358 358
     }*/
359 359
 
360
-    $clonedPlayers = [];
361
-
362
-    foreach ($base->getEntries() as $entry) {
363
-      $playerId = $entry->getPlayer()->getPlayerId();
364
-      $clonedPlayers[$playerId] = true;
365
-      if (!$list->getEntries()->containsKey($playerId)) {
366
-        //create new entry
367
-        $clone = new RankingSystemListEntry([]);
368
-        $clone->cloneSubClassDataFrom($entry);
369
-        $this->entityManager->persist($clone);
370
-        $clone->setPlayer($entry->getPlayer());
371
-        $clone->setRankingSystemList($list);
372
-      }
373
-      $foundEntry = $list->getEntries()[$playerId];
374
-      $foundEntry->setNumberRankedEntities($entry->getNumberRankedEntities());
375
-      $foundEntry->setPoints($entry->getPoints());
376
-    }
377
-
378
-    //remove all unused entries from list
379
-    foreach ($list->getEntries()->toArray() as $playerId => $entry) {
380
-      if (!array_key_exists($playerId, $clonedPlayers)) {
381
-        $list->getEntries()->removeElement($entry);
382
-        $this->entityManager->remove($entry);
383
-      }
384
-    }
360
+	$clonedPlayers = [];
361
+
362
+	foreach ($base->getEntries() as $entry) {
363
+	  $playerId = $entry->getPlayer()->getPlayerId();
364
+	  $clonedPlayers[$playerId] = true;
365
+	  if (!$list->getEntries()->containsKey($playerId)) {
366
+		//create new entry
367
+		$clone = new RankingSystemListEntry([]);
368
+		$clone->cloneSubClassDataFrom($entry);
369
+		$this->entityManager->persist($clone);
370
+		$clone->setPlayer($entry->getPlayer());
371
+		$clone->setRankingSystemList($list);
372
+	  }
373
+	  $foundEntry = $list->getEntries()[$playerId];
374
+	  $foundEntry->setNumberRankedEntities($entry->getNumberRankedEntities());
375
+	  $foundEntry->setPoints($entry->getPoints());
376
+	}
377
+
378
+	//remove all unused entries from list
379
+	foreach ($list->getEntries()->toArray() as $playerId => $entry) {
380
+	  if (!array_key_exists($playerId, $clonedPlayers)) {
381
+		$list->getEntries()->removeElement($entry);
382
+		$this->entityManager->remove($entry);
383
+	  }
384
+	}
385 385
   }
386 386
 
387 387
 
@@ -391,21 +391,21 @@  discard block
 block discarded – undo
391 391
    */
392 392
   private function deleteOldChanges(RankingSystem $ranking, array $entities)
393 393
   {
394
-    //delete old changes
395
-    $queryBuilder = $this->entityManager->createQueryBuilder();
396
-    /** @var RankingSystemChange[] $changes */
397
-    $changes = $queryBuilder
398
-      ->from(RankingSystemChange::class, 'c')
399
-      ->select('c')
400
-      ->where($queryBuilder->expr()->eq('c.rankingSystem', $ranking))
401
-      ->where($queryBuilder->expr()->in('c.hierarchyEntity', ':entities'))
402
-      ->setParameter('entities', $entities)
403
-      ->getQuery()->getResult();
404
-    foreach ($changes as $change) {
405
-      $this->deletedChanges[$change->getHierarchyEntity()->getId()][$ranking
406
-        ->getId()][$change->getPlayer()->getPlayerId()] = $change;
407
-      $this->entityManager->remove($change);
408
-    }
394
+	//delete old changes
395
+	$queryBuilder = $this->entityManager->createQueryBuilder();
396
+	/** @var RankingSystemChange[] $changes */
397
+	$changes = $queryBuilder
398
+	  ->from(RankingSystemChange::class, 'c')
399
+	  ->select('c')
400
+	  ->where($queryBuilder->expr()->eq('c.rankingSystem', $ranking))
401
+	  ->where($queryBuilder->expr()->in('c.hierarchyEntity', ':entities'))
402
+	  ->setParameter('entities', $entities)
403
+	  ->getQuery()->getResult();
404
+	foreach ($changes as $change) {
405
+	  $this->deletedChanges[$change->getHierarchyEntity()->getId()][$ranking
406
+		->getId()][$change->getPlayer()->getPlayerId()] = $change;
407
+	  $this->entityManager->remove($change);
408
+	}
409 409
   }
410 410
 
411 411
   /**
@@ -417,26 +417,26 @@  discard block
 block discarded – undo
417 417
    *                        successors do not have the ranking in its ranking systems
418 418
    */
419 419
   private function getEarliestEntityInfluence(RankingSystem $ranking, TournamentHierarchyInterface $entity,
420
-                                              bool $parentIsRanked): ?\DateTime
420
+											  bool $parentIsRanked): ?\DateTime
421 421
   {
422
-    $this->timeService->clearTimes();
423
-    $entityIsRanked = $parentIsRanked || $entity->getRankingSystems()->containsKey($ranking->getId());
424
-    if ($entity->getLevel() === $this->getLevel()) {
425
-      if ($entityIsRanked) {
426
-        return $this->timeService->getTime($entity);
427
-      } else {
428
-        return null;
429
-      }
430
-    }
431
-    $result = null;
432
-
433
-    foreach ($entity->getChildren() as $child) {
434
-      $earliest = $this->getEarliestEntityInfluence($ranking, $child, $entityIsRanked);
435
-      if ($result === null || ($earliest !== null && $earliest < $result)) {
436
-        $result = $earliest;
437
-      }
438
-    }
439
-    return $result;
422
+	$this->timeService->clearTimes();
423
+	$entityIsRanked = $parentIsRanked || $entity->getRankingSystems()->containsKey($ranking->getId());
424
+	if ($entity->getLevel() === $this->getLevel()) {
425
+	  if ($entityIsRanked) {
426
+		return $this->timeService->getTime($entity);
427
+	  } else {
428
+		return null;
429
+	  }
430
+	}
431
+	$result = null;
432
+
433
+	foreach ($entity->getChildren() as $child) {
434
+	  $earliest = $this->getEarliestEntityInfluence($ranking, $child, $entityIsRanked);
435
+	  if ($result === null || ($earliest !== null && $earliest < $result)) {
436
+		$result = $earliest;
437
+	  }
438
+	}
439
+	return $result;
440 440
   }
441 441
 
442 442
   /** @noinspection PhpDocMissingThrowsInspection */ //PropertyNotExistingException
@@ -450,35 +450,35 @@  discard block
 block discarded – undo
450 450
    * @param int $nextEntityIndex the first index in the entities list to consider
451 451
    */
452 452
   private function recomputeBasedOn(RankingSystemList $list, RankingSystemList $base, array $entities,
453
-                                    int &$nextEntityIndex)
453
+									int &$nextEntityIndex)
454 454
   {
455
-    $this->cloneInto($list, $base);
456
-    for ($i = $nextEntityIndex; $i < count($entities); $i++) {
457
-      $time = $this->timeService->getTime($entities[$i]);
458
-      if (!$list->isCurrent() && $time > $list->getLastEntryTime()) {
459
-        $nextEntityIndex = $i;
460
-        return;
461
-      }
462
-      $changes = $this->getChanges($entities[$nextEntityIndex], $list);
463
-      foreach ($changes as $change) {
464
-        $entry = $this->getOrCreateRankingSystemListEntry($list, $change->getPlayer());
465
-        $entry->setNumberRankedEntities($entry->getNumberRankedEntities() + 1);
466
-        $pointsAfterwards = $entry->getPoints() + $change->getPointsChange();
467
-        $entry->setPoints($pointsAfterwards);
468
-        $change->setPointsAfterwards($pointsAfterwards);
469
-        //apply further changes
470
-        foreach ($this->getAdditionalFields() as $field => $value) {
471
-          // PropertyNotExistingException => entry and field have exactly the static properties from getAdditionalFields
472
-          /** @noinspection PhpUnhandledExceptionInspection */
473
-          $entry->setProperty($field, $entry->getProperty($field) + $change->getProperty($field));
474
-        }
475
-        if ($time > $list->getLastEntryTime()) {
476
-          $list->setLastEntryTime($time);
477
-        }
478
-        $this->entityManager->persist($change);
479
-      }
480
-    }
481
-    $nextEntityIndex = count($entities);
455
+	$this->cloneInto($list, $base);
456
+	for ($i = $nextEntityIndex; $i < count($entities); $i++) {
457
+	  $time = $this->timeService->getTime($entities[$i]);
458
+	  if (!$list->isCurrent() && $time > $list->getLastEntryTime()) {
459
+		$nextEntityIndex = $i;
460
+		return;
461
+	  }
462
+	  $changes = $this->getChanges($entities[$nextEntityIndex], $list);
463
+	  foreach ($changes as $change) {
464
+		$entry = $this->getOrCreateRankingSystemListEntry($list, $change->getPlayer());
465
+		$entry->setNumberRankedEntities($entry->getNumberRankedEntities() + 1);
466
+		$pointsAfterwards = $entry->getPoints() + $change->getPointsChange();
467
+		$entry->setPoints($pointsAfterwards);
468
+		$change->setPointsAfterwards($pointsAfterwards);
469
+		//apply further changes
470
+		foreach ($this->getAdditionalFields() as $field => $value) {
471
+		  // PropertyNotExistingException => entry and field have exactly the static properties from getAdditionalFields
472
+		  /** @noinspection PhpUnhandledExceptionInspection */
473
+		  $entry->setProperty($field, $entry->getProperty($field) + $change->getProperty($field));
474
+		}
475
+		if ($time > $list->getLastEntryTime()) {
476
+		  $list->setLastEntryTime($time);
477
+		}
478
+		$this->entityManager->persist($change);
479
+	  }
480
+	}
481
+	$nextEntityIndex = count($entities);
482 482
   }
483 483
 //</editor-fold desc="Private Methods">
484 484
 }
485 485
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -29,8 +29,7 @@  discard block
 block discarded – undo
29 29
  * @package Tfboe\FmLib\Service\RankingSystemService
30 30
  * @SuppressWarnings(PHPMD) TODO: refactor this class and remove suppress warnings
31 31
  */
32
-abstract class RankingSystemService implements RankingSystemInterface
33
-{
32
+abstract class RankingSystemService implements RankingSystemInterface {
34 33
 //<editor-fold desc="Fields">
35 34
   /** @var EntityManagerInterface */
36 35
   private $entityManager;
@@ -67,8 +66,7 @@  discard block
 block discarded – undo
67 66
    * @param EntityComparerInterface $entityComparer
68 67
    */
69 68
   public function __construct(EntityManagerInterface $entityManager, TimeServiceInterface $timeService,
70
-                              EntityComparerInterface $entityComparer)
71
-  {
69
+                              EntityComparerInterface $entityComparer) {
72 70
     $this->entityManager = $entityManager;
73 71
     $this->timeService = $timeService;
74 72
     $this->entityComparer = $entityComparer;
@@ -91,8 +89,7 @@  discard block
 block discarded – undo
91 89
    * @inheritdoc
92 90
    */
93 91
   public function updateRankingForTournament(RankingSystem $ranking, Tournament $tournament,
94
-                                             ?\DateTime $oldInfluence)
95
-  {
92
+                                             ?\DateTime $oldInfluence) {
96 93
     $earliestInfluence = $this->getEarliestInfluence($ranking, $tournament);
97 94
     if ($oldInfluence !== null &&
98 95
       ($earliestInfluence === null || $oldInfluence < $earliestInfluence)) {
@@ -106,8 +103,7 @@  discard block
 block discarded – undo
106 103
   /**
107 104
    * @inheritDoc
108 105
    */
109
-  public function updateRankingFrom(RankingSystem $ranking, \DateTime $from)
110
-  {
106
+  public function updateRankingFrom(RankingSystem $ranking, \DateTime $from) {
111 107
     // can only be called once per ranking system!!!
112 108
     if (array_key_exists($ranking->getId(), $this->updateRankingCalls)) {
113 109
       throw new PreconditionFailedException();
@@ -228,8 +224,7 @@  discard block
 block discarded – undo
228 224
    * @return RankingSystemChange the found or newly created ranking system change
229 225
    */
230 226
   protected final function getOrCreateChange(TournamentHierarchyEntity $entity, RankingSystem $ranking,
231
-                                             Player $player)
232
-  {
227
+                                             Player $player) {
233 228
     $key1 = $entity->getId();
234 229
     $key2 = $ranking->getId();
235 230
     $key3 = $player->getPlayerId();
@@ -348,8 +343,7 @@  discard block
 block discarded – undo
348 343
    * @param RankingSystemList $list the ranking list to change
349 344
    * @param RankingSystemList $base the ranking list to use as base list, this doesn't get changed
350 345
    */
351
-  private function cloneInto(RankingSystemList $list, RankingSystemList $base)
352
-  {
346
+  private function cloneInto(RankingSystemList $list, RankingSystemList $base) {
353 347
     /*//first remove all entries from list
354 348
     foreach($list->getEntries()->toArray() as $entry)
355 349
     {
@@ -389,8 +383,7 @@  discard block
 block discarded – undo
389 383
    * @param RankingSystem $ranking
390 384
    * @param TournamentHierarchyEntity[] $entities
391 385
    */
392
-  private function deleteOldChanges(RankingSystem $ranking, array $entities)
393
-  {
386
+  private function deleteOldChanges(RankingSystem $ranking, array $entities) {
394 387
     //delete old changes
395 388
     $queryBuilder = $this->entityManager->createQueryBuilder();
396 389
     /** @var RankingSystemChange[] $changes */
@@ -450,8 +443,7 @@  discard block
 block discarded – undo
450 443
    * @param int $nextEntityIndex the first index in the entities list to consider
451 444
    */
452 445
   private function recomputeBasedOn(RankingSystemList $list, RankingSystemList $base, array $entities,
453
-                                    int &$nextEntityIndex)
454
-  {
446
+                                    int &$nextEntityIndex) {
455 447
     $this->cloneInto($list, $base);
456 448
     for ($i = $nextEntityIndex; $i < count($entities); $i++) {
457 449
       $time = $this->timeService->getTime($entities[$i]);
Please login to merge, or discard this patch.
config-example/jwt.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
   'keys' => [
49 49
 
50
-    /*
50
+	/*
51 51
     |--------------------------------------------------------------------------
52 52
     | Public Key
53 53
     |--------------------------------------------------------------------------
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
     |
59 59
     */
60 60
 
61
-    'public' => env('JWT_PUBLIC_KEY'),
61
+	'public' => env('JWT_PUBLIC_KEY'),
62 62
 
63
-    /*
63
+	/*
64 64
     |--------------------------------------------------------------------------
65 65
     | Private Key
66 66
     |--------------------------------------------------------------------------
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
     |
72 72
     */
73 73
 
74
-    'private' => env('JWT_PRIVATE_KEY'),
74
+	'private' => env('JWT_PRIVATE_KEY'),
75 75
 
76
-    /*
76
+	/*
77 77
     |--------------------------------------------------------------------------
78 78
     | Passphrase
79 79
     |--------------------------------------------------------------------------
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     |
83 83
     */
84 84
 
85
-    'passphrase' => env('JWT_PASSPHRASE'),
85
+	'passphrase' => env('JWT_PASSPHRASE'),
86 86
 
87 87
   ],
88 88
 
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
   */
149 149
 
150 150
   'required_claims' => [
151
-    'iss',
152
-    'iat',
153
-    'exp',
154
-    'nbf',
155
-    'sub',
156
-    'jti',
151
+	'iss',
152
+	'iat',
153
+	'exp',
154
+	'nbf',
155
+	'sub',
156
+	'jti',
157 157
   ],
158 158
 
159 159
   /*
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
   */
171 171
 
172 172
   'persistent_claims' => [
173
-    // 'foo',
174
-    // 'bar',
173
+	// 'foo',
174
+	// 'bar',
175 175
   ],
176 176
 
177 177
   /*
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 
213 213
   'providers' => [
214 214
 
215
-    /*
215
+	/*
216 216
     |--------------------------------------------------------------------------
217 217
     | JWT Provider
218 218
     |--------------------------------------------------------------------------
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
     |
222 222
     */
223 223
 
224
-    'jwt' => Tymon\JWTAuth\Providers\JWT\Namshi::class,
224
+	'jwt' => Tymon\JWTAuth\Providers\JWT\Namshi::class,
225 225
 
226
-    /*
226
+	/*
227 227
     |--------------------------------------------------------------------------
228 228
     | Authentication Provider
229 229
     |--------------------------------------------------------------------------
@@ -232,9 +232,9 @@  discard block
 block discarded – undo
232 232
     |
233 233
     */
234 234
 
235
-    'auth' => Tymon\JWTAuth\Providers\Auth\Illuminate::class,
235
+	'auth' => Tymon\JWTAuth\Providers\Auth\Illuminate::class,
236 236
 
237
-    /*
237
+	/*
238 238
     |--------------------------------------------------------------------------
239 239
     | Storage Provider
240 240
     |--------------------------------------------------------------------------
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     |
244 244
     */
245 245
 
246
-    'storage' => Tymon\JWTAuth\Providers\Storage\Illuminate::class,
246
+	'storage' => Tymon\JWTAuth\Providers\Storage\Illuminate::class,
247 247
 
248 248
   ],
249 249
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
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.
Please login to merge, or discard this patch.
config-example/database.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -29,16 +29,16 @@
 block discarded – undo
29 29
   |
30 30
   */
31 31
   'connections' => [
32
-    'mysql' => [
33
-      'driver' => 'mysql',
34
-      'host' => env('DB_HOST', 'localhost'),
35
-      'database' => env('DB_DATABASE'),
36
-      'username' => env('DB_USERNAME'),
37
-      'password' => env('DB_PASSWORD'),
38
-      'charset' => 'utf8',
39
-      'collation' => 'utf8_unicode_ci',
40
-      'prefix' => '',
41
-      'strict' => false,
42
-    ]
32
+	'mysql' => [
33
+	  'driver' => 'mysql',
34
+	  'host' => env('DB_HOST', 'localhost'),
35
+	  'database' => env('DB_DATABASE'),
36
+	  'username' => env('DB_USERNAME'),
37
+	  'password' => env('DB_PASSWORD'),
38
+	  'charset' => 'utf8',
39
+	  'collation' => 'utf8_unicode_ci',
40
+	  'prefix' => '',
41
+	  'strict' => false,
42
+	]
43 43
   ],
44 44
 ];
45 45
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 
4 4
 return [
5 5
   /*
Please login to merge, or discard this patch.
config-example/auth.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -3,22 +3,22 @@
 block discarded – undo
3 3
 
4 4
 return [
5 5
   'defaults' => [
6
-    'guard' => env('AUTH_GUARD', 'api'),
7
-    'passwords' => 'users',
6
+	'guard' => env('AUTH_GUARD', 'api'),
7
+	'passwords' => 'users',
8 8
   ],
9 9
   'guards' => [
10
-    'api' => [
11
-      'driver' => 'jwt-auth',
12
-      'provider' => 'users'
13
-    ],
10
+	'api' => [
11
+	  'driver' => 'jwt-auth',
12
+	  'provider' => 'users'
13
+	],
14 14
 
15
-    // ...
15
+	// ...
16 16
   ],
17 17
 
18 18
   'providers' => [
19
-    'users' => [
20
-      'driver' => 'doctrine',
21
-      'model' => \Tfboe\FmLib\Entity\User::class
22
-    ],
19
+	'users' => [
20
+	  'driver' => 'doctrine',
21
+	  'model' => \Tfboe\FmLib\Entity\User::class
22
+	],
23 23
   ],
24 24
 ];
25 25
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 
4 4
 return [
5 5
   'defaults' => [
Please login to merge, or discard this patch.
config-example/doctrine.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -22,23 +22,23 @@  discard block
 block discarded – undo
22 22
   |
23 23
   */
24 24
   'managers' => [
25
-    'default' => [
26
-      'dev' => env('APP_DEBUG'),
27
-      'meta' => env('DOCTRINE_METADATA', 'annotations'),
28
-      'connection' => env('DB_CONNECTION', 'mysql'),
29
-      'namespaces' => [
30
-        'Tfboe\FmLib\Entity'
31
-      ],
32
-      'paths' => [
33
-        base_path('vendor/tfboe/fm-lib/src/Entity'),
34
-      ],
35
-      'repository' => Doctrine\ORM\EntityRepository::class,
36
-      'proxies' => [
37
-        'namespace' => false,
38
-        'path' => storage_path('proxies'),
39
-        'auto_generate' => env('DOCTRINE_PROXY_AUTOGENERATE', false)
40
-      ],
41
-      /*
25
+	'default' => [
26
+	  'dev' => env('APP_DEBUG'),
27
+	  'meta' => env('DOCTRINE_METADATA', 'annotations'),
28
+	  'connection' => env('DB_CONNECTION', 'mysql'),
29
+	  'namespaces' => [
30
+		'Tfboe\FmLib\Entity'
31
+	  ],
32
+	  'paths' => [
33
+		base_path('vendor/tfboe/fm-lib/src/Entity'),
34
+	  ],
35
+	  'repository' => Doctrine\ORM\EntityRepository::class,
36
+	  'proxies' => [
37
+		'namespace' => false,
38
+		'path' => storage_path('proxies'),
39
+		'auto_generate' => env('DOCTRINE_PROXY_AUTOGENERATE', false)
40
+	  ],
41
+	  /*
42 42
       |--------------------------------------------------------------------------
43 43
       | Doctrine events
44 44
       |--------------------------------------------------------------------------
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
       | e.g. Doctrine\ORM\Events::onFlush
48 48
       |
49 49
       */
50
-      'events' => [
51
-        'listeners' => [],
52
-        'subscribers' => []
53
-      ],
54
-      'filters' => [],
55
-      /*
50
+	  'events' => [
51
+		'listeners' => [],
52
+		'subscribers' => []
53
+	  ],
54
+	  'filters' => [],
55
+	  /*
56 56
       |--------------------------------------------------------------------------
57 57
       | Doctrine mapping types
58 58
       |--------------------------------------------------------------------------
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
       | http://symfony.com/doc/current/cookbook/doctrine/dbal.html#registering-custom-mapping-types-in-the-schematool
76 76
       |--------------------------------------------------------------------------
77 77
       */
78
-      'mapping_types' => [
79
-        //'enum' => 'string'
80
-      ]
81
-    ]
78
+	  'mapping_types' => [
79
+		//'enum' => 'string'
80
+	  ]
81
+	]
82 82
   ],
83 83
   /*
84 84
   |--------------------------------------------------------------------------
@@ -92,16 +92,16 @@  discard block
 block discarded – undo
92 92
   |
93 93
   */
94 94
   'extensions' => [
95
-    //LaravelDoctrine\ORM\Extensions\TablePrefix\TablePrefixExtension::class,
96
-    LaravelDoctrine\Extensions\Timestamps\TimestampableExtension::class,
97
-    //LaravelDoctrine\Extensions\SoftDeletes\SoftDeleteableExtension::class,
98
-    //LaravelDoctrine\Extensions\Sluggable\SluggableExtension::class,
99
-    //LaravelDoctrine\Extensions\Sortable\SortableExtension::class,
100
-    //LaravelDoctrine\Extensions\Tree\TreeExtension::class,
101
-    //LaravelDoctrine\Extensions\Loggable\LoggableExtension::class,
102
-    //LaravelDoctrine\Extensions\Blameable\BlameableExtension::class,
103
-    //LaravelDoctrine\Extensions\IpTraceable\IpTraceableExtension::class,
104
-    //LaravelDoctrine\Extensions\Translatable\TranslatableExtension::class
95
+	//LaravelDoctrine\ORM\Extensions\TablePrefix\TablePrefixExtension::class,
96
+	LaravelDoctrine\Extensions\Timestamps\TimestampableExtension::class,
97
+	//LaravelDoctrine\Extensions\SoftDeletes\SoftDeleteableExtension::class,
98
+	//LaravelDoctrine\Extensions\Sluggable\SluggableExtension::class,
99
+	//LaravelDoctrine\Extensions\Sortable\SortableExtension::class,
100
+	//LaravelDoctrine\Extensions\Tree\TreeExtension::class,
101
+	//LaravelDoctrine\Extensions\Loggable\LoggableExtension::class,
102
+	//LaravelDoctrine\Extensions\Blameable\BlameableExtension::class,
103
+	//LaravelDoctrine\Extensions\IpTraceable\IpTraceableExtension::class,
104
+	//LaravelDoctrine\Extensions\Translatable\TranslatableExtension::class
105 105
   ],
106 106
   /*
107 107
   |--------------------------------------------------------------------------
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
   |--------------------------------------------------------------------------
113 113
   */
114 114
   'custom_types' => [
115
-    'json' => LaravelDoctrine\ORM\Types\Json::class
115
+	'json' => LaravelDoctrine\ORM\Types\Json::class
116 116
   ],
117 117
   /*
118 118
   |--------------------------------------------------------------------------
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
   |
158 158
   */
159 159
   'cache' => [
160
-    'default' => env('DOCTRINE_CACHE', 'array'),
161
-    'namespace' => null,
162
-    'second_level' => false,
160
+	'default' => env('DOCTRINE_CACHE', 'array'),
161
+	'namespace' => null,
162
+	'second_level' => false,
163 163
   ],
164 164
   /*
165 165
   |--------------------------------------------------------------------------
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
   |
173 173
   */
174 174
   'gedmo' => [
175
-    'all_mappings' => false
175
+	'all_mappings' => false
176 176
   ],
177 177
   /*
178 178
    |--------------------------------------------------------------------------
@@ -193,6 +193,6 @@  discard block
 block discarded – undo
193 193
    |
194 194
    */
195 195
   'notifications' => [
196
-    'channel' => 'database'
196
+	'channel' => 'database'
197 197
   ]
198 198
 ];
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 
4 4
 return [
5 5
 
Please login to merge, or discard this patch.
config-example/cache.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -13,28 +13,28 @@
 block discarded – undo
13 13
   |
14 14
   */
15 15
   'stores' => [
16
-    'array' => [
17
-      'driver' => 'array'
18
-    ],
19
-    'apc' => [
20
-      'driver' => 'apc',
21
-    ],
22
-    'file' => [
23
-      'driver' => 'file',
24
-      'path' => storage_path('framework/cache'),
25
-    ],
26
-    'memcached' => [
27
-      'driver' => 'memcached',
28
-      'servers' => [
29
-        [
30
-          'host' => '127.0.0.1', 'port' => 11211, 'weight' => 100,
31
-        ],
32
-      ],
33
-    ],
34
-    'redis' => [
35
-      'driver' => 'redis',
36
-      'connection' => 'default',
37
-    ],
16
+	'array' => [
17
+	  'driver' => 'array'
18
+	],
19
+	'apc' => [
20
+	  'driver' => 'apc',
21
+	],
22
+	'file' => [
23
+	  'driver' => 'file',
24
+	  'path' => storage_path('framework/cache'),
25
+	],
26
+	'memcached' => [
27
+	  'driver' => 'memcached',
28
+	  'servers' => [
29
+		[
30
+		  'host' => '127.0.0.1', 'port' => 11211, 'weight' => 100,
31
+		],
32
+	  ],
33
+	],
34
+	'redis' => [
35
+	  'driver' => 'redis',
36
+	  'connection' => 'default',
37
+	],
38 38
   ],
39 39
 
40 40
   'default' => env('CACHE_DRIVER'),
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 
4 4
 return [
5 5
   /*
Please login to merge, or discard this patch.
src/Claims/Version.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 /**
4 4
  * Created by PhpStorm.
5 5
  * User: benedikt
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,8 +15,7 @@
 block discarded – undo
15 15
  * Class Version
16 16
  * @package App\Claims
17 17
  */
18
-class Version extends Claim
19
-{
18
+class Version extends Claim {
20 19
 //<editor-fold desc="Fields">
21 20
   /**
22 21
    * {@inheritdoc}
Please login to merge, or discard this patch.