Completed
Branch master (0dfbed)
by Benedikt
07:50
created
src/Entity/Game.php 2 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.
src/Service/RankingSystem/EloRanking.php 2 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.
src/Service/RankingSystem/RankingSystemService.php 2 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.
config-example/jwt.php 1 patch
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.
config-example/database.php 1 patch
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.
config-example/auth.php 1 patch
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.
config-example/doctrine.php 1 patch
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.
config-example/cache.php 1 patch
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.
src/routes.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
    *                               too short
21 21
    */
22 22
   $router->post('register', [
23
-    'as' => 'register', 'uses' => 'UserController@register'
23
+	'as' => 'register', 'uses' => 'UserController@register'
24 24
   ]);
25 25
 
26 26
   /**
@@ -39,22 +39,22 @@  discard block
 block discarded – undo
39 39
    *                               too short
40 40
    */
41 41
   $router->post('login', [
42
-    'as' => 'login', 'uses' => 'UserController@login'
42
+	'as' => 'login', 'uses' => 'UserController@login'
43 43
   ]);
44 44
 
45 45
   $router->group(['middleware' => 'auth:api'], function () use ($router) {
46
-    /**
47
-     * @api {get} /userId Get User ID
48
-     * @apiUse AuthenticatedRequest
49
-     * @apiVersion 0.1.0
50
-     * @apiDescription Gets the user id of the currently logged in user
51
-     * @apiName GetUserId
52
-     * @apiGroup User
53
-     *
54
-     * @apiSuccess {string} id the id of the user
55
-     */
56
-    $router->get('userId', [
57
-      'as' => 'userId', 'uses' => 'UserController@userId'
58
-    ]);
46
+	/**
47
+	 * @api {get} /userId Get User ID
48
+	 * @apiUse AuthenticatedRequest
49
+	 * @apiVersion 0.1.0
50
+	 * @apiDescription Gets the user id of the currently logged in user
51
+	 * @apiName GetUserId
52
+	 * @apiGroup User
53
+	 *
54
+	 * @apiSuccess {string} id the id of the user
55
+	 */
56
+	$router->get('userId', [
57
+	  'as' => 'userId', 'uses' => 'UserController@userId'
58
+	]);
59 59
   });
60 60
 });
61 61
\ No newline at end of file
Please login to merge, or discard this patch.