Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
50.00% |
46 / 92 |
|
60.71% |
34 / 56 |
CRAP | |
0.00% |
0 / 1 |
Contractor | |
50.00% |
46 / 92 |
|
60.71% |
34 / 56 |
818.12 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
1 | |||
getId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
__toString | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
12 | |||
getName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setName | |
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 | |||
getReferent | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setReferent | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isContractualClausesVerified | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setContractualClausesVerified | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getOtherInformations | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setOtherInformations | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getAddress | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setAddress | |
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 | |||
isAdoptedSecurityFeatures | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setAdoptedSecurityFeatures | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isMaintainsTreatmentRegister | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setMaintainsTreatmentRegister | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isSendingDataOutsideEu | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setSendingDataOutsideEu | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getDpo | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setDpo | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getLegalManager | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setLegalManager | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isHasDpo | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setHasDpo | |
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 / 2 |
|
0.00% |
0 / 1 |
2 | |||
removeTreatment | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
20 | |||
getMesurements | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setMesurements | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
addMesurement | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
removeMesurement | |
0.00% |
0 / 3 |
|
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 / 2 |
|
0.00% |
0 / 1 |
2 | |||
removeTool | |
0.00% |
0 / 3 |
|
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 / 2 |
|
0.00% |
0 / 1 |
2 | |||
removeRequest | |
0.00% |
0 / 3 |
|
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 / 2 |
|
0.00% |
0 / 1 |
2 | |||
removeViolation | |
0.00% |
0 / 3 |
|
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 |
20 | |||
getContractors | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setContractors | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
addContractor | |
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\Embeddable\Address; |
32 | use App\Domain\Reporting\Model\LoggableSubject; |
33 | use App\Domain\User\Model\Embeddable\Contact; |
34 | use App\Domain\User\Model\Service; |
35 | use Doctrine\Common\Collections\ArrayCollection; |
36 | use Doctrine\Common\Collections\Collection; |
37 | use Ramsey\Uuid\Uuid; |
38 | use Ramsey\Uuid\UuidInterface; |
39 | |
40 | class Contractor implements LoggableSubject, CollectivityRelated |
41 | { |
42 | use CollectivityTrait; |
43 | use CreatorTrait; |
44 | use HistoryTrait; |
45 | use ServiceTrait; |
46 | |
47 | /** |
48 | * @var UuidInterface |
49 | */ |
50 | private $id; |
51 | |
52 | /** |
53 | * @var string|null |
54 | */ |
55 | private $name; |
56 | |
57 | /** |
58 | * @var string|null |
59 | */ |
60 | private $referent; |
61 | |
62 | /** |
63 | * Clauses contractuelles vérifiées. |
64 | * |
65 | * @var bool |
66 | */ |
67 | private $contractualClausesVerified; |
68 | |
69 | /** |
70 | * @var string|null |
71 | */ |
72 | private $otherInformations; |
73 | |
74 | /** |
75 | * @var string|null |
76 | */ |
77 | private $updatedBy; |
78 | |
79 | /** |
80 | * @var Address|null |
81 | */ |
82 | private $address; |
83 | |
84 | /** |
85 | * @var Contractor|null |
86 | */ |
87 | private $clonedFrom; |
88 | |
89 | /** |
90 | * Adopte les éléments de sécurité. |
91 | * |
92 | * @var bool |
93 | */ |
94 | private $adoptedSecurityFeatures; |
95 | |
96 | /** |
97 | * Registre des traitements. |
98 | * |
99 | * @var bool |
100 | */ |
101 | private $maintainsTreatmentRegister; |
102 | |
103 | /** |
104 | * Données dans l'UE. |
105 | * |
106 | * @var bool |
107 | */ |
108 | private $sendingDataOutsideEu; |
109 | |
110 | /** |
111 | * @var Contact|null |
112 | */ |
113 | private $dpo; |
114 | |
115 | /** |
116 | * @var Contact|null |
117 | */ |
118 | private $legalManager; |
119 | |
120 | /** |
121 | * @var bool |
122 | */ |
123 | private $hasDpo; |
124 | |
125 | /** |
126 | * @var Service|null |
127 | */ |
128 | private $service; |
129 | |
130 | private Collection $mesurements; |
131 | private Collection $requests; |
132 | private Collection $violations; |
133 | private Collection $tools; |
134 | private Collection $treatments; |
135 | private Collection $proofs; |
136 | private Collection $contractors; |
137 | |
138 | /** |
139 | * Contractor constructor. |
140 | * |
141 | * @throws \Exception |
142 | */ |
143 | public function __construct() |
144 | { |
145 | $this->id = Uuid::uuid4(); |
146 | $this->contractualClausesVerified = false; |
147 | $this->adoptedSecurityFeatures = false; |
148 | $this->maintainsTreatmentRegister = false; |
149 | $this->sendingDataOutsideEu = false; |
150 | $this->hasDpo = false; |
151 | $this->treatments = new ArrayCollection(); |
152 | $this->proofs = new ArrayCollection(); |
153 | $this->tools = new ArrayCollection(); |
154 | $this->mesurements = new ArrayCollection(); |
155 | $this->requests = new ArrayCollection(); |
156 | $this->violations = new ArrayCollection(); |
157 | $this->contractors = new ArrayCollection(); |
158 | } |
159 | |
160 | public function getId(): UuidInterface |
161 | { |
162 | return $this->id; |
163 | } |
164 | |
165 | public function __toString(): string |
166 | { |
167 | if (\is_null($this->getName())) { |
168 | return ''; |
169 | } |
170 | |
171 | if (\mb_strlen($this->getName()) > 150) { |
172 | return \mb_substr($this->getName(), 0, 150) . '...'; |
173 | } |
174 | |
175 | return $this->getName(); |
176 | } |
177 | |
178 | public function getName(): ?string |
179 | { |
180 | return $this->name; |
181 | } |
182 | |
183 | public function setName(?string $name): void |
184 | { |
185 | $this->name = $name; |
186 | } |
187 | |
188 | public function getUpdatedBy(): ?string |
189 | { |
190 | return $this->updatedBy; |
191 | } |
192 | |
193 | public function setUpdatedBy(?string $updatedBy): void |
194 | { |
195 | $this->updatedBy = $updatedBy; |
196 | } |
197 | |
198 | public function getReferent(): ?string |
199 | { |
200 | return $this->referent; |
201 | } |
202 | |
203 | public function setReferent(?string $referent): void |
204 | { |
205 | $this->referent = $referent; |
206 | } |
207 | |
208 | public function isContractualClausesVerified(): bool |
209 | { |
210 | return $this->contractualClausesVerified; |
211 | } |
212 | |
213 | public function setContractualClausesVerified(bool $contractualClausesVerified): void |
214 | { |
215 | $this->contractualClausesVerified = $contractualClausesVerified; |
216 | } |
217 | |
218 | public function getOtherInformations(): ?string |
219 | { |
220 | return $this->otherInformations; |
221 | } |
222 | |
223 | public function setOtherInformations(?string $otherInformations): void |
224 | { |
225 | $this->otherInformations = $otherInformations; |
226 | } |
227 | |
228 | public function getAddress(): ?Address |
229 | { |
230 | return $this->address; |
231 | } |
232 | |
233 | public function setAddress(Address $address): void |
234 | { |
235 | $this->address = $address; |
236 | } |
237 | |
238 | public function getClonedFrom(): ?Contractor |
239 | { |
240 | return $this->clonedFrom; |
241 | } |
242 | |
243 | public function setClonedFrom(?Contractor $clonedFrom): void |
244 | { |
245 | $this->clonedFrom = $clonedFrom; |
246 | } |
247 | |
248 | public function isAdoptedSecurityFeatures(): bool |
249 | { |
250 | return $this->adoptedSecurityFeatures; |
251 | } |
252 | |
253 | public function setAdoptedSecurityFeatures(bool $adoptedSecurityFeatures): void |
254 | { |
255 | $this->adoptedSecurityFeatures = $adoptedSecurityFeatures; |
256 | } |
257 | |
258 | public function isMaintainsTreatmentRegister(): bool |
259 | { |
260 | return $this->maintainsTreatmentRegister; |
261 | } |
262 | |
263 | public function setMaintainsTreatmentRegister(bool $maintainsTreatmentRegister): void |
264 | { |
265 | $this->maintainsTreatmentRegister = $maintainsTreatmentRegister; |
266 | } |
267 | |
268 | public function isSendingDataOutsideEu(): bool |
269 | { |
270 | return $this->sendingDataOutsideEu; |
271 | } |
272 | |
273 | public function setSendingDataOutsideEu(bool $sendingDataOutsideEu): void |
274 | { |
275 | $this->sendingDataOutsideEu = $sendingDataOutsideEu; |
276 | } |
277 | |
278 | public function getDpo(): ?Contact |
279 | { |
280 | return $this->dpo; |
281 | } |
282 | |
283 | public function setDpo(?Contact $dpo): void |
284 | { |
285 | $this->dpo = $dpo; |
286 | } |
287 | |
288 | public function getLegalManager(): ?Contact |
289 | { |
290 | return $this->legalManager; |
291 | } |
292 | |
293 | public function setLegalManager(?Contact $legalManager): void |
294 | { |
295 | $this->legalManager = $legalManager; |
296 | } |
297 | |
298 | public function isHasDpo(): bool |
299 | { |
300 | return $this->hasDpo; |
301 | } |
302 | |
303 | public function setHasDpo(bool $hasDpo): void |
304 | { |
305 | $this->hasDpo = $hasDpo; |
306 | } |
307 | |
308 | public function getTreatments(): Collection |
309 | { |
310 | return $this->treatments; |
311 | } |
312 | |
313 | public function setTreatments(Collection $treatments) |
314 | { |
315 | $this->treatments = $treatments; |
316 | } |
317 | |
318 | public function addTreatment(Treatment $treatment): void |
319 | { |
320 | $treatment->addContractor($this); |
321 | $this->treatments->add($treatment); |
322 | } |
323 | |
324 | public function removeTreatment(Treatment $treatment): void |
325 | { |
326 | $treatment->removeContractor($this); |
327 | if ($this->treatments && $this->treatments->count() && $this->treatments->contains($treatment)) { |
328 | $this->treatments->removeElement($treatment); |
329 | } |
330 | } |
331 | |
332 | public function getMesurements(): Collection |
333 | { |
334 | return $this->mesurements; |
335 | } |
336 | |
337 | public function setMesurements(Collection $mesurements): void |
338 | { |
339 | $this->mesurements = $mesurements; |
340 | } |
341 | |
342 | public function addMesurement(Mesurement $mesurement): void |
343 | { |
344 | $mesurement->addContractor($this); |
345 | $this->mesurements->add($mesurement); |
346 | } |
347 | |
348 | public function removeMesurement(Mesurement $mesurement): void |
349 | { |
350 | $mesurement->removeContractor($this); |
351 | if ($this->mesurements && $this->mesurements->count() && $this->mesurements->contains($mesurement)) { |
352 | $this->mesurements->removeElement($mesurement); |
353 | } |
354 | } |
355 | |
356 | public function getTools(): Collection |
357 | { |
358 | return $this->tools; |
359 | } |
360 | |
361 | public function setTools(Collection $tools): void |
362 | { |
363 | $this->tools = $tools; |
364 | } |
365 | |
366 | public function addTool(Tool $tool): void |
367 | { |
368 | $tool->addContractor($this); |
369 | $this->tools->add($tool); |
370 | } |
371 | |
372 | public function removeTool(Tool $tool): void |
373 | { |
374 | $tool->removeContractor($this); |
375 | if ($this->tools && $this->tools->count() && $this->tools->contains($tool)) { |
376 | $this->tools->removeElement($tool); |
377 | } |
378 | } |
379 | |
380 | public function getRequests(): Collection |
381 | { |
382 | return $this->requests; |
383 | } |
384 | |
385 | public function setRequests(Collection $requests): void |
386 | { |
387 | $this->requests = $requests; |
388 | } |
389 | |
390 | public function addRequest(Request $request): void |
391 | { |
392 | $request->addContractor($this); |
393 | $this->requests->add($request); |
394 | } |
395 | |
396 | public function removeRequest(Request $request): void |
397 | { |
398 | $request->removeContractor($this); |
399 | if ($this->requests && $this->requests->count() && $this->requests->contains($request)) { |
400 | $this->requests->removeElement($request); |
401 | } |
402 | } |
403 | |
404 | public function getViolations(): Collection |
405 | { |
406 | return $this->violations; |
407 | } |
408 | |
409 | public function setViolations(Collection $violations): void |
410 | { |
411 | $this->violations = $violations; |
412 | } |
413 | |
414 | public function addViolation(Violation $violation): void |
415 | { |
416 | $violation->addContractor($this); |
417 | $this->violations->add($violation); |
418 | } |
419 | |
420 | public function removeViolation(Violation $violation): void |
421 | { |
422 | $violation->removeContractor($this); |
423 | if ($this->violations && $this->violations->count() && $this->violations->contains($violation)) { |
424 | $this->violations->removeElement($violation); |
425 | } |
426 | } |
427 | |
428 | public function getProofs(): Collection |
429 | { |
430 | return $this->proofs; |
431 | } |
432 | |
433 | public function setProofs(Collection $proofs) |
434 | { |
435 | $this->proofs = $proofs; |
436 | } |
437 | |
438 | public function addProof(Proof $proof): void |
439 | { |
440 | $proof->addContractor($this); |
441 | $this->proofs->add($proof); |
442 | } |
443 | |
444 | public function removeProof(Proof $proof): void |
445 | { |
446 | $proof->removeContractor($this); |
447 | if ($this->proofs && $this->proofs->count() && $this->proofs->contains($proof)) { |
448 | $this->proofs->removeElement($proof); |
449 | } |
450 | } |
451 | |
452 | public function getContractors(): ArrayCollection|Collection |
453 | { |
454 | return $this->contractors; |
455 | } |
456 | |
457 | public function setContractors(ArrayCollection|Collection $contractors): void |
458 | { |
459 | $this->contractors = $contractors; |
460 | foreach ($contractors as $contractor) { |
461 | $contractor->addContractor($this); |
462 | } |
463 | } |
464 | |
465 | public function addContractor(Contractor $contractor): void |
466 | { |
467 | $this->contractors->add($contractor); |
468 | } |
469 | } |