Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
58.02% |
47 / 81 |
|
60.34% |
35 / 58 |
CRAP | |
0.00% |
0 / 1 |
Mesurement | |
58.02% |
47 / 81 |
|
60.34% |
35 / 58 |
527.96 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
1 | |||
__toString | |
60.00% |
3 / 5 |
|
0.00% |
0 / 1 |
3.58 | |||
getId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getUpdatedBy | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setUpdatedBy | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getType | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setType | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getDescription | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setDescription | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getCost | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setCost | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getCharge | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setCharge | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getStatus | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setStatus | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getPlanificationDate | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setPlanificationDate | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getComment | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setComment | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getClonedFrom | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setClonedFrom | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getPriority | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setPriority | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getManager | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setManager | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getConformiteOrganisation | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getConformiteTraitementReponses | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getTreatments | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setTreatments | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
addTreatment | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
removeTreatment | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
20 | |||
getContractors | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setContractors | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
addContractor | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
removeContractor | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
20 | |||
getRequests | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setRequests | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
addRequest | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
removeRequest | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
20 | |||
getViolations | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setViolations | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
addViolation | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
removeViolation | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
20 | |||
getTools | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setTools | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
addTool | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
removeTool | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
20 | |||
getProofs | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setProofs | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
addProof | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
removeProof | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
12 | |||
getAnswerSurveys | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setAnswerSurveys | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getMesurements | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setMesurements | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
addMesurement | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | /** |
4 | * This file is part of the MADIS - RGPD Management application. |
5 | * |
6 | * @copyright Copyright (c) 2018-2019 Soluris - Solutions Numériques Territoriales Innovantes |
7 | * |
8 | * This program is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU Affero General Public License as published by |
10 | * the Free Software Foundation, either version 3 of the License, or |
11 | * (at your option) any later version. |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU Affero General Public License for more details. |
17 | * |
18 | * You should have received a copy of the GNU Affero General Public License |
19 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
20 | */ |
21 | |
22 | declare(strict_types=1); |
23 | |
24 | namespace App\Domain\Registry\Model; |
25 | |
26 | use App\Application\Interfaces\CollectivityRelated; |
27 | use App\Application\Traits\Model\CollectivityTrait; |
28 | use App\Application\Traits\Model\CreatorTrait; |
29 | use App\Application\Traits\Model\HistoryTrait; |
30 | use App\Application\Traits\Model\ServiceTrait; |
31 | use App\Domain\Registry\Model\ConformiteTraitement\Reponse; |
32 | use App\Domain\Reporting\Model\LoggableSubject; |
33 | use App\Domain\User\Model\Service; |
34 | use Doctrine\Common\Collections\ArrayCollection; |
35 | use Doctrine\Common\Collections\Collection; |
36 | use Ramsey\Uuid\Uuid; |
37 | use Ramsey\Uuid\UuidInterface; |
38 | |
39 | /** |
40 | * Action de protection / Plan d'action. |
41 | */ |
42 | class Mesurement implements LoggableSubject, CollectivityRelated |
43 | { |
44 | use CollectivityTrait; |
45 | use CreatorTrait; |
46 | use HistoryTrait; |
47 | use ServiceTrait; |
48 | |
49 | /** |
50 | * @var UuidInterface |
51 | */ |
52 | private $id; |
53 | |
54 | /** |
55 | * FR: Nom. |
56 | * |
57 | * @var string|null |
58 | */ |
59 | private $name; |
60 | |
61 | /** |
62 | * FR: Type. |
63 | * |
64 | * @var string|null |
65 | */ |
66 | private $type; |
67 | |
68 | /** |
69 | * FR: Description. |
70 | * |
71 | * @var string|null |
72 | */ |
73 | private $description; |
74 | |
75 | /** |
76 | * FR: Cout. |
77 | * |
78 | * @var string|null |
79 | */ |
80 | private $cost; |
81 | |
82 | /** |
83 | * FR: Charge. |
84 | * |
85 | * @var string|null |
86 | */ |
87 | private $charge; |
88 | |
89 | /** |
90 | * FR: Statut. |
91 | * |
92 | * @var string|null |
93 | */ |
94 | private $status; |
95 | |
96 | /** |
97 | * FR: Modifié par. |
98 | * |
99 | * @var string|null |
100 | */ |
101 | private $updatedBy; |
102 | |
103 | /** |
104 | * FR: Date de planification. |
105 | * |
106 | * @var \DateTime|null |
107 | */ |
108 | private $planificationDate; |
109 | |
110 | /** |
111 | * @var string|null |
112 | */ |
113 | private $comment; |
114 | |
115 | /** |
116 | * @var Mesurement|null |
117 | */ |
118 | private $clonedFrom; |
119 | |
120 | /** |
121 | * @var string|null |
122 | */ |
123 | private $priority; |
124 | |
125 | /** |
126 | * @var string|null |
127 | */ |
128 | private $manager; |
129 | |
130 | /** |
131 | * @var iterable |
132 | */ |
133 | private $conformiteOrganisation; |
134 | |
135 | /** |
136 | * @var iterable |
137 | */ |
138 | private $conformiteTraitementReponses; |
139 | |
140 | private Collection $treatments; |
141 | private Collection $contractors; |
142 | private Collection $requests; |
143 | private Collection $violations; |
144 | private Collection $proofs; |
145 | private Collection $tools; |
146 | /** |
147 | * @var Service|null |
148 | */ |
149 | private $service; |
150 | private Collection $mesurements; |
151 | |
152 | private ?iterable $answerSurveys; |
153 | |
154 | /** |
155 | * Mesurement constructor. |
156 | * |
157 | * @throws \Exception |
158 | */ |
159 | public function __construct() |
160 | { |
161 | $this->id = Uuid::uuid4(); |
162 | $this->proofs = new ArrayCollection(); |
163 | $this->treatments = new ArrayCollection(); |
164 | $this->requests = new ArrayCollection(); |
165 | $this->violations = new ArrayCollection(); |
166 | $this->contractors = new ArrayCollection(); |
167 | $this->tools = new ArrayCollection(); |
168 | $this->mesurements = new ArrayCollection(); |
169 | $this->conformiteTraitementReponses = []; |
170 | $this->conformiteOrganisation = []; |
171 | } |
172 | |
173 | public function __toString(): string |
174 | { |
175 | if (\is_null($this->getName())) { |
176 | return ''; |
177 | } |
178 | |
179 | if (\mb_strlen($this->getName()) > 150) { |
180 | return \mb_substr($this->getName(), 0, 150) . '...'; |
181 | } |
182 | |
183 | return $this->getName(); |
184 | } |
185 | |
186 | public function getId(): UuidInterface |
187 | { |
188 | return $this->id; |
189 | } |
190 | |
191 | public function getUpdatedBy(): ?string |
192 | { |
193 | return $this->updatedBy; |
194 | } |
195 | |
196 | public function setUpdatedBy(?string $updatedBy): void |
197 | { |
198 | $this->updatedBy = $updatedBy; |
199 | } |
200 | |
201 | public function getName(): ?string |
202 | { |
203 | return $this->name; |
204 | } |
205 | |
206 | public function setName(?string $name): void |
207 | { |
208 | $this->name = $name; |
209 | } |
210 | |
211 | public function getType(): ?string |
212 | { |
213 | return $this->type; |
214 | } |
215 | |
216 | public function setType(?string $type): void |
217 | { |
218 | $this->type = $type; |
219 | } |
220 | |
221 | public function getDescription(): ?string |
222 | { |
223 | return $this->description; |
224 | } |
225 | |
226 | public function setDescription(?string $description): void |
227 | { |
228 | $this->description = $description; |
229 | } |
230 | |
231 | public function getCost(): ?string |
232 | { |
233 | return $this->cost; |
234 | } |
235 | |
236 | public function setCost(?string $cost): void |
237 | { |
238 | $this->cost = $cost; |
239 | } |
240 | |
241 | public function getCharge(): ?string |
242 | { |
243 | return $this->charge; |
244 | } |
245 | |
246 | public function setCharge(?string $charge): void |
247 | { |
248 | $this->charge = $charge; |
249 | } |
250 | |
251 | public function getStatus(): ?string |
252 | { |
253 | return $this->status; |
254 | } |
255 | |
256 | public function setStatus(?string $status): void |
257 | { |
258 | $this->status = $status; |
259 | } |
260 | |
261 | public function getPlanificationDate(): ?\DateTime |
262 | { |
263 | return $this->planificationDate; |
264 | } |
265 | |
266 | public function setPlanificationDate(?\DateTime $planificationDate): void |
267 | { |
268 | $this->planificationDate = $planificationDate; |
269 | } |
270 | |
271 | public function getComment(): ?string |
272 | { |
273 | return $this->comment; |
274 | } |
275 | |
276 | public function setComment(?string $comment): void |
277 | { |
278 | $this->comment = $comment; |
279 | } |
280 | |
281 | public function getClonedFrom(): ?Mesurement |
282 | { |
283 | return $this->clonedFrom; |
284 | } |
285 | |
286 | public function setClonedFrom(?Mesurement $clonedFrom): void |
287 | { |
288 | $this->clonedFrom = $clonedFrom; |
289 | } |
290 | |
291 | public function getPriority(): ?string |
292 | { |
293 | return $this->priority; |
294 | } |
295 | |
296 | public function setPriority(?string $priority): void |
297 | { |
298 | $this->priority = $priority; |
299 | } |
300 | |
301 | public function getManager(): ?string |
302 | { |
303 | return $this->manager; |
304 | } |
305 | |
306 | public function setManager(?string $manager): void |
307 | { |
308 | $this->manager = $manager; |
309 | } |
310 | |
311 | public function getConformiteOrganisation() |
312 | { |
313 | return $this->conformiteOrganisation; |
314 | } |
315 | |
316 | /** |
317 | * @return Reponse[] |
318 | */ |
319 | public function getConformiteTraitementReponses() |
320 | { |
321 | return $this->conformiteTraitementReponses; |
322 | } |
323 | |
324 | public function getTreatments(): Collection |
325 | { |
326 | return $this->treatments; |
327 | } |
328 | |
329 | public function setTreatments(Collection $treatments) |
330 | { |
331 | $this->treatments = $treatments; |
332 | } |
333 | |
334 | public function addTreatment(Treatment $treatment): void |
335 | { |
336 | $this->treatments[] = $treatment; |
337 | } |
338 | |
339 | public function removeTreatment(Treatment $treatment): void |
340 | { |
341 | if ($this->treatments && $this->treatments->count() && $this->treatments->contains($treatment)) { |
342 | $this->treatments->removeElement($treatment); |
343 | } |
344 | } |
345 | |
346 | public function getContractors(): Collection |
347 | { |
348 | return $this->contractors; |
349 | } |
350 | |
351 | public function setContractors(Collection $contractors): void |
352 | { |
353 | $this->contractors = $contractors; |
354 | } |
355 | |
356 | public function addContractor(Contractor $contractor): void |
357 | { |
358 | $this->contractors[] = $contractor; |
359 | } |
360 | |
361 | public function removeContractor(Contractor $contractor): void |
362 | { |
363 | if ($this->contractors && $this->contractors->count() && $this->contractors->contains($contractor)) { |
364 | $this->contractors->removeElement($contractor); |
365 | } |
366 | } |
367 | |
368 | public function getRequests(): Collection |
369 | { |
370 | return $this->requests; |
371 | } |
372 | |
373 | public function setRequests(Collection $requests): void |
374 | { |
375 | $this->requests = $requests; |
376 | } |
377 | |
378 | public function addRequest(Request $request): void |
379 | { |
380 | $this->requests[] = $request; |
381 | } |
382 | |
383 | public function removeRequest(Request $request): void |
384 | { |
385 | if ($this->requests && $this->requests->count() && $this->requests->contains($request)) { |
386 | $this->requests->removeElement($request); |
387 | } |
388 | } |
389 | |
390 | public function getViolations(): Collection |
391 | { |
392 | return $this->violations; |
393 | } |
394 | |
395 | public function setViolations(Collection $violations): void |
396 | { |
397 | $this->violations = $violations; |
398 | } |
399 | |
400 | public function addViolation(Violation $violation): void |
401 | { |
402 | $this->violations->add($violation); |
403 | } |
404 | |
405 | public function removeViolation(Violation $violation): void |
406 | { |
407 | if ($this->violations && $this->violations->count() && $this->violations->contains($violation)) { |
408 | $this->violations->removeElement($violation); |
409 | } |
410 | } |
411 | |
412 | public function getTools(): Collection |
413 | { |
414 | return $this->tools; |
415 | } |
416 | |
417 | public function setTools(Collection $tools): void |
418 | { |
419 | $this->tools = $tools; |
420 | } |
421 | |
422 | public function addTool(Tool $tool): void |
423 | { |
424 | $this->tools->add($tool); |
425 | } |
426 | |
427 | public function removeTool(Tool $tool): void |
428 | { |
429 | if ($this->tools && $this->tools->count() && $this->tools->contains($tool)) { |
430 | $this->tools->removeElement($tool); |
431 | } |
432 | } |
433 | |
434 | public function getProofs(): Collection |
435 | { |
436 | return $this->proofs; |
437 | } |
438 | |
439 | public function setProofs(Collection $proofs): void |
440 | { |
441 | $this->proofs = $proofs; |
442 | } |
443 | |
444 | public function addProof(Proof $proof): void |
445 | { |
446 | $this->proofs->add($proof); |
447 | $proof->addMesurement($this); |
448 | } |
449 | |
450 | public function removeProof(Proof $proof): void |
451 | { |
452 | if ($this->proofs->count() && $this->proofs->contains($proof)) { |
453 | $this->proofs->removeElement($proof); |
454 | } |
455 | $proof->removeMesurement($this); |
456 | } |
457 | |
458 | public function getAnswerSurveys(): ?iterable |
459 | { |
460 | return $this->answerSurveys; |
461 | } |
462 | |
463 | public function setAnswerSurveys(?iterable $answerSurveys): void |
464 | { |
465 | $this->answerSurveys = $answerSurveys; |
466 | } |
467 | |
468 | public function getMesurements(): ArrayCollection|Collection |
469 | { |
470 | return $this->mesurements; |
471 | } |
472 | |
473 | public function setMesurements(ArrayCollection|Collection $mesurements): void |
474 | { |
475 | $this->mesurements = $mesurements; |
476 | foreach ($mesurements as $mesurement) { |
477 | $mesurement->addMesurement($this); |
478 | } |
479 | } |
480 | |
481 | public function addMesurement(Mesurement $mesurement): void |
482 | { |
483 | $this->mesurements->add($mesurement); |
484 | } |
485 | } |