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

Damage::getFlightId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace FlightLog\Application\Damage\ViewModel;
5
6
7
final class Damage
8
{
9
10
    /**
11
     * @var string
12
     */
13
    private $authorName;
14
15
    /**
16
     * @var float
17
     */
18
    private $amount;
19
20
    /**
21
     * @var int
22
     */
23
    public $id;
24
25
    /**
26
     * @var bool
27
     */
28
    private $invoiced;
29
30
    /**
31
     * @var array
32
     */
33
    public $linkedObjects;
34
35
    /**
36
     * @var int|null
37
     */
38
    private $flightId;
39
40
    /**
41
     * @param string $authorName
42
     * @param float $amount
43
     * @param int $id
44
     * @param bool $invoiced
45
     * @param int $flightId
46
     */
47
    public function __construct($authorName, $amount, $id, $invoiced, $flightId)
48
    {
49
        $this->authorName = $authorName;
50
        $this->amount = $amount;
51
        $this->id = $id;
52
        $this->invoiced = $invoiced;
53
        $this->linkedObjects = [];
54
        $this->flightId = $flightId;
55
    }
56
57
    /**
58
     * @param array $properties
59
     *
60
     * @return Damage
61
     */
62
    public static function fromArray(array $properties){
63
        $author = $properties['author_name'];
64
        $amount = $properties['amount'];
65
        $id = $properties['id'];
66
        $flightId = isset($properties['flight_id']) ? $properties['flight_id'] : null;
67
        $invoiced = (bool)$properties['invoiced'];
68
69
        return new self($author, $amount, $id, $invoiced, $flightId);
70
    }
71
72
    /**
73
     * @return string
74
     */
75
    public function getAuthorName()
76
    {
77
        return $this->authorName;
78
    }
79
80
    /**
81
     * @return float
82
     */
83
    public function getAmount()
84
    {
85
        return $this->amount;
86
    }
87
88
    /**
89
     * @return int
90
     */
91
    public function getId()
92
    {
93
        return $this->id;
94
    }
95
96
    /**
97
     * @return bool
98
     */
99
    public function isInvoiced()
100
    {
101
        return $this->invoiced;
102
    }
103
104
    public function __call($name, $arguments)
105
    {}
106
107
    /**
108
     * @param int $elementId
109
     * @param string $elementType
110
     * @param \CommonObject $element
111
     */
112
    public function addLink($elementId, $elementType, $element)
113
    {
114
        $this->linkedObjects[$elementType][$elementId] = $element;
115
    }
116
117
    /**
118
     * @return int|null
119
     */
120
    public function getFlightId()
121
    {
122
        return $this->flightId;
123
    }
124
}