Completed
Push — feature/fixing_cost ( f58af6...414fbf )
by Laurent
01:41
created

FlightDamage::waiting()   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 2
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(DamageAmount $amount, $billed, AuthorId $authorId, FlightId $flightId = null, 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($amount, $billed, $authorId, $flightId, $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($amount, false, $authorId, $flightId);
71
    }
72
73
    /**
74
     * @param DamageAmount $amount
75
     * @param AuthorId $authorId
76
     *
77
     * @return FlightDamage
78
     */
79
    public static function waiting(DamageAmount $amount, AuthorId $authorId){
80
        return new self($amount, false, $authorId);
81
    }
82
83
    /**
84
     * @return bool
85
     */
86
    public function isBilled()
87
    {
88
        return $this->billed;
89
    }
90
91
    /**
92
     * @return FlightId
93
     */
94
    public function getFlightId(){
95
        return $this->flight;
96
    }
97
98
    /**
99
     * @return DamageAmount
100
     */
101
    public function amount(){
102
        return $this->amount;
103
    }
104
105
    /**
106
     * @return AuthorId
107
     */
108
    public function getAuthor()
109
    {
110
        return $this->author;
111
    }
112
113
    /**
114
     * Invoice the damage.
115
     *
116
     * @return FlightDamage
117
     */
118
    public function invoice(){
119
        return new self($this->flight, $this->amount, true, $this->author, $this->id);
0 ignored issues
show
Documentation introduced by
$this->flight is of type object<FlightLog\Domain\Damage\FlightId>, but the function expects a object<FlightLog\Domain\Damage\DamageAmount>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
true is of type boolean, but the function expects a object<FlightLog\Domain\Damage\AuthorId>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$this->author is of type object<FlightLog\Domain\Damage\AuthorId>, but the function expects a null|object<FlightLog\Domain\Damage\FlightId>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
120
    }
121
122
    /**
123
     * @return DamageId|null
124
     */
125
    public function getId()
126
    {
127
        return $this->id;
128
    }
129
130
}