Completed
Push — feature/fixing_cost ( 2c76a0...f58af6 )
by Laurent
01:38
created

FlightDamage::invoice()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace FlightLog\Domain\Damage;
5
6
final class FlightDamage
7
{
8
    /**
9
     * @var DamageId|null
10
     */
11
    private $id;
12
13
    /**
14
     * @var FlightId
15
     */
16
    private $flight;
17
18
    /**
19
     * @var DamageAmount
20
     */
21
    private $amount;
22
23
    /**
24
     * @var bool
25
     */
26
    private $billed;
27
28
    /**
29
     * @var AuthorId
30
     */
31
    private $author;
32
33
    /**
34
     * @param FlightId $flightId
35
     * @param DamageAmount $amount
36
     * @param $billed
37
     * @param AuthorId $authorId
38
     * @param DamageId|null $id
39
     */
40
    private function __construct(FlightId $flightId, DamageAmount $amount, $billed, AuthorId $authorId, DamageId $id = null)
41
    {
42
       $this->flight = $flightId;
43
       $this->amount = $amount;
44
       $this->billed = $billed;
45
       $this->author = $authorId;
46
       $this->id = $id;
47
    }
48
49
    /**
50
     * @param FlightId $flightId
51
     * @param DamageAmount $amount
52
     * @param $billed
53
     * @param AuthorId $authorId
54
     * @param DamageId|null $id
55
     *
56
     * @return FlightDamage
57
     */
58
    public static function load(FlightId $flightId, DamageAmount $amount, $billed, AuthorId $authorId, DamageId $id = null){
59
        return new self($flightId, $amount, $billed, $authorId, $id);
60
    }
61
62
    /**
63
     * @param FlightId $flightId
64
     * @param DamageAmount $amount
65
     * @param AuthorId $authorId
66
     *
67
     * @return FlightDamage
68
     */
69
    public static function damage(FlightId $flightId, DamageAmount $amount, AuthorId $authorId){
70
        return new self($flightId, $amount, false, $authorId);
71
    }
72
73
    /**
74
     * @return bool
75
     */
76
    public function isBilled()
77
    {
78
        return $this->billed;
79
    }
80
81
    /**
82
     * @return FlightId
83
     */
84
    public function getFlightId(){
85
        return $this->flight;
86
    }
87
88
    /**
89
     * @return DamageAmount
90
     */
91
    public function amount(){
92
        return $this->amount;
93
    }
94
95
    /**
96
     * @return AuthorId
97
     */
98
    public function getAuthor()
99
    {
100
        return $this->author;
101
    }
102
103
    /**
104
     * Invoice the damage.
105
     *
106
     * @return FlightDamage
107
     */
108
    public function invoice(){
109
        return new self($this->flight, $this->amount, true, $this->author, $this->id);
110
    }
111
112
    /**
113
     * @return DamageId|null
114
     */
115
    public function getId()
116
    {
117
        return $this->id;
118
    }
119
120
}