Conditions | 2 |
Paths | 2 |
Total Lines | 23 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
26 | public function calculate() |
||
27 | { |
||
28 | //holescore |
||
29 | $holescore = $this->holescore->score; // Gross score on hole |
||
30 | |||
31 | //Use Round to get player_id |
||
32 | $player = Round::find($this->holescore->round_id)->player_id; |
||
33 | |||
34 | //Get player's handicap |
||
35 | $handicap = Player::find($player)->handicap; |
||
36 | |||
37 | //Get par for hole |
||
38 | $holePar = Hole::find($this->holescore->hole_id)->par; |
||
39 | |||
40 | //Use par and handicap to determine max score for a hole |
||
41 | $maxScore = $this->maxAllowableScore($holePar, $handicap); |
||
42 | |||
43 | if($holescore > $maxScore) { |
||
44 | return $maxScore; |
||
45 | } |
||
46 | return $holescore; |
||
47 | |||
48 | } |
||
49 | |||
72 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: