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    public function __construct()
78    {
79        $this->id = Uuid::uuid4();
80    }
81
82    public function __clone()
83    {
84        $this->id                       = null;
85        $this->authorizedCollectivities = null;
86
87        $questions = [];
88        foreach ($this->questionConformites as $questionConformite) {
89            $questions[] = clone $questionConformite;
90        }
91        $this->questionConformites = $questions;
92
93        $scenarios = [];
94        foreach ($this->scenarioMenaces as $scenario) {
95            $scenarios[] = clone $scenario;
96        }
97        $this->scenarioMenaces = $scenarios;
98    }
99
100    public function deserialize(): void
101    {
102        $this->id = Uuid::uuid4();
103
104        foreach ($this->scenarioMenaces as $scenario) {
105            $scenario->deserialize();
106            $scenario->setModeleAnalyse($this);
107            foreach ($scenario->getMesuresProtections() as $mesure) {
108                $mesure->addScenarioMenace($scenario);
109            }
110        }
111        foreach ($this->questionConformites as $question) {
112            $question->deserialize();
113            $question->setModeleAnalyse($this);
114        }
115        foreach ($this->criterePrincipeFondamentaux as $critere) {
116            $critere->deserialize();
117            $critere->setModeleAnalyse($this);
118        }
119    }
120
121    public function getId(): ?UuidInterface
122    {
123        return $this->id;
124    }
125
126    public function __toString(): string
127    {
128        if (\is_null($this->getNom())) {
129            return '';
130        }
131
132        if (\mb_strlen($this->getNom()) > 150) {
133            return \mb_substr($this->getNom(), 0, 150) . '...';
134        }
135
136        return $this->getNom();
137    }
138
139    public function getNom(): string
140    {
141        return $this->nom;
142    }
143
144    public function setNom(string $nom): void
145    {
146        $this->nom = $nom;
147    }
148
149    public function getDescription(): string
150    {
151        return $this->description;
152    }
153
154    public function setDescription(string $description): void
155    {
156        $this->description = $description;
157    }
158
159    public function getLabelAmeliorationPrevue(): string
160    {
161        return $this->labelAmeliorationPrevue;
162    }
163
164    public function setLabelAmeliorationPrevue(string $labelAmeliorationPrevue): void
165    {
166        $this->labelAmeliorationPrevue = $labelAmeliorationPrevue;
167    }
168
169    public function getLabelInsatisfaisant(): string
170    {
171        return $this->labelInsatisfaisant;
172    }
173
174    public function setLabelInsatisfaisant(string $labelInsatisfaisant): void
175    {
176        $this->labelInsatisfaisant = $labelInsatisfaisant;
177    }
178
179    public function getLabelSatisfaisant(): string
180    {
181        return $this->labelSatisfaisant;
182    }
183
184    public function setLabelSatisfaisant(string $labelSatisfaisant): void
185    {
186        $this->labelSatisfaisant = $labelSatisfaisant;
187    }
188
189    public function getAuthorizedCollectivities()
190    {
191        return $this->authorizedCollectivities;
192    }
193
194    public function setAuthorizedCollectivities($authorizedCollectivities): void
195    {
196        $this->authorizedCollectivities = $authorizedCollectivities;
197    }
198
199    public function addAuthorizedCollectivity(Collectivity $collectivity)
200    {
201        if ($this->authorizedCollectivities->contains($collectivity)) {
202            return;
203        }
204
205        $this->authorizedCollectivities[] = $collectivity;
206        $collectivity->addModeleAnalyse($this);
207    }
208
209    public function getCriterePrincipeFondamentaux()
210    {
211        return $this->criterePrincipeFondamentaux;
212    }
213
214    public function setCriterePrincipeFondamentaux($criterePrincipeFondamentaux): void
215    {
216        /** @var CriterePrincipeFondamental $critere */
217        foreach ($criterePrincipeFondamentaux as $critere) {
218            $critere->setModeleAnalyse($this);
219        }
220        $this->criterePrincipeFondamentaux = $criterePrincipeFondamentaux;
221    }
222
223    public function getQuestionConformites()
224    {
225        return $this->questionConformites;
226    }
227
228    public function setQuestionConformites($questionConformites): void
229    {
230        $this->questionConformites = $questionConformites;
231    }
232
233    public function getScenarioMenaces()
234    {
235        return $this->scenarioMenaces;
236    }
237
238    public function setScenarioMenaces($scenarioMenaces): void
239    {
240        foreach ($scenarioMenaces as $scenarioMenace) {
241            $scenarioMenace->setModeleAnalyse($this);
242        }
243        $this->scenarioMenaces = $scenarioMenaces;
244    }
245
246    public function getOptionRightSelection()
247    {
248        return $this->optionRightSelection;
249    }
250
251    public function setOptionRightSelection($optionRightSelection)
252    {
253        $this->optionRightSelection = $optionRightSelection;
254    }
255
256    public function getAuthorizedCollectivityTypes()
257    {
258        return $this->authorizedCollectivityTypes;
259    }
260
261    public function setAuthorizedCollectivityTypes(iterable $authorizedCollectivityTypes)
262    {
263        $this->authorizedCollectivityTypes = $authorizedCollectivityTypes;
264    }
265}