FlightCost::minBonus()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
require_once(DOL_DOCUMENT_ROOT . '/flightlog/class/flight/FlightBonus.php');
4
5
/**
6
 * @author Laurent De Coninck <[email protected]>
7
 */
8
class FlightCost
9
{
10
11
    /**
12
     * @var int
13
     */
14
    private $cost;
15
16
    /**
17
     * @param int $cost
18
     */
19
    public function __construct($cost)
20
    {
21
        $this->cost = $cost;
22
    }
23
24
    /**
25
     * @return FlightCost
26
     */
27
    public static function zero()
28
    {
29
        return new FlightCost(0);
30
    }
31
32
    /**
33
     * @param FlightCost $cost
34
     *
35
     * @return FlightCost
36
     */
37
    public function addCost(FlightCost $cost)
38
    {
39
        return new FlightCost($this->cost + $cost->getValue());
40
    }
41
42
    /**
43
     * @param int $factor
44
     *
45
     * @return FlightCost
46
     */
47
    public function multiply($factor)
48
    {
49
        return new FlightCost($factor * $this->cost);
50
    }
51
52
    /**
53
     * @return int
54
     */
55
    public function getValue()
56
    {
57
        return $this->cost;
58
    }
59
60
    /**
61
     * @param FlightBonus $bonus
62
     *
63
     * @return FlightCost
64
     */
65
    public function minBonus(FlightBonus $bonus)
66
    {
67
        return new FlightCost($this->cost - $bonus->getValue());
68
    }
69
70
}