Completed
Push — master ( 236403...70f3fa )
by Michael
02:53
created

Handicap::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Michael Schmidt
5
 * Date: 8/14/16
6
 * Time: 8:22 PM
7
 */
8
9
namespace GLsoftware\Golf;
10
11
12
class Handicap
13
{
14
    private $roundsEnteredArray;
15
    private $scores;
16
    private $numberOfScores;
17
18
    /**
19
     * Handicap constructor.
20
     * @param array $scores
21
     */
22 3
    public function __construct(array $scores)
23
    {
24 3
        $this->roundsEnteredArray = [0,1,1,1,1,1,1,2,2,3,3,4,4,5,5,6,6,7,8,9,10];
25 3
        $this->scores = $scores; // These should be ESC adjusted scores
26 3
        $this->numberOfScores = count($this->scores);
27 3
    }
28
29
    /**
30
     * @return array
31
     */
32 1
    public function getScores()
33
    {
34 1
        return $this->scores;
35
    }
36
37
    /**
38
     * @return mixed
39
     */
40 1
    public function getDifferential()
41
    {
42 1
        return $this->roundsEnteredArray[$this->numberOfScores];
43
    }
44
45
    /**
46
     * @return float
47
     */
48 1
    public function get()
49
    {
50 1
        return ((array_sum($this->scores)/$this->numberOfScores) * 0.96) - 72;
51
    }
52
}
53