Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
22.83% covered (danger)
22.83%
21 / 92
10.94% covered (danger)
10.94%
7 / 64
CRAP
0.00% covered (danger)
0.00%
0 / 1
Violation
22.83% covered (danger)
22.83%
21 / 92
10.94% covered (danger)
10.94%
7 / 64
3327.17
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
1 / 1
1
 getId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 __toString
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 getUpdatedBy
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setUpdatedBy
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDate
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setDate
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 isInProgress
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setInProgress
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getViolationNatures
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setViolationNatures
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getOrigins
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setOrigins
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getCause
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setCause
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getConcernedDataNature
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setConcernedDataNature
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getConcernedPeopleCategories
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setConcernedPeopleCategories
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getNbAffectedRows
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setNbAffectedRows
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getNbAffectedPersons
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setNbAffectedPersons
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getPotentialImpactsNature
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setPotentialImpactsNature
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getGravity
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setGravity
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getCommunication
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setCommunication
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getCommunicationPrecision
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setCommunicationPrecision
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getAppliedMeasuresAfterViolation
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setAppliedMeasuresAfterViolation
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getNotification
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setNotification
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getNotificationDetails
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setNotificationDetails
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getComment
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setComment
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getProofs
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setProofs
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 addProof
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 removeProof
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
20
 getMesurements
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setMesurements
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 addMesurement
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 removeMesurement
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
20
 addRequest
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 removeRequest
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
20
 addTreatment
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 removeTreatment
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
20
 getTreatments
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 addContractor
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 removeContractor
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
20
 getContractors
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getRequests
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setRequests
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getTools
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setTools
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 addTool
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 removeTool
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
20
 getViolations
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setViolations
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 addViolation
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
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
22declare(strict_types=1);
23
24namespace App\Domain\Registry\Model;
25
26use App\Application\Interfaces\CollectivityRelated;
27use App\Application\Traits\Model\CollectivityTrait;
28use App\Application\Traits\Model\CreatorTrait;
29use App\Application\Traits\Model\HistoryTrait;
30use App\Application\Traits\Model\ServiceTrait;
31use App\Application\Traits\Model\SoftDeletableTrait;
32use App\Domain\Reporting\Model\LoggableSubject;
33use Doctrine\Common\Collections\ArrayCollection;
34use Doctrine\Common\Collections\Collection;
35use Ramsey\Uuid\Uuid;
36use Ramsey\Uuid\UuidInterface;
37
38class Violation implements LoggableSubject, CollectivityRelated
39{
40    use CollectivityTrait;
41    use CreatorTrait;
42    use HistoryTrait;
43    use SoftDeletableTrait;
44    use ServiceTrait;
45
46    /**
47     * @var UuidInterface
48     */
49    private $id;
50
51    /**
52     * @var \DateTime|null
53     */
54    private $date;
55
56    /**
57     * @var bool
58     */
59    private $inProgress;
60
61    /**
62     * @var iterable
63     */
64    private $violationNatures;
65
66    /**
67     * @var iterable
68     */
69    private $origins;
70
71    /**
72     * @var string|null
73     */
74    private $cause;
75
76    /**
77     * @var string|null
78     */
79    private $updatedBy;
80
81    /**
82     * @var iterable
83     */
84    private $concernedDataNature;
85
86    /**
87     * @var iterable
88     */
89    private $concernedPeopleCategories;
90
91    /**
92     * @var int|null
93     */
94    private $nbAffectedRows;
95
96    /**
97     * @var int|null
98     */
99    private $nbAffectedPersons;
100
101    /**
102     * @var iterable
103     */
104    private $potentialImpactsNature;
105
106    /**
107     * @var string|null
108     */
109    private $gravity;
110
111    /**
112     * @var string|null
113     */
114    private $communication;
115
116    /**
117     * @var string|null
118     */
119    private $communicationPrecision;
120
121    /**
122     * @var string|null
123     */
124    private $appliedMeasuresAfterViolation;
125
126    /**
127     * @var string|null
128     */
129    private $notification;
130
131    /**
132     * @var string|null
133     */
134    private $notificationDetails;
135
136    /**
137     * @var string|null
138     */
139    private $comment;
140
141    private Collection $proofs;
142    private Collection $mesurements;
143    private Collection $treatments;
144    private Collection $contractors;
145    private Collection $requests;
146    private Collection $tools;
147    private Collection $violations;
148
149    /**
150     * Violation constructor.
151     *
152     * @throws \Exception
153     */
154    public function __construct()
155    {
156        $this->id                        = Uuid::uuid4();
157        $this->date                      = new \DateTime();
158        $this->inProgress                = false;
159        $this->violationNatures          = [];
160        $this->origins                   = [];
161        $this->concernedDataNature       = [];
162        $this->concernedPeopleCategories = [];
163        $this->potentialImpactsNature    = [];
164        $this->proofs                    = new ArrayCollection();
165        $this->mesurements               = new ArrayCollection();
166        $this->treatments                = new ArrayCollection();
167        $this->contractors               = new ArrayCollection();
168        $this->requests                  = new ArrayCollection();
169        $this->tools                     = new ArrayCollection();
170        $this->violations                = new ArrayCollection();
171    }
172
173    public function getId(): UuidInterface
174    {
175        return $this->id;
176    }
177
178    public function __toString(): string
179    {
180        if (\is_null($this->getDate())) {
181            return '';
182        }
183
184        return "Violation du {$this->getDate()->format('d/m/Y')}";
185    }
186
187    public function getUpdatedBy(): ?string
188    {
189        return $this->updatedBy;
190    }
191
192    public function setUpdatedBy(?string $updatedBy): void
193    {
194        $this->updatedBy = $updatedBy;
195    }
196
197    public function getDate(): ?\DateTime
198    {
199        return $this->date;
200    }
201
202    public function setDate(?\DateTime $date): void
203    {
204        $this->date = $date;
205    }
206
207    public function isInProgress(): bool
208    {
209        return $this->inProgress;
210    }
211
212    public function setInProgress(bool $inProgress): void
213    {
214        $this->inProgress = $inProgress;
215    }
216
217    public function getViolationNatures(): iterable
218    {
219        return $this->violationNatures;
220    }
221
222    public function setViolationNatures(iterable $violationNatures): void
223    {
224        $this->violationNatures = $violationNatures;
225    }
226
227    public function getOrigins(): iterable
228    {
229        return $this->origins;
230    }
231
232    public function setOrigins(iterable $origins): void
233    {
234        $this->origins = $origins;
235    }
236
237    public function getCause(): ?string
238    {
239        return $this->cause;
240    }
241
242    public function setCause(?string $cause): void
243    {
244        $this->cause = $cause;
245    }
246
247    public function getConcernedDataNature(): iterable
248    {
249        return $this->concernedDataNature;
250    }
251
252    public function setConcernedDataNature(iterable $concernedDataNature): void
253    {
254        $this->concernedDataNature = $concernedDataNature;
255    }
256
257    public function getConcernedPeopleCategories(): iterable
258    {
259        return $this->concernedPeopleCategories;
260    }
261
262    public function setConcernedPeopleCategories(iterable $concernedPeopleCategories): void
263    {
264        $this->concernedPeopleCategories = $concernedPeopleCategories;
265    }
266
267    public function getNbAffectedRows(): ?int
268    {
269        return $this->nbAffectedRows;
270    }
271
272    public function setNbAffectedRows(?int $nbAffectedRows): void
273    {
274        $this->nbAffectedRows = $nbAffectedRows;
275    }
276
277    public function getNbAffectedPersons(): ?int
278    {
279        return $this->nbAffectedPersons;
280    }
281
282    public function setNbAffectedPersons(?int $nbAffectedPersons): void
283    {
284        $this->nbAffectedPersons = $nbAffectedPersons;
285    }
286
287    public function getPotentialImpactsNature(): iterable
288    {
289        return $this->potentialImpactsNature;
290    }
291
292    public function setPotentialImpactsNature(iterable $potentialImpactsNature): void
293    {
294        $this->potentialImpactsNature = $potentialImpactsNature;
295    }
296
297    public function getGravity(): ?string
298    {
299        return $this->gravity;
300    }
301
302    public function setGravity(?string $gravity): void
303    {
304        $this->gravity = $gravity;
305    }
306
307    public function getCommunication(): ?string
308    {
309        return $this->communication;
310    }
311
312    public function setCommunication(?string $communication): void
313    {
314        $this->communication = $communication;
315    }
316
317    public function getCommunicationPrecision(): ?string
318    {
319        return $this->communicationPrecision;
320    }
321
322    public function setCommunicationPrecision(?string $communicationPrecision): void
323    {
324        $this->communicationPrecision = $communicationPrecision;
325    }
326
327    public function getAppliedMeasuresAfterViolation(): ?string
328    {
329        return $this->appliedMeasuresAfterViolation;
330    }
331
332    public function setAppliedMeasuresAfterViolation(?string $appliedMeasuresAfterViolation): void
333    {
334        $this->appliedMeasuresAfterViolation = $appliedMeasuresAfterViolation;
335    }
336
337    public function getNotification(): ?string
338    {
339        return $this->notification;
340    }
341
342    public function setNotification(?string $notification): void
343    {
344        $this->notification = $notification;
345    }
346
347    public function getNotificationDetails(): ?string
348    {
349        return $this->notificationDetails;
350    }
351
352    public function setNotificationDetails(?string $notificationDetails): void
353    {
354        $this->notificationDetails = $notificationDetails;
355    }
356
357    public function getComment(): ?string
358    {
359        return $this->comment;
360    }
361
362    public function setComment(?string $comment): void
363    {
364        $this->comment = $comment;
365    }
366
367    public function getProofs(): Collection
368    {
369        return $this->proofs;
370    }
371
372    public function setProofs($proofs)
373    {
374        $this->proofs = $proofs;
375    }
376
377    public function addProof(Proof $proof): void
378    {
379        $this->proofs->add($proof);
380        $proof->addViolation($this);
381    }
382
383    public function removeProof(Proof $proof): void
384    {
385        if ($this->proofs && $this->proofs->count() && $this->proofs->contains($proof)) {
386            $this->proofs->removeElement($proof);
387            $proof->removeViolation($this);
388        }
389    }
390
391    public function getMesurements(): Collection
392    {
393        return $this->mesurements;
394    }
395
396    public function setMesurements(Collection $mesurements): void
397    {
398        $this->mesurements = $mesurements;
399    }
400
401    public function addMesurement(Mesurement $mesurement): void
402    {
403        $this->mesurements->add($mesurement);
404        $mesurement->addViolation($this);
405    }
406
407    public function removeMesurement(Mesurement $mesurement): void
408    {
409        if ($this->mesurements && $this->mesurements->count() && $this->mesurements->contains($mesurement)) {
410            $this->mesurements->removeElement($mesurement);
411            $mesurement->removeViolation($this);
412        }
413    }
414
415    public function addRequest(Request $request): void
416    {
417        $this->requests[] = $request;
418    }
419
420    public function removeRequest(Request $request): void
421    {
422        if ($this->requests && $this->requests->count() && $this->requests->contains($request)) {
423            $this->requests->removeElement($request);
424        }
425    }
426
427    public function addTreatment(Treatment $treatment): void
428    {
429        $this->treatments[] = $treatment;
430    }
431
432    public function removeTreatment(Treatment $treatment): void
433    {
434        if ($this->treatments && $this->treatments->count() && $this->treatments->contains($treatment)) {
435            $this->treatments->removeElement($treatment);
436        }
437    }
438
439    public function getTreatments(): Collection
440    {
441        return $this->treatments;
442    }
443
444    public function addContractor(Contractor $contractor): void
445    {
446        $this->contractors[] = $contractor;
447    }
448
449    public function removeContractor(Contractor $contractor): void
450    {
451        if ($this->contractors && $this->contractors->count() && $this->contractors->contains($contractor)) {
452            $this->contractors->removeElement($contractor);
453        }
454    }
455
456    public function getContractors(): Collection
457    {
458        return $this->contractors;
459    }
460
461    public function getRequests(): ArrayCollection|Collection
462    {
463        return $this->requests;
464    }
465
466    public function setRequests(ArrayCollection|Collection $requests): void
467    {
468        $this->requests = $requests;
469    }
470
471    public function getTools(): ArrayCollection|Collection
472    {
473        return $this->tools;
474    }
475
476    public function setTools(ArrayCollection|Collection $tools): void
477    {
478        $this->tools = $tools;
479    }
480
481    public function addTool(Tool $tool): void
482    {
483        $this->tools[] = $tool;
484    }
485
486    public function removeTool(Tool $tool): void
487    {
488        if ($this->tools && $this->tools->count() && $this->tools->contains($tool)) {
489            $this->tools->removeElement($tool);
490        }
491    }
492
493    public function getViolations(): ArrayCollection|Collection
494    {
495        return $this->violations;
496    }
497
498    public function setViolations(ArrayCollection|Collection $violations): void
499    {
500        $this->violations = $violations;
501        foreach ($violations as $violation) {
502            $violation->addViolation($this);
503        }
504    }
505
506    public function addViolation(Violation $violation): void
507    {
508        $this->violations->add($violation);
509    }
510}