Completed
Push — master ( 2ab3b9...3652cb )
by Michael
02:59
created
app/controllers/LeagueStatisticsController.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
58 58
 	 * Show the form for editing the specified resource.
59 59
 	 *
60 60
 	 * @param  int  $id
61
-	 * @return Response
61
+	 * @return integer
62 62
 	 */
63 63
 	public function edit($id)
64 64
 	{
Please login to merge, or discard this patch.
app/library/Classes/Statistics/LeagueStatistics.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -3,36 +3,36 @@
 block discarded – undo
3 3
 
4 4
 interface LeagueStatistics {
5 5
 
6
-    public function topFiveLowestScores();
7
-    public function topFiveLowestScoresByYear($year);
8
-    public function topFiveScoringAverageByYear($year);
9
-    public function topFiveNetScoresByYear($year);
10
-    public function mostSkinsByYear($year);
11
-    public function totalEagles($year);
12
-    public function totalBirdies($year);
13
-    public function totalPars($year);
14
-    public function totalBogeys($year);
15
-    public function totalDoubles($year);
16
-    public function totalOthers($year);
6
+	public function topFiveLowestScores();
7
+	public function topFiveLowestScoresByYear($year);
8
+	public function topFiveScoringAverageByYear($year);
9
+	public function topFiveNetScoresByYear($year);
10
+	public function mostSkinsByYear($year);
11
+	public function totalEagles($year);
12
+	public function totalBirdies($year);
13
+	public function totalPars($year);
14
+	public function totalBogeys($year);
15
+	public function totalDoubles($year);
16
+	public function totalOthers($year);
17 17
 
18
-    public function netScoresByPlayer($playerId);
19
-    public function netScoresByPlayerTop($playerId,$number);
20
-    public function netScoresByPlayerYear($playerId, $year);
21
-    public function netScoresByPlayerTopYear($playerId,$top, $year);
18
+	public function netScoresByPlayer($playerId);
19
+	public function netScoresByPlayerTop($playerId,$number);
20
+	public function netScoresByPlayerYear($playerId, $year);
21
+	public function netScoresByPlayerTopYear($playerId,$top, $year);
22 22
 
23
-    public function netScoresLeague();
24
-    public function netScoresLeagueTop($number);
25
-    public function netScoresLeagueYear($year);
26
-    public function netScoresLeagueTopYear($top,$year);
23
+	public function netScoresLeague();
24
+	public function netScoresLeagueTop($number);
25
+	public function netScoresLeagueYear($year);
26
+	public function netScoresLeagueTopYear($top,$year);
27 27
 
28
-    // Cumulative Net returns +/- relative to par
29
-    public function netCumulative();
30
-    public function netCumulativeTop($top);
31
-    public function netCumulativeByPlayer($playerId);
32
-    public function netCumulativeByPlayerTop($playerId,$top);
33
-    public function netCumulativeYear($year);
34
-    public function netCumulativeTopYear($top,$year);
35
-    public function netCumulativeByPlayerYear($playerId,$year);
36
-    public function netCumulativeByPlayerTopYear($playerId,$top,$year);
28
+	// Cumulative Net returns +/- relative to par
29
+	public function netCumulative();
30
+	public function netCumulativeTop($top);
31
+	public function netCumulativeByPlayer($playerId);
32
+	public function netCumulativeByPlayerTop($playerId,$top);
33
+	public function netCumulativeYear($year);
34
+	public function netCumulativeTopYear($top,$year);
35
+	public function netCumulativeByPlayerYear($playerId,$year);
36
+	public function netCumulativeByPlayerTopYear($playerId,$top,$year);
37 37
 
38 38
 }
39 39
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -16,23 +16,23 @@
 block discarded – undo
16 16
     public function totalOthers($year);
17 17
 
18 18
     public function netScoresByPlayer($playerId);
19
-    public function netScoresByPlayerTop($playerId,$number);
19
+    public function netScoresByPlayerTop($playerId, $number);
20 20
     public function netScoresByPlayerYear($playerId, $year);
21
-    public function netScoresByPlayerTopYear($playerId,$top, $year);
21
+    public function netScoresByPlayerTopYear($playerId, $top, $year);
22 22
 
23 23
     public function netScoresLeague();
24 24
     public function netScoresLeagueTop($number);
25 25
     public function netScoresLeagueYear($year);
26
-    public function netScoresLeagueTopYear($top,$year);
26
+    public function netScoresLeagueTopYear($top, $year);
27 27
 
28 28
     // Cumulative Net returns +/- relative to par
29 29
     public function netCumulative();
30 30
     public function netCumulativeTop($top);
31 31
     public function netCumulativeByPlayer($playerId);
32
-    public function netCumulativeByPlayerTop($playerId,$top);
32
+    public function netCumulativeByPlayerTop($playerId, $top);
33 33
     public function netCumulativeYear($year);
34
-    public function netCumulativeTopYear($top,$year);
35
-    public function netCumulativeByPlayerYear($playerId,$year);
36
-    public function netCumulativeByPlayerTopYear($playerId,$top,$year);
34
+    public function netCumulativeTopYear($top, $year);
35
+    public function netCumulativeByPlayerYear($playerId, $year);
36
+    public function netCumulativeByPlayerTopYear($playerId, $top, $year);
37 37
 
38 38
 }
39 39
\ No newline at end of file
Please login to merge, or discard this patch.
app/library/Classes/Statistics/LeagueStatisticsEloquent.php 2 patches
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
 {
13 13
     public function topFiveLowestScores()
14 14
     {
15
-        return Round::with('player','course')->orderBy('score')->take(5)->get();
15
+        return Round::with('player', 'course')->orderBy('score')->take(5)->get();
16 16
     }
17 17
     public function topFiveLowestScoresByYear($year)
18 18
     {
19
-        $date1 = $year . '-01-01';
20
-        $date2 = $year . '-12-31';
19
+        $date1 = $year.'-01-01';
20
+        $date2 = $year.'-12-31';
21 21
         return Round::with('player', 'course')
22 22
             ->where('match_id', '>', '0')
23 23
             ->where('date', '>=', $date1)
@@ -31,23 +31,23 @@  discard block
 block discarded – undo
31 31
         //Get players
32 32
         //For each player where match > 0 select scores and average them
33 33
         //Store in players array
34
-        $date1 = $year . '-01-01';
35
-        $date2 = $year . '-12-31';
34
+        $date1 = $year.'-01-01';
35
+        $date2 = $year.'-12-31';
36 36
         $players = Player::all();
37 37
         $average = array();
38 38
         $i = 0;
39
-        foreach($players as $key => $player) {
39
+        foreach ($players as $key => $player) {
40 40
             $rounds = Round::where('match_id', '>', '0')
41 41
                 ->where('player_id', '=', $player->id)
42 42
                 ->where('date', '>=', $date1)
43 43
                 ->where('date', '<=', $date2)
44 44
                 ->get();
45 45
             $scores = array();
46
-			foreach($rounds as $round) {
46
+			foreach ($rounds as $round) {
47 47
 				$scores[] = $round->score;
48 48
 			}
49
-            if(count($scores) > 0) {
50
-                $average[$i]['average'] = round((array_sum($scores) / count($scores)) ,2);
49
+            if (count($scores) > 0) {
50
+                $average[$i]['average'] = round((array_sum($scores) / count($scores)), 2);
51 51
                 $average[$i]['player_id'] = $player->id;
52 52
                 $average[$i]['name'] = $player->name;
53 53
                 $average[$i]['rounds'] = count($scores);
@@ -59,26 +59,26 @@  discard block
 block discarded – undo
59 59
     }
60 60
     public function topFiveNetScoresByYear($year)
61 61
     {
62
-		$date1 = $year . '-01-01';
63
-		$date2 = $year . '-12-31';
62
+		$date1 = $year.'-01-01';
63
+		$date2 = $year.'-12-31';
64 64
 
65
-		return Netwinner::with('player','match','match.course')
65
+		return Netwinner::with('player', 'match', 'match.course')
66 66
 				->where('created_at', '>=', $date1)
67 67
 				->where('created_at', '<=', $date2)
68 68
 				->orderBy('score')->take(5)->get();
69 69
     }
70 70
     public function mostSkinsByYear($year)
71 71
     {
72
-        $year = $year . '-01-01';
72
+        $year = $year.'-01-01';
73 73
         $players = Player::all();
74 74
         $i = 0;
75 75
         $skinsCount = array();
76
-        foreach($players as $key => $player) {
77
-            $skins = Skin::with('player','level')
76
+        foreach ($players as $key => $player) {
77
+            $skins = Skin::with('player', 'level')
78 78
                 ->where('player_id', '=', $player->id)
79 79
                 ->where('created_at', '>', $year)
80 80
                 ->get();
81
-            if(count($skins) > 0) {
81
+            if (count($skins) > 0) {
82 82
                 $skinsCount[$i]['skins'] = $skins->count();
83 83
                 $skinsCount[$i]['name'] = $player->name;
84 84
                 $i++;
@@ -87,66 +87,66 @@  discard block
 block discarded – undo
87 87
         array_multisort($skinsCount, SORT_DESC);
88 88
         return $skinsCount;
89 89
     }
90
-    public function totalEagles($year){}
90
+    public function totalEagles($year) {}
91 91
     public function totalBirdies($year)
92 92
 	{
93
-		$year = $year . '-01-01';
94
-		$holescores = Holescore::with('round.player','hole')
93
+		$year = $year.'-01-01';
94
+		$holescores = Holescore::with('round.player', 'hole')
95 95
 			->where('created_at', '>', $year)
96 96
 			->get();
97 97
 		$allBirdies = array();
98
-		foreach($holescores as $key => $holescore) {
99
-			if($holescore['round']['match_id'] != null){
100
-				if( ($holescore['hole']['par'] - $holescore['score']) === 1) {
101
-						$allBirdies[]= $holescore['round']['player']['name'];
98
+		foreach ($holescores as $key => $holescore) {
99
+			if ($holescore['round']['match_id'] != null) {
100
+				if (($holescore['hole']['par'] - $holescore['score']) === 1) {
101
+						$allBirdies[] = $holescore['round']['player']['name'];
102 102
 				}
103 103
 			}
104 104
 		}
105
-		$i =0;
105
+		$i = 0;
106 106
 		$newArray = array_count_values($allBirdies);
107 107
 			$birds = array();
108 108
 			foreach ($newArray as $key => $value) {
109 109
 				$birds[$i]['name'] = $key;
110
-				$birds[$i]['birds'] =$value;
110
+				$birds[$i]['birds'] = $value;
111 111
 				$i++;
112 112
 			}
113 113
 			return $birds;
114 114
 	}
115 115
     public function totalPars($year)
116 116
 	{
117
-		$year = $year . '-01-01';
118
-		$holescores = Holescore::with('round.player','hole')
117
+		$year = $year.'-01-01';
118
+		$holescores = Holescore::with('round.player', 'hole')
119 119
 			->where('created_at', '>', $year)
120 120
 			->get();
121 121
 		$allPars = array();
122
-		foreach($holescores as $key => $holescore) {
123
-			if($holescore['round']['match_id'] != null){
124
-				if( ($holescore['hole']['par'] - $holescore['score']) === 0) {
125
-						$allPars[]= $holescore['round']['player']['name'];
122
+		foreach ($holescores as $key => $holescore) {
123
+			if ($holescore['round']['match_id'] != null) {
124
+				if (($holescore['hole']['par'] - $holescore['score']) === 0) {
125
+						$allPars[] = $holescore['round']['player']['name'];
126 126
 				}
127 127
 			}
128 128
 		}
129
-		$i =0;
129
+		$i = 0;
130 130
 		$newArray = array_count_values($allPars);
131 131
 			$pars = array();
132 132
 			foreach ($newArray as $key => $value) {
133 133
 				$pars[$i]['name'] = $key;
134
-				$pars[$i]['pars'] =$value;
134
+				$pars[$i]['pars'] = $value;
135 135
 				$i++;
136 136
 			}
137 137
 			return $pars;
138 138
 	}
139 139
     public function totalBogeys($year)
140 140
 	{
141
-		$year = $year . '-01-01';
142
-		$holescores = Holescore::with('round.player','hole')
141
+		$year = $year.'-01-01';
142
+		$holescores = Holescore::with('round.player', 'hole')
143 143
 			->where('created_at', '>', $year)
144 144
 			->get();
145 145
 		$allBogeys = array();
146
-		foreach($holescores as $key => $holescore) {
147
-			if($holescore['round']['match_id'] != null){
148
-				if( ($holescore['score'] - $holescore['hole']['par']) === 1) {
149
-						$allBogeys[]= $holescore['round']['player']['name'];
146
+		foreach ($holescores as $key => $holescore) {
147
+			if ($holescore['round']['match_id'] != null) {
148
+				if (($holescore['score'] - $holescore['hole']['par']) === 1) {
149
+						$allBogeys[] = $holescore['round']['player']['name'];
150 150
 				}
151 151
 			}
152 152
 		}
@@ -155,22 +155,22 @@  discard block
 block discarded – undo
155 155
 		$bogeys = array();
156 156
 			foreach ($newArray as $key => $value) {
157 157
 				$bogeys[$i]['name'] = $key;
158
-				$bogeys[$i]['bogeys'] =$value;
158
+				$bogeys[$i]['bogeys'] = $value;
159 159
 				$i++;
160 160
 			}
161 161
 		return $bogeys;
162 162
 	}
163 163
     public function totalDoubles($year)
164 164
 	{
165
-		$year = $year . '-01-01';
166
-		$holescores = Holescore::with('round.player','hole')
165
+		$year = $year.'-01-01';
166
+		$holescores = Holescore::with('round.player', 'hole')
167 167
 			->where('created_at', '>', $year)
168 168
 			->get();
169 169
 		$allDoubles = array();
170
-		foreach($holescores as $key => $holescore) {
171
-			if($holescore['round']['match_id'] != null){
172
-				if( ($holescore['score'] - $holescore['hole']['par']) === 2) {
173
-						$allDoubles[]= $holescore['round']['player']['name'];
170
+		foreach ($holescores as $key => $holescore) {
171
+			if ($holescore['round']['match_id'] != null) {
172
+				if (($holescore['score'] - $holescore['hole']['par']) === 2) {
173
+						$allDoubles[] = $holescore['round']['player']['name'];
174 174
 				}
175 175
 			}
176 176
 		}
@@ -179,22 +179,22 @@  discard block
 block discarded – undo
179 179
 			$doubles = array();
180 180
 			foreach ($newArray as $key => $value) {
181 181
 				$doubles[$i]['name'] = $key;
182
-				$doubles[$i]['doubles'] =$value;
182
+				$doubles[$i]['doubles'] = $value;
183 183
 				$i++;
184 184
 			}
185 185
 		return $doubles;
186 186
 	}
187 187
     public function totalOthers($year)
188 188
 	{
189
-		$year = $year . '-01-01';
190
-		$holescores = Holescore::with('round.player','hole')
189
+		$year = $year.'-01-01';
190
+		$holescores = Holescore::with('round.player', 'hole')
191 191
 			->where('created_at', '>', $year)
192 192
 			->get();
193 193
 		$allOthers = array();
194
-		foreach($holescores as $key => $holescore) {
195
-			if($holescore['round']['match_id'] != null){
196
-				if( ($holescore['score'] - $holescore['hole']['par']) > 2) {
197
-					$allOthers[]= $holescore['round']['player']['name'];
194
+		foreach ($holescores as $key => $holescore) {
195
+			if ($holescore['round']['match_id'] != null) {
196
+				if (($holescore['score'] - $holescore['hole']['par']) > 2) {
197
+					$allOthers[] = $holescore['round']['player']['name'];
198 198
 				}
199 199
 			}
200 200
 		}
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 		$others = array();
204 204
 			foreach ($newArray as $key => $value) {
205 205
 				$others[$i]['name'] = $key;
206
-				$others[$i]['others'] =$value;
206
+				$others[$i]['others'] = $value;
207 207
 				$i++;
208 208
 			}
209 209
 		return $others;
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
 		//for each round get match handicap
221 221
 		$rounds->map(function($round)
222 222
 		{
223
-			$playerMatch = Player::find($round->player_id)->matches()->where('match_player.match_id','=', $round->match_id)->get();
224
-			foreach($playerMatch as $player){
223
+			$playerMatch = Player::find($round->player_id)->matches()->where('match_player.match_id', '=', $round->match_id)->get();
224
+			foreach ($playerMatch as $player) {
225 225
 				$handicap = $player['pivot']['handicap'];
226 226
 				$round->handicap = $handicap;
227 227
 			}
@@ -247,28 +247,28 @@  discard block
 block discarded – undo
247 247
 		return $rounds;
248 248
 
249 249
 	}
250
-	public function netScoresByPlayerTop($playerId,$top)
250
+	public function netScoresByPlayerTop($playerId, $top)
251 251
 	{
252 252
 		$netScores = $this->netScoresByPlayer($playerId);
253 253
 		return $netScores->take($top);
254 254
 	}
255 255
 	public function netScoresByPlayerYear($playerId, $year)
256 256
 	{
257
-		$date1 = $year . '-01-01';
258
-		$date2 = $date1 -1;
257
+		$date1 = $year.'-01-01';
258
+		$date2 = $date1 - 1;
259 259
 		$date2 .= '-01-01';
260 260
 		// Get players match scores
261 261
 		$rounds = Round::with('player')
262 262
 			->where('player_id', '=', $playerId)
263 263
 			->where('date', '>', $date1)
264
-			->where('date','<', $date2)
264
+			->where('date', '<', $date2)
265 265
 			->whereNotNull('match_id')->get();
266 266
 
267 267
 		//for each round get match handicap
268 268
 		$rounds->map(function($round)
269 269
 		{
270
-			$playerMatch = Player::find($round->player_id)->matches()->where('match_player.match_id','=', $round->match_id)->get();
271
-			foreach($playerMatch as $player){
270
+			$playerMatch = Player::find($round->player_id)->matches()->where('match_player.match_id', '=', $round->match_id)->get();
271
+			foreach ($playerMatch as $player) {
272 272
 				$handicap = $player['pivot']['handicap'];
273 273
 				$round->handicap = $handicap;
274 274
 			}
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 
294 294
 		return $rounds;
295 295
 	}
296
-	public function netScoresByPlayerTopYear($playerId,$top, $year)
296
+	public function netScoresByPlayerTopYear($playerId, $top, $year)
297 297
 	{
298 298
 		$netScores = $this->netScoresByPlayerYear($playerId, $year);
299 299
 		return $netScores->take($top);
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 		$players = Player::all();
306 306
 
307 307
 		$netScores = new \Illuminate\Support\Collection();
308
-		foreach($players as $player){
308
+		foreach ($players as $player) {
309 309
 			$netScores->push($this->netScoresByPlayer($player->id));
310 310
 		}
311 311
 		return $netScores;
@@ -317,9 +317,9 @@  discard block
 block discarded – undo
317 317
 		$players = Player::all();
318 318
 
319 319
 		$netScores = new \Illuminate\Support\Collection();
320
-		foreach($players as $player){
320
+		foreach ($players as $player) {
321 321
 			$netScore = $this->netScoresByPlayerTop($player->id, $number);
322
-			if(!$netScore->isEmpty()){
322
+			if ( ! $netScore->isEmpty()) {
323 323
 				$netScores->push($netScore);
324 324
 			}
325 325
 		}
@@ -332,20 +332,20 @@  discard block
 block discarded – undo
332 332
 		$players = Player::all();
333 333
 
334 334
 		$netScores = new \Illuminate\Support\Collection();
335
-		foreach($players as $player){
336
-			$netScores->push($this->netScoresByPlayerYear($player->id,$year));
335
+		foreach ($players as $player) {
336
+			$netScores->push($this->netScoresByPlayerYear($player->id, $year));
337 337
 		}
338 338
 		return $netScores;
339 339
 	}
340
-	public function netScoresLeagueTopYear($top,$year)
340
+	public function netScoresLeagueTopYear($top, $year)
341 341
 	{
342 342
 		//get players
343 343
 		$players = Player::all();
344 344
 
345 345
 		$netScores = new \Illuminate\Support\Collection();
346
-		foreach($players as $player){
346
+		foreach ($players as $player) {
347 347
 			$netScore = $this->netScoresByPlayerTopYear($player->id, $top, $year);
348
-			if(!$netScore->isEmpty()){
348
+			if ( ! $netScore->isEmpty()) {
349 349
 				$netScores->push($netScore);
350 350
 			}
351 351
 		}
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 		$players = Player::all();
360 360
 
361 361
 		$cumulativeNetScores = new \Illuminate\Support\Collection();
362
-		foreach($players as $player){
362
+		foreach ($players as $player) {
363 363
 			$cumulativeNetScores->push($this->netCumulativeByPlayer($player->id));
364 364
 		}
365 365
 		return $cumulativeNetScores;
@@ -370,9 +370,9 @@  discard block
 block discarded – undo
370 370
 		$players = Player::all();
371 371
 
372 372
 		$cumulativeNetScores = new \Illuminate\Support\Collection();
373
-		foreach($players as $player){
373
+		foreach ($players as $player) {
374 374
 			$netScore = $this->netCumulativeByPlayerTop($player->id, $top);
375
-			if($netScore->isEmpty() == false){
375
+			if ($netScore->isEmpty() == false) {
376 376
 				$cumulativeNetScores->push($netScore);
377 377
 			}
378 378
 		}
@@ -382,9 +382,9 @@  discard block
 block discarded – undo
382 382
 	public function netCumulativeByPlayer($playerId)
383 383
 	{
384 384
 		$netScores = $this->netScoresByPlayer($playerId);
385
-		$cumulativeNet= new \Illuminate\Support\Collection();
385
+		$cumulativeNet = new \Illuminate\Support\Collection();
386 386
 
387
-		if($netScores->count() > 0){
387
+		if ($netScores->count() > 0) {
388 388
 			$netScore = $netScores->first();
389 389
 
390 390
 			$totalNetScore = $netScores->sum('netScore');
@@ -398,9 +398,9 @@  discard block
 block discarded – undo
398 398
 	public function netCumulativeByPlayerTop($playerId, $top)
399 399
 	{
400 400
 		$netScores = $this->netScoresByPlayerTop($playerId, $top);
401
-		$cumulativeNet= new \Illuminate\Support\Collection();
401
+		$cumulativeNet = new \Illuminate\Support\Collection();
402 402
 
403
-		if($netScores->count() > 0){
403
+		if ($netScores->count() > 0) {
404 404
 			$netScore = $netScores->first();
405 405
 
406 406
 			$totalNetScore = $netScores->sum('netScore');
@@ -417,32 +417,32 @@  discard block
 block discarded – undo
417 417
 		$players = Player::all();
418 418
 
419 419
 		$cumulativeNetScores = new \Illuminate\Support\Collection();
420
-		foreach($players as $player){
421
-			$cumulativeNetScores->push($this->netCumulativeByPlayerYear($player->id,$year));
420
+		foreach ($players as $player) {
421
+			$cumulativeNetScores->push($this->netCumulativeByPlayerYear($player->id, $year));
422 422
 		}
423 423
 		return $cumulativeNetScores;
424 424
 	}
425
-	public function netCumulativeTopYear($top,$year)
425
+	public function netCumulativeTopYear($top, $year)
426 426
 	{
427 427
 		//get players
428 428
 		$players = Player::all();
429 429
 
430 430
 		$cumulativeNetScores = new \Illuminate\Support\Collection();
431
-		foreach($players as $player){
431
+		foreach ($players as $player) {
432 432
 			$netScore = $this->netCumulativeByPlayerTopYear($player->id, $top, $year);
433
-			if($netScore->isEmpty() == false){
433
+			if ($netScore->isEmpty() == false) {
434 434
 				$cumulativeNetScores->push($netScore);
435 435
 			}
436 436
 		}
437 437
 
438 438
 		return $cumulativeNetScores;
439 439
 	}
440
-	public function netCumulativeByPlayerYear($playerId,$year)
440
+	public function netCumulativeByPlayerYear($playerId, $year)
441 441
 	{
442 442
 		$netScores = $this->netScoresByPlayerYear($playerId, $year);
443
-		$cumulativeNet= new \Illuminate\Support\Collection();
443
+		$cumulativeNet = new \Illuminate\Support\Collection();
444 444
 
445
-		if($netScores->count() > 0){
445
+		if ($netScores->count() > 0) {
446 446
 			$netScore = $netScores->first();
447 447
 
448 448
 			$totalNetScore = $netScores->sum('netScore');
@@ -453,12 +453,12 @@  discard block
 block discarded – undo
453 453
 
454 454
 		return $cumulativeNet;
455 455
 	}
456
-	public function netCumulativeByPlayerTopYear($playerId,$top,$year)
456
+	public function netCumulativeByPlayerTopYear($playerId, $top, $year)
457 457
 	{
458 458
 		$netScores = $this->netScoresByPlayerTopYear($playerId, $top, $year);
459
-		$cumulativeNet= new \Illuminate\Support\Collection();
459
+		$cumulativeNet = new \Illuminate\Support\Collection();
460 460
 
461
-		if($netScores->count() > 0){
461
+		if ($netScores->count() > 0) {
462 462
 			$netScore = $netScores->first();
463 463
 
464 464
 			$totalNetScore = $netScores->sum('netScore');
Please login to merge, or discard this patch.
Braces   +32 added lines, -31 removed lines patch added patch discarded remove patch
@@ -8,8 +8,7 @@  discard block
 block discarded – undo
8 8
 use \Holescore;
9 9
 use \Match;
10 10
 
11
-class LeagueStatisticsEloquent implements LeagueStatistics
12
-{
11
+class LeagueStatisticsEloquent implements LeagueStatistics {
13 12
     public function topFiveLowestScores()
14 13
     {
15 14
         return Round::with('player','course')->orderBy('score')->take(5)->get();
@@ -87,16 +86,18 @@  discard block
 block discarded – undo
87 86
         array_multisort($skinsCount, SORT_DESC);
88 87
         return $skinsCount;
89 88
     }
90
-    public function totalEagles($year){}
89
+    public function totalEagles($year)
90
+    {
91
+}
91 92
     public function totalBirdies($year)
92
-	{
93
+    {
93 94
 		$year = $year . '-01-01';
94 95
 		$holescores = Holescore::with('round.player','hole')
95 96
 			->where('created_at', '>', $year)
96 97
 			->get();
97 98
 		$allBirdies = array();
98 99
 		foreach($holescores as $key => $holescore) {
99
-			if($holescore['round']['match_id'] != null){
100
+			if($holescore['round']['match_id'] != null) {
100 101
 				if( ($holescore['hole']['par'] - $holescore['score']) === 1) {
101 102
 						$allBirdies[]= $holescore['round']['player']['name'];
102 103
 				}
@@ -113,14 +114,14 @@  discard block
 block discarded – undo
113 114
 			return $birds;
114 115
 	}
115 116
     public function totalPars($year)
116
-	{
117
+    {
117 118
 		$year = $year . '-01-01';
118 119
 		$holescores = Holescore::with('round.player','hole')
119 120
 			->where('created_at', '>', $year)
120 121
 			->get();
121 122
 		$allPars = array();
122 123
 		foreach($holescores as $key => $holescore) {
123
-			if($holescore['round']['match_id'] != null){
124
+			if($holescore['round']['match_id'] != null) {
124 125
 				if( ($holescore['hole']['par'] - $holescore['score']) === 0) {
125 126
 						$allPars[]= $holescore['round']['player']['name'];
126 127
 				}
@@ -137,14 +138,14 @@  discard block
 block discarded – undo
137 138
 			return $pars;
138 139
 	}
139 140
     public function totalBogeys($year)
140
-	{
141
+    {
141 142
 		$year = $year . '-01-01';
142 143
 		$holescores = Holescore::with('round.player','hole')
143 144
 			->where('created_at', '>', $year)
144 145
 			->get();
145 146
 		$allBogeys = array();
146 147
 		foreach($holescores as $key => $holescore) {
147
-			if($holescore['round']['match_id'] != null){
148
+			if($holescore['round']['match_id'] != null) {
148 149
 				if( ($holescore['score'] - $holescore['hole']['par']) === 1) {
149 150
 						$allBogeys[]= $holescore['round']['player']['name'];
150 151
 				}
@@ -161,14 +162,14 @@  discard block
 block discarded – undo
161 162
 		return $bogeys;
162 163
 	}
163 164
     public function totalDoubles($year)
164
-	{
165
+    {
165 166
 		$year = $year . '-01-01';
166 167
 		$holescores = Holescore::with('round.player','hole')
167 168
 			->where('created_at', '>', $year)
168 169
 			->get();
169 170
 		$allDoubles = array();
170 171
 		foreach($holescores as $key => $holescore) {
171
-			if($holescore['round']['match_id'] != null){
172
+			if($holescore['round']['match_id'] != null) {
172 173
 				if( ($holescore['score'] - $holescore['hole']['par']) === 2) {
173 174
 						$allDoubles[]= $holescore['round']['player']['name'];
174 175
 				}
@@ -185,14 +186,14 @@  discard block
 block discarded – undo
185 186
 		return $doubles;
186 187
 	}
187 188
     public function totalOthers($year)
188
-	{
189
+    {
189 190
 		$year = $year . '-01-01';
190 191
 		$holescores = Holescore::with('round.player','hole')
191 192
 			->where('created_at', '>', $year)
192 193
 			->get();
193 194
 		$allOthers = array();
194 195
 		foreach($holescores as $key => $holescore) {
195
-			if($holescore['round']['match_id'] != null){
196
+			if($holescore['round']['match_id'] != null) {
196 197
 				if( ($holescore['score'] - $holescore['hole']['par']) > 2) {
197 198
 					$allOthers[]= $holescore['round']['player']['name'];
198 199
 				}
@@ -221,7 +222,7 @@  discard block
 block discarded – undo
221 222
 		$rounds->map(function($round)
222 223
 		{
223 224
 			$playerMatch = Player::find($round->player_id)->matches()->where('match_player.match_id','=', $round->match_id)->get();
224
-			foreach($playerMatch as $player){
225
+			foreach($playerMatch as $player) {
225 226
 				$handicap = $player['pivot']['handicap'];
226 227
 				$round->handicap = $handicap;
227 228
 			}
@@ -268,7 +269,7 @@  discard block
 block discarded – undo
268 269
 		$rounds->map(function($round)
269 270
 		{
270 271
 			$playerMatch = Player::find($round->player_id)->matches()->where('match_player.match_id','=', $round->match_id)->get();
271
-			foreach($playerMatch as $player){
272
+			foreach($playerMatch as $player) {
272 273
 				$handicap = $player['pivot']['handicap'];
273 274
 				$round->handicap = $handicap;
274 275
 			}
@@ -305,7 +306,7 @@  discard block
 block discarded – undo
305 306
 		$players = Player::all();
306 307
 
307 308
 		$netScores = new \Illuminate\Support\Collection();
308
-		foreach($players as $player){
309
+		foreach($players as $player) {
309 310
 			$netScores->push($this->netScoresByPlayer($player->id));
310 311
 		}
311 312
 		return $netScores;
@@ -317,9 +318,9 @@  discard block
 block discarded – undo
317 318
 		$players = Player::all();
318 319
 
319 320
 		$netScores = new \Illuminate\Support\Collection();
320
-		foreach($players as $player){
321
+		foreach($players as $player) {
321 322
 			$netScore = $this->netScoresByPlayerTop($player->id, $number);
322
-			if(!$netScore->isEmpty()){
323
+			if(!$netScore->isEmpty()) {
323 324
 				$netScores->push($netScore);
324 325
 			}
325 326
 		}
@@ -332,7 +333,7 @@  discard block
 block discarded – undo
332 333
 		$players = Player::all();
333 334
 
334 335
 		$netScores = new \Illuminate\Support\Collection();
335
-		foreach($players as $player){
336
+		foreach($players as $player) {
336 337
 			$netScores->push($this->netScoresByPlayerYear($player->id,$year));
337 338
 		}
338 339
 		return $netScores;
@@ -343,9 +344,9 @@  discard block
 block discarded – undo
343 344
 		$players = Player::all();
344 345
 
345 346
 		$netScores = new \Illuminate\Support\Collection();
346
-		foreach($players as $player){
347
+		foreach($players as $player) {
347 348
 			$netScore = $this->netScoresByPlayerTopYear($player->id, $top, $year);
348
-			if(!$netScore->isEmpty()){
349
+			if(!$netScore->isEmpty()) {
349 350
 				$netScores->push($netScore);
350 351
 			}
351 352
 		}
@@ -359,7 +360,7 @@  discard block
 block discarded – undo
359 360
 		$players = Player::all();
360 361
 
361 362
 		$cumulativeNetScores = new \Illuminate\Support\Collection();
362
-		foreach($players as $player){
363
+		foreach($players as $player) {
363 364
 			$cumulativeNetScores->push($this->netCumulativeByPlayer($player->id));
364 365
 		}
365 366
 		return $cumulativeNetScores;
@@ -370,9 +371,9 @@  discard block
 block discarded – undo
370 371
 		$players = Player::all();
371 372
 
372 373
 		$cumulativeNetScores = new \Illuminate\Support\Collection();
373
-		foreach($players as $player){
374
+		foreach($players as $player) {
374 375
 			$netScore = $this->netCumulativeByPlayerTop($player->id, $top);
375
-			if($netScore->isEmpty() == false){
376
+			if($netScore->isEmpty() == false) {
376 377
 				$cumulativeNetScores->push($netScore);
377 378
 			}
378 379
 		}
@@ -384,7 +385,7 @@  discard block
 block discarded – undo
384 385
 		$netScores = $this->netScoresByPlayer($playerId);
385 386
 		$cumulativeNet= new \Illuminate\Support\Collection();
386 387
 
387
-		if($netScores->count() > 0){
388
+		if($netScores->count() > 0) {
388 389
 			$netScore = $netScores->first();
389 390
 
390 391
 			$totalNetScore = $netScores->sum('netScore');
@@ -400,7 +401,7 @@  discard block
 block discarded – undo
400 401
 		$netScores = $this->netScoresByPlayerTop($playerId, $top);
401 402
 		$cumulativeNet= new \Illuminate\Support\Collection();
402 403
 
403
-		if($netScores->count() > 0){
404
+		if($netScores->count() > 0) {
404 405
 			$netScore = $netScores->first();
405 406
 
406 407
 			$totalNetScore = $netScores->sum('netScore');
@@ -417,7 +418,7 @@  discard block
 block discarded – undo
417 418
 		$players = Player::all();
418 419
 
419 420
 		$cumulativeNetScores = new \Illuminate\Support\Collection();
420
-		foreach($players as $player){
421
+		foreach($players as $player) {
421 422
 			$cumulativeNetScores->push($this->netCumulativeByPlayerYear($player->id,$year));
422 423
 		}
423 424
 		return $cumulativeNetScores;
@@ -428,9 +429,9 @@  discard block
 block discarded – undo
428 429
 		$players = Player::all();
429 430
 
430 431
 		$cumulativeNetScores = new \Illuminate\Support\Collection();
431
-		foreach($players as $player){
432
+		foreach($players as $player) {
432 433
 			$netScore = $this->netCumulativeByPlayerTopYear($player->id, $top, $year);
433
-			if($netScore->isEmpty() == false){
434
+			if($netScore->isEmpty() == false) {
434 435
 				$cumulativeNetScores->push($netScore);
435 436
 			}
436 437
 		}
@@ -442,7 +443,7 @@  discard block
 block discarded – undo
442 443
 		$netScores = $this->netScoresByPlayerYear($playerId, $year);
443 444
 		$cumulativeNet= new \Illuminate\Support\Collection();
444 445
 
445
-		if($netScores->count() > 0){
446
+		if($netScores->count() > 0) {
446 447
 			$netScore = $netScores->first();
447 448
 
448 449
 			$totalNetScore = $netScores->sum('netScore');
@@ -458,7 +459,7 @@  discard block
 block discarded – undo
458 459
 		$netScores = $this->netScoresByPlayerTopYear($playerId, $top, $year);
459 460
 		$cumulativeNet= new \Illuminate\Support\Collection();
460 461
 
461
-		if($netScores->count() > 0){
462
+		if($netScores->count() > 0) {
462 463
 			$netScore = $netScores->first();
463 464
 
464 465
 			$totalNetScore = $netScores->sum('netScore');
Please login to merge, or discard this patch.