1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SDIS62\Core\Ops\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
6
|
|
|
use SDIS62\Core\Common\Entity\IdentityTrait; |
7
|
|
|
|
8
|
|
|
class Materiel |
9
|
|
|
{ |
10
|
|
|
use IdentityTrait; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Nom du materiel. |
14
|
|
|
* |
15
|
|
|
* @var string |
16
|
|
|
*/ |
17
|
|
|
protected $name; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Centre dans lequel le matériel est affecté. |
21
|
|
|
* |
22
|
|
|
* @var SDIS62\Core\Ops\Entity\Centre |
23
|
|
|
*/ |
24
|
|
|
protected $centre; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Liste des engagements du matériel. |
28
|
|
|
* |
29
|
|
|
* @var SDIS62\Core\Ops\Entity\Engagement[] |
30
|
|
|
*/ |
31
|
|
|
protected $engagements; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Coordonnées du matériel. |
35
|
|
|
* |
36
|
|
|
* @var SDIS62\Core\Ops\Entity\Coordinates |
37
|
|
|
*/ |
38
|
|
|
protected $coordinates; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Etat du matériel. |
42
|
|
|
* |
43
|
|
|
* @var SDIS62\Core\Ops\Entity\Statut |
44
|
|
|
*/ |
45
|
|
|
protected $statut; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Ajout d'un materiel à un centre. |
49
|
|
|
* |
50
|
|
|
* @param SDIS62\Core\Ops\Entity\Centre $centre |
51
|
|
|
* @param string $name |
52
|
|
|
*/ |
53
|
|
|
public function __construct(Centre $centre, $name) |
54
|
|
|
{ |
55
|
|
|
$this->name = $name; |
56
|
|
|
$this->centre = $centre; |
|
|
|
|
57
|
|
|
$this->centre->addMateriel($this); |
58
|
|
|
$this->engagements = new ArrayCollection(); |
|
|
|
|
59
|
|
|
$this->statut = Statut::DISPONIBLE(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Get the value of Nom du materiel. |
64
|
|
|
* |
65
|
|
|
* @return string |
66
|
|
|
*/ |
67
|
|
|
public function getName() |
68
|
|
|
{ |
69
|
|
|
return $this->name; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Set the value of Nom du materiel. |
74
|
|
|
* |
75
|
|
|
* @param string name |
76
|
|
|
* |
77
|
|
|
* @return self |
78
|
|
|
*/ |
79
|
|
|
public function setName($name) |
80
|
|
|
{ |
81
|
|
|
$this->name = $name; |
82
|
|
|
|
83
|
|
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Get the value of Centre dans lequel le materiel est affecté. |
88
|
|
|
* |
89
|
|
|
* @return SDIS62\Core\Ops\Entity\Centre |
90
|
|
|
*/ |
91
|
|
|
public function getCentre() |
92
|
|
|
{ |
93
|
|
|
return $this->centre; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Set the value of Centre dans lequel le materiel est affecté. |
98
|
|
|
* |
99
|
|
|
* @param SDIS62\Core\Ops\Entity\Centre centre |
100
|
|
|
* |
101
|
|
|
* @return self |
102
|
|
|
*/ |
103
|
|
|
public function setCentre(Centre $centre) |
104
|
|
|
{ |
105
|
|
|
$this->centre = $centre; |
|
|
|
|
106
|
|
|
|
107
|
|
|
return $this; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Get the value of Liste des engagements du matériel. |
112
|
|
|
* |
113
|
|
|
* @return SDIS62\Core\Ops\Entity\Engagement[] |
114
|
|
|
*/ |
115
|
|
|
public function getEngagements() |
116
|
|
|
{ |
117
|
|
|
return $this->engagements; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Ajoute un engagement au matériel. |
122
|
|
|
* |
123
|
|
|
* @param SDIS62\Core\Ops\Entity\Engagement $engagement |
124
|
|
|
* |
125
|
|
|
* @return self |
126
|
|
|
*/ |
127
|
|
|
public function addEngagement(Engagement $engagement) |
128
|
|
|
{ |
129
|
|
|
$this->engagements[] = $engagement; |
130
|
|
|
|
131
|
|
|
return $this; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* Le matériel est il actuellement engagé ? |
136
|
|
|
* |
137
|
|
|
* @return bool |
138
|
|
|
*/ |
139
|
|
|
public function isEngage() |
140
|
|
|
{ |
141
|
|
|
foreach ($this->engagements as $engagement) { |
142
|
|
|
if (!$engagement->isEnded()) { |
143
|
|
|
return true; |
144
|
|
|
} |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
return false; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* Get the value of Coordonnées du matériel. |
152
|
|
|
* |
153
|
|
|
* @return SDIS62\Core\Ops\Entity\Coordinates |
154
|
|
|
*/ |
155
|
|
|
public function getCoordinates() |
156
|
|
|
{ |
157
|
|
|
return $this->coordinates; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* Set the value of Coordonnées du matériel. |
162
|
|
|
* |
163
|
|
|
* @param SDIS62\Core\Ops\Entity\Coordinates $coordinates |
164
|
|
|
* |
165
|
|
|
* @return self |
166
|
|
|
*/ |
167
|
|
|
public function setCoordinates(Coordinates $coordinates) |
168
|
|
|
{ |
169
|
|
|
$this->coordinates = $coordinates; |
|
|
|
|
170
|
|
|
|
171
|
|
|
return $this; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Get the value of Etat du matériel. |
176
|
|
|
* |
177
|
|
|
* @return SDIS62\Core\Ops\Entity\Statut |
178
|
|
|
*/ |
179
|
|
|
public function getStatut() |
180
|
|
|
{ |
181
|
|
|
return $this->statut instanceof Statut ? $this->statut : Statut::getByName($this->statut); |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* Set the value of Etat du matériel. |
186
|
|
|
* |
187
|
|
|
* @param SDIS62\Core\Ops\Entity\Statut statut |
188
|
|
|
* |
189
|
|
|
* @return self |
190
|
|
|
*/ |
191
|
|
|
public function setStatut(Statut $statut) |
192
|
|
|
{ |
193
|
|
|
$this->statut = $statut; |
|
|
|
|
194
|
|
|
|
195
|
|
|
return $this; |
196
|
|
|
} |
197
|
|
|
} |
198
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..