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

Handicap   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 0 Features 1
Metric Value
wmc 4
c 5
b 0
f 1
lcom 1
cbo 0
dl 0
loc 41
ccs 11
cts 11
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getScores() 0 4 1
A getDifferential() 0 4 1
A get() 0 4 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