Completed
Push — master ( 1f5232...fc3dfa )
by Michael
03:22
created
app/library/Classes/Statistics/PlayerStatisticsEloquent.php 2 patches
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -10,93 +10,93 @@
 block discarded – undo
10 10
 
11 11
 class PlayerStatisticsEloquent implements PlayerStatistics
12 12
 {
13
-    private $date1 = '-01-01';
14
-    private $date2 = '-12-31';
15
-
16
-    public function matchesHandicap($playerId){}
17
-    public function scoringAverage($playerId)
18
-    {
19
-        $today = Carbon::today()->toDateString();
20
-        $rounds = Round::where('player_id', '=', $playerId)
21
-            ->where('date', '<', $today)
22
-            ->get();
23
-        $scores = $rounds->map(function($round)
24
-        {
25
-            return $round->score;
26
-        });
27
-        if($rounds->count() > 0) {
28
-            return round(array_sum($scores->toArray())/($rounds->count()), 2);
29
-        } else {
30
-            return $rounds;
31
-        }
32
-    }
33
-    public function scoringAverageByYear($playerId, $year)
34
-    {
35
-        $date1 = $year . '-01-01';
36
-        $date2 = $year . '-12-31';
37
-
38
-
39
-        $rounds = Round::where('player_id', '=', $playerId)
40
-            ->where('date', '>=', $date1)
41
-            ->where('date', '<=', $date2)
42
-            ->get();
43
-        $scores = $rounds->map(function($round)
44
-        {
45
-            return $round->score;
46
-        });
47
-        if($rounds->count() > 0) {
48
-            return round(array_sum($scores->toArray())/($rounds->count()), 2);
49
-        } else {
50
-            return $rounds;
51
-        }
52
-
53
-
54
-    }
55
-    public function scoringAverageMatchesByYear($year){}
56
-    public function handicapRounds($playerId){}
57
-
58
-    public function scoringAverageCourse($course){}
59
-    public function scoringAverageCourseByYear($course, $year){}
60
-    public function scoringAverageCourseMatchesByYear($course, $year){}
61
-
62
-    public function totalEagles(){}
63
-    public function eaglesByYear($year){}
64
-    public function eaglesMatchesByYear($year){}
65
-
66
-    public function totalBirdies($playerId){}
67
-    public function birdiesByYear($playerId, $year)
68
-    {
69
-        $year = $year . '-01-01';
70
-        $holescores = Holescore::with('round.player','hole')
71
-            ->where('created_at', '>', $year)
72
-            ->get();
73
-        $allBirdies = array();
74
-        foreach($holescores as $key => $holescore) {
75
-            if($holescore['round']['match_id'] != null){
76
-                if( ($holescore['hole']['par'] - $holescore['score']) === 1) {
77
-                    $allBirdies[]= $holescore['round']['player']['id'];
78
-                }
79
-            }
80
-        }
81
-        return count(array_keys($allBirdies, $playerId));
82
-
83
-    }
84
-    public function birdiesMatchesByYear($year){}
85
-
86
-    public function totalPars(){}
87
-    public function parsByYear($year){}
88
-    public function parsMatchesByYear($year){}
89
-
90
-    public function totalbogeys(){}
91
-    public function bogeysByYear($year){}
92
-    public function bogeysMatchesByYear($year){}
93
-
94
-    public function totalDoubles(){}
95
-    public function doublesByYear($year){}
96
-    public function doublesMatchesByYear($year){}
97
-
98
-    public function totalOthers(){}
99
-    public function othersByYear($year){}
100
-    public function othersMatchesByYear($year){}
13
+	private $date1 = '-01-01';
14
+	private $date2 = '-12-31';
15
+
16
+	public function matchesHandicap($playerId){}
17
+	public function scoringAverage($playerId)
18
+	{
19
+		$today = Carbon::today()->toDateString();
20
+		$rounds = Round::where('player_id', '=', $playerId)
21
+			->where('date', '<', $today)
22
+			->get();
23
+		$scores = $rounds->map(function($round)
24
+		{
25
+			return $round->score;
26
+		});
27
+		if($rounds->count() > 0) {
28
+			return round(array_sum($scores->toArray())/($rounds->count()), 2);
29
+		} else {
30
+			return $rounds;
31
+		}
32
+	}
33
+	public function scoringAverageByYear($playerId, $year)
34
+	{
35
+		$date1 = $year . '-01-01';
36
+		$date2 = $year . '-12-31';
37
+
38
+
39
+		$rounds = Round::where('player_id', '=', $playerId)
40
+			->where('date', '>=', $date1)
41
+			->where('date', '<=', $date2)
42
+			->get();
43
+		$scores = $rounds->map(function($round)
44
+		{
45
+			return $round->score;
46
+		});
47
+		if($rounds->count() > 0) {
48
+			return round(array_sum($scores->toArray())/($rounds->count()), 2);
49
+		} else {
50
+			return $rounds;
51
+		}
52
+
53
+
54
+	}
55
+	public function scoringAverageMatchesByYear($year){}
56
+	public function handicapRounds($playerId){}
57
+
58
+	public function scoringAverageCourse($course){}
59
+	public function scoringAverageCourseByYear($course, $year){}
60
+	public function scoringAverageCourseMatchesByYear($course, $year){}
61
+
62
+	public function totalEagles(){}
63
+	public function eaglesByYear($year){}
64
+	public function eaglesMatchesByYear($year){}
65
+
66
+	public function totalBirdies($playerId){}
67
+	public function birdiesByYear($playerId, $year)
68
+	{
69
+		$year = $year . '-01-01';
70
+		$holescores = Holescore::with('round.player','hole')
71
+			->where('created_at', '>', $year)
72
+			->get();
73
+		$allBirdies = array();
74
+		foreach($holescores as $key => $holescore) {
75
+			if($holescore['round']['match_id'] != null){
76
+				if( ($holescore['hole']['par'] - $holescore['score']) === 1) {
77
+					$allBirdies[]= $holescore['round']['player']['id'];
78
+				}
79
+			}
80
+		}
81
+		return count(array_keys($allBirdies, $playerId));
82
+
83
+	}
84
+	public function birdiesMatchesByYear($year){}
85
+
86
+	public function totalPars(){}
87
+	public function parsByYear($year){}
88
+	public function parsMatchesByYear($year){}
89
+
90
+	public function totalbogeys(){}
91
+	public function bogeysByYear($year){}
92
+	public function bogeysMatchesByYear($year){}
93
+
94
+	public function totalDoubles(){}
95
+	public function doublesByYear($year){}
96
+	public function doublesMatchesByYear($year){}
97
+
98
+	public function totalOthers(){}
99
+	public function othersByYear($year){}
100
+	public function othersMatchesByYear($year){}
101 101
 
102 102
 }
103 103
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
     private $date1 = '-01-01';
14 14
     private $date2 = '-12-31';
15 15
 
16
-    public function matchesHandicap($playerId){}
16
+    public function matchesHandicap($playerId) {}
17 17
     public function scoringAverage($playerId)
18 18
     {
19 19
         $today = Carbon::today()->toDateString();
@@ -24,16 +24,16 @@  discard block
 block discarded – undo
24 24
         {
25 25
             return $round->score;
26 26
         });
27
-        if($rounds->count() > 0) {
28
-            return round(array_sum($scores->toArray())/($rounds->count()), 2);
27
+        if ($rounds->count() > 0) {
28
+            return round(array_sum($scores->toArray()) / ($rounds->count()), 2);
29 29
         } else {
30 30
             return $rounds;
31 31
         }
32 32
     }
33 33
     public function scoringAverageByYear($playerId, $year)
34 34
     {
35
-        $date1 = $year . '-01-01';
36
-        $date2 = $year . '-12-31';
35
+        $date1 = $year.'-01-01';
36
+        $date2 = $year.'-12-31';
37 37
 
38 38
 
39 39
         $rounds = Round::where('player_id', '=', $playerId)
@@ -44,59 +44,59 @@  discard block
 block discarded – undo
44 44
         {
45 45
             return $round->score;
46 46
         });
47
-        if($rounds->count() > 0) {
48
-            return round(array_sum($scores->toArray())/($rounds->count()), 2);
47
+        if ($rounds->count() > 0) {
48
+            return round(array_sum($scores->toArray()) / ($rounds->count()), 2);
49 49
         } else {
50 50
             return $rounds;
51 51
         }
52 52
 
53 53
 
54 54
     }
55
-    public function scoringAverageMatchesByYear($year){}
56
-    public function handicapRounds($playerId){}
55
+    public function scoringAverageMatchesByYear($year) {}
56
+    public function handicapRounds($playerId) {}
57 57
 
58
-    public function scoringAverageCourse($course){}
59
-    public function scoringAverageCourseByYear($course, $year){}
60
-    public function scoringAverageCourseMatchesByYear($course, $year){}
58
+    public function scoringAverageCourse($course) {}
59
+    public function scoringAverageCourseByYear($course, $year) {}
60
+    public function scoringAverageCourseMatchesByYear($course, $year) {}
61 61
 
62
-    public function totalEagles(){}
63
-    public function eaglesByYear($year){}
64
-    public function eaglesMatchesByYear($year){}
62
+    public function totalEagles() {}
63
+    public function eaglesByYear($year) {}
64
+    public function eaglesMatchesByYear($year) {}
65 65
 
66
-    public function totalBirdies($playerId){}
66
+    public function totalBirdies($playerId) {}
67 67
     public function birdiesByYear($playerId, $year)
68 68
     {
69
-        $year = $year . '-01-01';
70
-        $holescores = Holescore::with('round.player','hole')
69
+        $year = $year.'-01-01';
70
+        $holescores = Holescore::with('round.player', 'hole')
71 71
             ->where('created_at', '>', $year)
72 72
             ->get();
73 73
         $allBirdies = array();
74
-        foreach($holescores as $key => $holescore) {
75
-            if($holescore['round']['match_id'] != null){
76
-                if( ($holescore['hole']['par'] - $holescore['score']) === 1) {
77
-                    $allBirdies[]= $holescore['round']['player']['id'];
74
+        foreach ($holescores as $key => $holescore) {
75
+            if ($holescore['round']['match_id'] != null) {
76
+                if (($holescore['hole']['par'] - $holescore['score']) === 1) {
77
+                    $allBirdies[] = $holescore['round']['player']['id'];
78 78
                 }
79 79
             }
80 80
         }
81 81
         return count(array_keys($allBirdies, $playerId));
82 82
 
83 83
     }
84
-    public function birdiesMatchesByYear($year){}
84
+    public function birdiesMatchesByYear($year) {}
85 85
 
86
-    public function totalPars(){}
87
-    public function parsByYear($year){}
88
-    public function parsMatchesByYear($year){}
86
+    public function totalPars() {}
87
+    public function parsByYear($year) {}
88
+    public function parsMatchesByYear($year) {}
89 89
 
90
-    public function totalbogeys(){}
91
-    public function bogeysByYear($year){}
92
-    public function bogeysMatchesByYear($year){}
90
+    public function totalbogeys() {}
91
+    public function bogeysByYear($year) {}
92
+    public function bogeysMatchesByYear($year) {}
93 93
 
94
-    public function totalDoubles(){}
95
-    public function doublesByYear($year){}
96
-    public function doublesMatchesByYear($year){}
94
+    public function totalDoubles() {}
95
+    public function doublesByYear($year) {}
96
+    public function doublesMatchesByYear($year) {}
97 97
 
98
-    public function totalOthers(){}
99
-    public function othersByYear($year){}
100
-    public function othersMatchesByYear($year){}
98
+    public function totalOthers() {}
99
+    public function othersByYear($year) {}
100
+    public function othersMatchesByYear($year) {}
101 101
 
102 102
 }
103 103
\ No newline at end of file
Please login to merge, or discard this patch.