Completed
Push — master ( d80111...e10130 )
by Michael
07:04
created
app/library/Classes/Handicap.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -7,47 +7,47 @@
 block discarded – undo
7 7
 
8 8
 class Handicap
9 9
 {
10
-    private $differentialArray;
11
-    private $player;
12
-    private $roundsUsed;
13
-
14
-    public function __construct(Player $player, $roundsUsed = 10)
15
-    {
16
-        $this->differentialArray = array(0,1,1,1,1,1,1,2,2,3,3,4,4,5,5,6,6,7,8,9,10);
17
-        $this->player = $player;
18
-        $this->roundsUsed = $roundsUsed; //20 is USGA standard;  Some leagues may want to adjust.
19
-    }
20
-
21
-    public function calculate()
22
-    {
23
-        $rounds = Round::where('player_id', '=', $this->player->id)->orderBy('date', 'desc')->take($this->roundsUsed)->get();
24
-        $differential = $this->differential($rounds->count());
25
-
26
-        $i = 1;
27
-        foreach ($rounds as $round) {
28
-            $differentials[$i]  = $round->esc;
29
-            $i++;
30
-        }
31
-        sort($differentials);
32
-        $chunkedRounds = array_chunk($differentials,$differential,true);
33
-        $roundsUsed = $chunkedRounds[0];
34
-
35
-        $sumofDifferentials = array_sum($roundsUsed);
36
-        $handicap = (($sumofDifferentials / $differential) * .96) - 36;
37
-        $handicap = round($handicap ,2);
38
-
39
-        return $handicap;
40
-    }
41
-
42
-    //
43
-    public function differential($numberOfScores)
44
-    {
45
-        if($numberOfScores <= 20){
46
-            return $this->differentialArray[$numberOfScores];
47
-        } else {
48
-            return $this->differentialArray[20];
49
-        }
50
-    }
10
+	private $differentialArray;
11
+	private $player;
12
+	private $roundsUsed;
13
+
14
+	public function __construct(Player $player, $roundsUsed = 10)
15
+	{
16
+		$this->differentialArray = array(0,1,1,1,1,1,1,2,2,3,3,4,4,5,5,6,6,7,8,9,10);
17
+		$this->player = $player;
18
+		$this->roundsUsed = $roundsUsed; //20 is USGA standard;  Some leagues may want to adjust.
19
+	}
20
+
21
+	public function calculate()
22
+	{
23
+		$rounds = Round::where('player_id', '=', $this->player->id)->orderBy('date', 'desc')->take($this->roundsUsed)->get();
24
+		$differential = $this->differential($rounds->count());
25
+
26
+		$i = 1;
27
+		foreach ($rounds as $round) {
28
+			$differentials[$i]  = $round->esc;
29
+			$i++;
30
+		}
31
+		sort($differentials);
32
+		$chunkedRounds = array_chunk($differentials,$differential,true);
33
+		$roundsUsed = $chunkedRounds[0];
34
+
35
+		$sumofDifferentials = array_sum($roundsUsed);
36
+		$handicap = (($sumofDifferentials / $differential) * .96) - 36;
37
+		$handicap = round($handicap ,2);
38
+
39
+		return $handicap;
40
+	}
41
+
42
+	//
43
+	public function differential($numberOfScores)
44
+	{
45
+		if($numberOfScores <= 20){
46
+			return $this->differentialArray[$numberOfScores];
47
+		} else {
48
+			return $this->differentialArray[20];
49
+		}
50
+	}
51 51
 
52 52
 
53 53
 }
54 54
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
     public function __construct(Player $player, $roundsUsed = 10)
15 15
     {
16
-        $this->differentialArray = array(0,1,1,1,1,1,1,2,2,3,3,4,4,5,5,6,6,7,8,9,10);
16
+        $this->differentialArray = array(0, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 8, 9, 10);
17 17
         $this->player = $player;
18 18
         $this->roundsUsed = $roundsUsed; //20 is USGA standard;  Some leagues may want to adjust.
19 19
     }
@@ -25,16 +25,16 @@  discard block
 block discarded – undo
25 25
 
26 26
         $i = 1;
27 27
         foreach ($rounds as $round) {
28
-            $differentials[$i]  = $round->esc;
28
+            $differentials[$i] = $round->esc;
29 29
             $i++;
30 30
         }
31 31
         sort($differentials);
32
-        $chunkedRounds = array_chunk($differentials,$differential,true);
32
+        $chunkedRounds = array_chunk($differentials, $differential, true);
33 33
         $roundsUsed = $chunkedRounds[0];
34 34
 
35 35
         $sumofDifferentials = array_sum($roundsUsed);
36 36
         $handicap = (($sumofDifferentials / $differential) * .96) - 36;
37
-        $handicap = round($handicap ,2);
37
+        $handicap = round($handicap, 2);
38 38
 
39 39
         return $handicap;
40 40
     }
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     //
43 43
     public function differential($numberOfScores)
44 44
     {
45
-        if($numberOfScores <= 20){
45
+        if ($numberOfScores <= 20) {
46 46
             return $this->differentialArray[$numberOfScores];
47 47
         } else {
48 48
             return $this->differentialArray[20];
Please login to merge, or discard this patch.