Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
16.95% covered (danger)
16.95%
10 / 59
25.00% covered (danger)
25.00%
7 / 28
CRAP
0.00% covered (danger)
0.00%
0 / 1
ModeleAnalyse
16.95% covered (danger)
16.95%
10 / 59
25.00% covered (danger)
25.00%
7 / 28
910.29
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 __clone
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
12
 deserialize
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 1
30
 getId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 __toString
60.00% covered (warning)
60.00%
3 / 5
0.00% covered (danger)
0.00%
0 / 1
3.58
 getNom
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setNom
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getDescription
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setDescription
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getLabelAmeliorationPrevue
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setLabelAmeliorationPrevue
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getLabelInsatisfaisant
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setLabelInsatisfaisant
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getLabelSatisfaisant
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setLabelSatisfaisant
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getAuthorizedCollectivities
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setAuthorizedCollectivities
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 addAuthorizedCollectivity
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 getCriterePrincipeFondamentaux
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setCriterePrincipeFondamentaux
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 getQuestionConformites
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setQuestionConformites
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getScenarioMenaces
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setScenarioMenaces
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 getOptionRightSelection
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setOptionRightSelection
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getAuthorizedCollectivityTypes
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setAuthorizedCollectivityTypes
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace App\Domain\AIPD\Model;
6
7use App\Application\Traits\Model\HistoryTrait;
8use App\Domain\User\Model\Collectivity;
9use Doctrine\Common\Collections\Collection;
10use JMS\Serializer\Annotation as Serializer;
11use Ramsey\Uuid\Uuid;
12use Ramsey\Uuid\UuidInterface;
13
14/**
15 * @Serializer\ExclusionPolicy("none")
16 */
17class ModeleAnalyse
18{
19    use HistoryTrait;
20
21    /**
22     * @Serializer\Exclude
23     */
24    private ?UuidInterface $id;
25
26    private string $nom;
27    private string $description;
28
29    private string $labelAmeliorationPrevue;
30
31    private string $labelInsatisfaisant;
32
33    private string $labelSatisfaisant;
34
35    /**
36     * @var Collection|Collectivity[]
37     *
38     * @Serializer\Exclude
39     */
40    private $authorizedCollectivities;
41
42    /**
43     * @var array|CriterePrincipeFondamental[]
44     *
45     * @Serializer\Type("array<App\Domain\AIPD\Model\CriterePrincipeFondamental>")
46     */
47    private iterable $criterePrincipeFondamentaux;
48
49    /**
50     * @var array|ModeleQuestionConformite[]
51     *
52     * @Serializer\Type("array<App\Domain\AIPD\Model\ModeleQuestionConformite>")
53     */
54    private $questionConformites;
55
56    /**
57     * @var array|ModeleScenarioMenace[]
58     *
59     * @Serializer\Type("array<App\Domain\AIPD\Model\ModeleScenarioMenace>")
60     */
61    private $scenarioMenaces;
62
63    /**
64     * @see DuplicationTargetOptionDictionary
65     *
66     * @Serializer\Exclude
67     */
68    private ?string $optionRightSelection = null;
69
70    /**
71     * @see CollectivityTypeDictionary
72     *
73     * @Serializer\Exclude
74     */
75    private ?iterable $authorizedCollectivityTypes;
76
77    /**
78     * @var \DateTimeImmutable|null
79     *
80     * @Serializer\Type("DateTimeImmutable")
81     */
82    private $createdAt;
83
84    /**
85     * @var \DateTimeImmutable|null
86     *
87     * @Serializer\Type("DateTimeImmutable")
88     */
89    private $updatedAt;
90
91    public function __construct()
92    {
93        $this->id = Uuid::uuid4();
94    }
95
96    public function __clone()
97    {
98        $this->id                       = null;
99        $this->authorizedCollectivities = null;
100
101        $questions = [];
102        foreach ($this->questionConformites as $questionConformite) {
103            $questions[] = clone $questionConformite;
104        }
105        $this->questionConformites = $questions;
106
107        $scenarios = [];
108        foreach ($this->scenarioMenaces as $scenario) {
109            $scenarios[] = clone $scenario;
110        }
111        $this->scenarioMenaces = $scenarios;
112    }
113
114    public function deserialize(): void
115    {
116        $this->id = Uuid::uuid4();
117
118        foreach ($this->scenarioMenaces as $scenario) {
119            $scenario->deserialize();
120            $scenario->setModeleAnalyse($this);
121            foreach ($scenario->getMesuresProtections() as $mesure) {
122                $mesure->addScenarioMenace($scenario);
123            }
124        }
125        foreach ($this->questionConformites as $question) {
126            $question->deserialize();
127            $question->setModeleAnalyse($this);
128        }
129        foreach ($this->criterePrincipeFondamentaux as $critere) {
130            $critere->deserialize();
131            $critere->setModeleAnalyse($this);
132        }
133    }
134
135    public function getId(): ?UuidInterface
136    {
137        return $this->id;
138    }
139
140    public function __toString(): string
141    {
142        if (\is_null($this->getNom())) {
143            return '';
144        }
145
146        if (\mb_strlen($this->getNom()) > 150) {
147            return \mb_substr($this->getNom(), 0, 150) . '...';
148        }
149
150        return $this->getNom();
151    }
152
153    public function getNom(): string
154    {
155        return $this->nom;
156    }
157
158    public function setNom(string $nom): void
159    {
160        $this->nom = $nom;
161    }
162
163    public function getDescription(): string
164    {
165        return $this->description;
166    }
167
168    public function setDescription(string $description): void
169    {
170        $this->description = $description;
171    }
172
173    public function getLabelAmeliorationPrevue(): string
174    {
175        return $this->labelAmeliorationPrevue;
176    }
177
178    public function setLabelAmeliorationPrevue(string $labelAmeliorationPrevue): void
179    {
180        $this->labelAmeliorationPrevue = $labelAmeliorationPrevue;
181    }
182
183    public function getLabelInsatisfaisant(): string
184    {
185        return $this->labelInsatisfaisant;
186    }
187
188    public function setLabelInsatisfaisant(string $labelInsatisfaisant): void
189    {
190        $this->labelInsatisfaisant = $labelInsatisfaisant;
191    }
192
193    public function getLabelSatisfaisant(): string
194    {
195        return $this->labelSatisfaisant;
196    }
197
198    public function setLabelSatisfaisant(string $labelSatisfaisant): void
199    {
200        $this->labelSatisfaisant = $labelSatisfaisant;
201    }
202
203    public function getAuthorizedCollectivities()
204    {
205        return $this->authorizedCollectivities;
206    }
207
208    public function setAuthorizedCollectivities($authorizedCollectivities): void
209    {
210        $this->authorizedCollectivities = $authorizedCollectivities;
211    }
212
213    public function addAuthorizedCollectivity(Collectivity $collectivity)
214    {
215        if ($this->authorizedCollectivities->contains($collectivity)) {
216            return;
217        }
218
219        $this->authorizedCollectivities[] = $collectivity;
220        $collectivity->addModeleAnalyse($this);
221    }
222
223    public function getCriterePrincipeFondamentaux()
224    {
225        return $this->criterePrincipeFondamentaux;
226    }
227
228    public function setCriterePrincipeFondamentaux($criterePrincipeFondamentaux): void
229    {
230        /** @var CriterePrincipeFondamental $critere */
231        foreach ($criterePrincipeFondamentaux as $critere) {
232            $critere->setModeleAnalyse($this);
233        }
234        $this->criterePrincipeFondamentaux = $criterePrincipeFondamentaux;
235    }
236
237    public function getQuestionConformites()
238    {
239        return $this->questionConformites;
240    }
241
242    public function setQuestionConformites($questionConformites): void
243    {
244        $this->questionConformites = $questionConformites;
245    }
246
247    public function getScenarioMenaces()
248    {
249        return $this->scenarioMenaces;
250    }
251
252    public function setScenarioMenaces($scenarioMenaces): void
253    {
254        foreach ($scenarioMenaces as $scenarioMenace) {
255            $scenarioMenace->setModeleAnalyse($this);
256        }
257        $this->scenarioMenaces = $scenarioMenaces;
258    }
259
260    public function getOptionRightSelection()
261    {
262        return $this->optionRightSelection;
263    }
264
265    public function setOptionRightSelection($optionRightSelection)
266    {
267        $this->optionRightSelection = $optionRightSelection;
268    }
269
270    public function getAuthorizedCollectivityTypes()
271    {
272        return $this->authorizedCollectivityTypes;
273    }
274
275    public function setAuthorizedCollectivityTypes(iterable $authorizedCollectivityTypes)
276    {
277        $this->authorizedCollectivityTypes = $authorizedCollectivityTypes;
278    }
279}