Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
52.43% covered (warning)
52.43%
54 / 103
55.56% covered (warning)
55.56%
40 / 72
CRAP
0.00% covered (danger)
0.00%
0 / 1
Collectivity
52.43% covered (warning)
52.43%
54 / 103
55.56% covered (warning)
55.56%
40 / 72
769.06
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
12 / 12
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
60.00% covered (warning)
60.00%
3 / 5
0.00% covered (danger)
0.00%
0 / 1
3.58
 getName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getShortName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setShortName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 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
 getType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getSiren
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setSiren
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isActive
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setActive
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getWebsite
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setWebsite
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getAddress
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setAddress
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getLegalManager
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setLegalManager
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getReferent
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setReferent
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isDifferentDpo
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setDifferentDpo
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getDpo
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setDpo
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isDifferentItManager
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setDifferentItManager
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getItManager
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setItManager
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getUsers
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setUsers
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 addService
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 removeService
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 getServices
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setServices
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getIsServicesEnabled
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setIsServicesEnabled
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getReportingBlockManagementCommitment
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setReportingBlockManagementCommitment
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getReportingBlockContinuousImprovement
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setReportingBlockContinuousImprovement
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 addComiteIlContact
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 removeComiteIlContact
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 getComiteIlContacts
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getModeleAnalyses
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setModeleAnalyses
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 addModeleAnalyse
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 isHasModuleConformiteTraitement
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setHasModuleConformiteTraitement
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isHasModuleConformiteOrganisation
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setHasModuleConformiteOrganisation
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getEvaluations
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getUserReferents
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getInformationsComplementaires
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setInformationsComplementaires
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getFinessGeo
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setFinessGeo
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getReferentiels
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setReferentiels
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 addReferentiel
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 getNbrAgents
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setNbrAgents
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getNbrCnil
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setNbrCnil
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getPopulation
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setPopulation
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 isHasModuleTools
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setHasModuleTools
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getReviewData
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setReviewData
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\User\Model;
25
26use App\Application\Traits\Model\HistoryTrait;
27use App\Domain\AIPD\Model\ModeleAnalyse;
28use App\Domain\Maturity\Model\Referentiel;
29use App\Domain\Reporting\Model\LoggableSubject;
30use App\Domain\User\Model\Embeddable\Address;
31use App\Domain\User\Model\Embeddable\Contact;
32use Doctrine\Common\Collections\ArrayCollection;
33use Doctrine\Common\Collections\Collection;
34use Ramsey\Uuid\Uuid;
35use Ramsey\Uuid\UuidInterface;
36use Symfony\Component\Validator\Constraints as Assert;
37
38/**
39 * Organisation.
40 */
41class Collectivity implements LoggableSubject
42{
43    use HistoryTrait;
44
45    /**
46     * @var UuidInterface
47     */
48    private $id;
49
50    /**
51     * @var string|null
52     */
53    private $name;
54
55    /**
56     * @var string|null
57     */
58    private $shortName;
59
60    /**
61     * @var string|null
62     */
63    private $type;
64
65    /**
66     * @var string|null
67     */
68    private $updatedBy;
69
70    /**
71     * @var string|null
72     *
73     * @Assert\Length(
74     *       min = 9,
75     *       max = 14,
76     *       minMessage = "Le SIREN doit contenir au moins 9 caractères.",
77     *       maxMessage = "Le SIREN ne peut pas dépasser 14 caractères."
78     *  )
79     *
80     * @Assert\NotBlank(message="Le SIREN est obligatoire.")
81     *
82     * @Assert\Regex(
83     *      pattern="/^\d+$/",
84     *      message="Le SIREN ne doit contenir que des chiffres."
85     *  )
86     */
87    private $siren;
88
89    /**
90     * @var bool
91     */
92    private $active;
93
94    /**
95     * @var string|null
96     */
97    private $website;
98
99    /**
100     * @var Address|null
101     */
102    private $address;
103
104    /**
105     * @var Contact|null
106     */
107    private $legalManager;
108
109    /**
110     * @var Contact|null
111     */
112    private $referent;
113
114    /**
115     * @var bool
116     */
117    private $differentDpo;
118
119    /**
120     * @var Contact|null
121     */
122    private $dpo;
123
124    /**
125     * @var bool
126     */
127    private $differentItManager;
128
129    /**
130     * @var Contact|null
131     */
132    private $itManager;
133
134    /**
135     * @var Collection
136     */
137    private $users;
138
139    /**
140     * @var Collection|Service[]
141     */
142    private $services;
143
144    /**
145     * @var bool|null
146     */
147    private $isServicesEnabled;
148
149    /**
150     * @var string|null
151     */
152    private $reportingBlockManagementCommitment;
153
154    /**
155     * @var string|null
156     */
157    private $reportingBlockContinuousImprovement;
158
159    /**
160     * @var Collection|Contact[]
161     */
162    private $comiteIlContacts;
163
164    /**
165     * @var Collection|ModeleAnalyse[]
166     */
167    private $modeleAnalyses;
168
169    /**
170     * @var Collection|Referentiel[]
171     */
172    private $referentiels;
173
174    /**
175     * @var bool
176     */
177    private $hasModuleConformiteTraitement;
178
179    /**
180     * @var bool
181     */
182    private $hasModuleConformiteOrganisation;
183    /**
184     * @var bool
185     */
186    private $hasModuleTools;
187
188    /**
189     * @var iterable
190     */
191    private $evaluations;
192
193    /**
194     * @var iterable
195     */
196    private $userReferents;
197
198    /**
199     * @var string|null
200     */
201    private $informationsComplementaires;
202
203    /**
204     * @var string|null
205     */
206    private $finessGeo;
207
208    /**
209     * @var int|null
210     */
211    private $population;
212    /**
213     * @var int|null
214     */
215    private $nbrAgents;
216    /**
217     * @var int|null
218     */
219    private $nbrCnil;
220
221    /**
222     * @var ReviewData|null
223     */
224    private $reviewData;
225
226    /**
227     * Collectivity constructor.
228     *
229     * @throws \Exception
230     */
231    public function __construct()
232    {
233        $this->id                              = Uuid::uuid4();
234        $this->users                           = new ArrayCollection();
235        $this->comiteIlContacts                = new ArrayCollection();
236        $this->services                        = new ArrayCollection();
237        $this->active                          = true;
238        $this->differentDpo                    = false;
239        $this->differentItManager              = false;
240        $this->hasModuleConformiteTraitement   = false;
241        $this->hasModuleConformiteOrganisation = false;
242        $this->hasModuleTools                  = false;
243        $this->evaluations                     = [];
244        $this->userReferents                   = [];
245    }
246
247    public function getId(): UuidInterface
248    {
249        return $this->id;
250    }
251
252    public function __toString(): string
253    {
254        if (\is_null($this->getName())) {
255            return '';
256        }
257
258        if (\mb_strlen($this->getName()) > 150) {
259            return \mb_substr($this->getName(), 0, 150) . '...';
260        }
261
262        return $this->getName();
263    }
264
265    public function getName(): ?string
266    {
267        return $this->name;
268    }
269
270    public function setName(?string $name): void
271    {
272        $this->name = $name;
273    }
274
275    public function getShortName(): ?string
276    {
277        return $this->shortName;
278    }
279
280    public function setShortName(?string $shortName): void
281    {
282        $this->shortName = $shortName;
283    }
284
285    public function getUpdatedBy(): ?string
286    {
287        return $this->updatedBy;
288    }
289
290    public function setUpdatedBy(?string $updatedBy): void
291    {
292        $this->updatedBy = $updatedBy;
293    }
294
295    public function getType(): ?string
296    {
297        return $this->type;
298    }
299
300    public function setType(?string $type): void
301    {
302        $this->type = $type;
303    }
304
305    public function getSiren(): ?string
306    {
307        return $this->siren;
308    }
309
310    public function setSiren(?string $siren): void
311    {
312        $this->siren = $siren;
313    }
314
315    public function isActive(): bool
316    {
317        return $this->active;
318    }
319
320    public function setActive(bool $active): void
321    {
322        $this->active = $active;
323    }
324
325    public function getWebsite(): ?string
326    {
327        return $this->website;
328    }
329
330    public function setWebsite(?string $website): void
331    {
332        $this->website = $website;
333    }
334
335    public function getAddress(): ?Address
336    {
337        return $this->address;
338    }
339
340    public function setAddress(?Address $address): void
341    {
342        $this->address = $address;
343    }
344
345    public function getLegalManager(): ?Contact
346    {
347        return $this->legalManager;
348    }
349
350    public function setLegalManager(?Contact $legalManager): void
351    {
352        $this->legalManager = $legalManager;
353    }
354
355    public function getReferent(): ?Contact
356    {
357        return $this->referent;
358    }
359
360    public function setReferent(?Contact $referent): void
361    {
362        $this->referent = $referent;
363    }
364
365    public function isDifferentDpo(): bool
366    {
367        return $this->differentDpo;
368    }
369
370    public function setDifferentDpo(bool $differentDpo): void
371    {
372        $this->differentDpo = $differentDpo;
373    }
374
375    public function getDpo(): ?Contact
376    {
377        return $this->dpo;
378    }
379
380    public function setDpo(?Contact $dpo): void
381    {
382        $this->dpo = $dpo;
383    }
384
385    public function isDifferentItManager(): bool
386    {
387        return $this->differentItManager;
388    }
389
390    public function setDifferentItManager(bool $differentItManager): void
391    {
392        $this->differentItManager = $differentItManager;
393    }
394
395    public function getItManager(): ?Contact
396    {
397        return $this->itManager;
398    }
399
400    public function setItManager(?Contact $itManager): void
401    {
402        $this->itManager = $itManager;
403    }
404
405    public function getUsers(): Collection
406    {
407        return $this->users;
408    }
409
410    public function setUsers(Collection $users): void
411    {
412        $this->users = $users;
413    }
414
415    public function addService(Service $service)
416    {
417        if ($this->services->contains($service)) {
418            return;
419        }
420
421        $this->services[] = $service;
422        $service->setCollectivity($this);
423    }
424
425    public function removeService(Service $service)
426    {
427        if (!$this->services->contains($service)) {
428            return;
429        }
430
431        $this->services->removeElement($service);
432    }
433
434    /**
435     * @return Collection|Service[]
436     */
437    public function getServices(): Collection
438    {
439        return $this->services;
440    }
441
442    public function setServices(Collection $services): void
443    {
444        $this->services = $services;
445    }
446
447    public function getIsServicesEnabled(): ?bool
448    {
449        return $this->isServicesEnabled;
450    }
451
452    public function setIsServicesEnabled(?bool $isServicesEnabled): void
453    {
454        $this->isServicesEnabled = $isServicesEnabled;
455    }
456
457    public function getReportingBlockManagementCommitment(): ?string
458    {
459        return $this->reportingBlockManagementCommitment;
460    }
461
462    public function setReportingBlockManagementCommitment(?string $reportingBlockManagementCommitment): void
463    {
464        $this->reportingBlockManagementCommitment = $reportingBlockManagementCommitment;
465    }
466
467    public function getReportingBlockContinuousImprovement(): ?string
468    {
469        return $this->reportingBlockContinuousImprovement;
470    }
471
472    public function setReportingBlockContinuousImprovement(?string $reportingBlockContinuousImprovement): void
473    {
474        $this->reportingBlockContinuousImprovement = $reportingBlockContinuousImprovement;
475    }
476
477    public function addComiteIlContact(ComiteIlContact $contact)
478    {
479        if ($this->comiteIlContacts->contains($contact)) {
480            return;
481        }
482
483        $this->comiteIlContacts[] = $contact;
484        $contact->setCollectivity($this);
485    }
486
487    public function removeComiteIlContact(ComiteIlContact $contact)
488    {
489        if (!$this->comiteIlContacts->contains($contact)) {
490            return;
491        }
492
493        $this->comiteIlContacts->removeElement($contact);
494    }
495
496    /**
497     * @return Collection|ComiteIlContact[]
498     */
499    public function getComiteIlContacts()
500    {
501        return $this->comiteIlContacts;
502    }
503
504    public function getModeleAnalyses()
505    {
506        return $this->modeleAnalyses;
507    }
508
509    public function setModeleAnalyses($modeleAnalyses): void
510    {
511        $this->modeleAnalyses = $modeleAnalyses;
512    }
513
514    public function addModeleAnalyse(ModeleAnalyse $modeleAnalyse)
515    {
516        if ($this->modeleAnalyses->contains($modeleAnalyse)) {
517            return;
518        }
519
520        $this->modeleAnalyses[] = $modeleAnalyse;
521        $modeleAnalyse->addAuthorizedCollectivity($this);
522    }
523
524    public function isHasModuleConformiteTraitement(): ?bool
525    {
526        return $this->hasModuleConformiteTraitement;
527    }
528
529    public function setHasModuleConformiteTraitement(bool $hasModuleConformiteTraitement): void
530    {
531        $this->hasModuleConformiteTraitement = $hasModuleConformiteTraitement;
532    }
533
534    public function isHasModuleConformiteOrganisation(): bool
535    {
536        return $this->hasModuleConformiteOrganisation;
537    }
538
539    public function setHasModuleConformiteOrganisation(bool $hasModuleConformiteOrganisation): void
540    {
541        $this->hasModuleConformiteOrganisation = $hasModuleConformiteOrganisation;
542    }
543
544    public function getEvaluations(): iterable
545    {
546        return $this->evaluations;
547    }
548
549    public function getUserReferents(): iterable
550    {
551        return $this->userReferents;
552    }
553
554    public function getInformationsComplementaires(): ?string
555    {
556        return $this->informationsComplementaires;
557    }
558
559    public function setInformationsComplementaires(?string $informationsComplementaires): void
560    {
561        $this->informationsComplementaires = $informationsComplementaires;
562    }
563
564    public function getFinessGeo(): ?string
565    {
566        return $this->finessGeo;
567    }
568
569    public function setFinessGeo(?string $finessGeo): void
570    {
571        $this->finessGeo = $finessGeo;
572    }
573
574    public function getReferentiels()
575    {
576        return $this->referentiels;
577    }
578
579    public function setReferentiels($referentiels): void
580    {
581        $this->referentiels = $referentiels;
582    }
583
584    public function addReferentiel(Referentiel $referentiel)
585    {
586        if ($this->referentiels->contains($referentiel)) {
587            return;
588        }
589
590        $this->referentiels[] = $referentiel;
591        $referentiel->addAuthorizedCollectivity($this);
592    }
593
594    public function getNbrAgents(): ?int
595    {
596        return $this->nbrAgents;
597    }
598
599    public function setNbrAgents(?int $nbrAgents): void
600    {
601        $this->nbrAgents = $nbrAgents;
602    }
603
604    public function getNbrCnil(): ?int
605    {
606        return $this->nbrCnil;
607    }
608
609    public function setNbrCnil(?int $nbrCnil): void
610    {
611        $this->nbrCnil = $nbrCnil;
612    }
613
614    public function getPopulation(): ?int
615    {
616        return $this->population;
617    }
618
619    public function setPopulation(?int $population): void
620    {
621        $this->population = $population;
622    }
623
624    public function isHasModuleTools(): bool
625    {
626        return $this->hasModuleTools;
627    }
628
629    public function setHasModuleTools(bool $hasModuleTools): void
630    {
631        $this->hasModuleTools = $hasModuleTools;
632    }
633
634    public function getReviewData(): ?ReviewData
635    {
636        return $this->reviewData;
637    }
638
639    public function setReviewData(?ReviewData $reviewData): void
640    {
641        $this->reviewData = $reviewData;
642    }
643}