FlightBonus   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 42
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A zero() 0 4 1
A addPoints() 0 4 1
A getValue() 0 4 1
1
<?php
2
3
require_once(DOL_DOCUMENT_ROOT . '/flightlog/class/flight/FlightPoints.php');
4
5
/**
6
 * A bonus won by a pilot
7
 *
8
 * @author Laurent De Coninck <[email protected]>
9
 */
10
class FlightBonus
11
{
12
    /**
13
     * @var int
14
     */
15
    private $bonusAmount;
16
17
    /**
18
     * @param int $bonusAmount
19
     */
20
    private function __construct($bonusAmount)
21
    {
22
        $this->bonusAmount = $bonusAmount;
23
    }
24
25
    /**
26
     * @return FlightBonus
27
     */
28
    public static function zero()
29
    {
30
        return new FlightBonus(0);
31
    }
32
33
    /**
34
     * @param FlightPoints $points
35
     *
36
     * @return FlightBonus
37
     */
38
    public function addPoints(FlightPoints $points)
39
    {
40
        return new FlightBonus($this->bonusAmount + $points->getValue());
41
    }
42
43
    /**
44
     * @return int
45
     */
46
    public function getValue()
47
    {
48
        return $this->bonusAmount;
49
    }
50
51
}