Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
25.93% covered (danger)
25.93%
14 / 54
20.00% covered (danger)
20.00%
7 / 35
CRAP
0.00% covered (danger)
0.00%
0 / 1
Proof
25.93% covered (danger)
25.93%
14 / 54
20.00% covered (danger)
20.00%
7 / 35
1330.60
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
8 / 8
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 / 5
0.00% covered (danger)
0.00%
0 / 1
12
 getName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getType
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getDocument
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setDocument
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDocumentFile
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setDocumentFile
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
 getTreatments
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 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
 getContractors
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 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
 getMesurements
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 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 removeMesurement
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
20
 getRequests
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 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
 getViolations
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 addViolation
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 removeViolation
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
20
 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
 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 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 addProof
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 App\Domain\User\Model\Service;
34use Doctrine\Common\Collections\ArrayCollection;
35use Doctrine\Common\Collections\Collection;
36use Ramsey\Uuid\Uuid;
37use Ramsey\Uuid\UuidInterface;
38use Symfony\Component\HttpFoundation\File\UploadedFile;
39
40class Proof implements LoggableSubject, CollectivityRelated
41{
42    use CollectivityTrait;
43    use CreatorTrait;
44    use HistoryTrait;
45    use SoftDeletableTrait;
46    use ServiceTrait;
47
48    /**
49     * @var UuidInterface
50     */
51    private $id;
52
53    /**
54     * @var string|null
55     */
56    private $name;
57
58    /**
59     * @var string|null
60     */
61    private $type;
62
63    /**
64     * @var string|null
65     */
66    private $document;
67
68    /**
69     * @var UploadedFile|null
70     */
71    private $documentFile;
72
73    /**
74     * @var string|null
75     */
76    private $comment;
77
78    private Collection $treatments;
79    private Collection $contractors;
80    private Collection $mesurements;
81    private Collection $requests;
82    private Collection $violations;
83    private Collection $tools;
84    /**
85     * @var Service|null
86     */
87    private $service;
88    private Collection $proofs;
89
90    /**
91     * Proof constructor.
92     *
93     * @throws \Exception
94     */
95    public function __construct()
96    {
97        $this->id          = Uuid::uuid4();
98        $this->treatments  = new ArrayCollection();
99        $this->contractors = new ArrayCollection();
100        $this->mesurements = new ArrayCollection();
101        $this->requests    = new ArrayCollection();
102        $this->violations  = new ArrayCollection();
103        $this->proofs      = new ArrayCollection();
104        $this->tools       = new ArrayCollection();
105    }
106
107    public function getId(): UuidInterface
108    {
109        return $this->id;
110    }
111
112    public function __toString(): string
113    {
114        if (\is_null($this->getName())) {
115            return '';
116        }
117
118        if (\mb_strlen($this->getName()) > 150) {
119            return \mb_substr($this->getName(), 0, 150) . '...';
120        }
121
122        return $this->getName();
123    }
124
125    public function getName(): ?string
126    {
127        return $this->name;
128    }
129
130    public function setName(?string $name): void
131    {
132        $this->name = $name;
133    }
134
135    public function getType(): ?string
136    {
137        return $this->type;
138    }
139
140    public function setType(?string $type): void
141    {
142        $this->type = $type;
143    }
144
145    public function getDocument(): ?string
146    {
147        return $this->document;
148    }
149
150    public function setDocument(?string $document): void
151    {
152        $this->document = $document;
153    }
154
155    public function getDocumentFile(): ?UploadedFile
156    {
157        return $this->documentFile;
158    }
159
160    public function setDocumentFile(?UploadedFile $documentFile): void
161    {
162        $this->documentFile = $documentFile;
163    }
164
165    public function getComment(): ?string
166    {
167        return $this->comment;
168    }
169
170    public function setComment(?string $comment): void
171    {
172        $this->comment = $comment;
173    }
174
175    public function getTreatments(): Collection
176    {
177        return $this->treatments;
178    }
179
180    public function addTreatment(Treatment $treatment): void
181    {
182        $this->treatments->add($treatment);
183    }
184
185    public function removeTreatment(Treatment $treatment): void
186    {
187        if ($this->treatments && $this->treatments->count() && $this->treatments->contains($treatment)) {
188            $this->treatments->removeElement($treatment);
189        }
190    }
191
192    public function getContractors(): Collection
193    {
194        return $this->contractors;
195    }
196
197    public function addContractor(Contractor $contractor): void
198    {
199        $this->contractors->add($contractor);
200    }
201
202    public function removeContractor(Contractor $contractor): void
203    {
204        if ($this->contractors && $this->contractors->count() && $this->contractors->contains($contractor)) {
205            $this->contractors->removeElement($contractor);
206        }
207    }
208
209    public function getMesurements(): Collection
210    {
211        return $this->mesurements;
212    }
213
214    public function addMesurement(Mesurement $mesurement): void
215    {
216        $this->mesurements->add($mesurement);
217    }
218
219    public function removeMesurement(Mesurement $mesurement): void
220    {
221        if ($this->mesurements && $this->mesurements->count() && $this->mesurements->contains($mesurement)) {
222            $this->mesurements->removeElement($mesurement);
223        }
224    }
225
226    public function getRequests(): Collection
227    {
228        return $this->requests;
229    }
230
231    public function addRequest(Request $request): void
232    {
233        $this->requests->add($request);
234    }
235
236    public function removeRequest(Request $request): void
237    {
238        if ($this->requests && $this->requests->count() && $this->requests->contains($request)) {
239            $this->requests->removeElement($request);
240        }
241    }
242
243    public function getViolations(): Collection
244    {
245        return $this->violations;
246    }
247
248    public function addViolation(Violation $violation): void
249    {
250        $this->violations->add($violation);
251    }
252
253    public function removeViolation(Violation $violation): void
254    {
255        if ($this->violations && $this->violations->count() && $this->violations->contains($violation)) {
256            $this->violations->removeElement($violation);
257        }
258    }
259
260    public function getTools(): ?Collection
261    {
262        return $this->tools;
263    }
264
265    public function setTools(Collection $tools): void
266    {
267        $this->tools = $tools;
268    }
269
270    public function addTool(Tool $tool): void
271    {
272        $this->tools->add($tool);
273    }
274
275    public function removeTool(Tool $tool): void
276    {
277        if ($this->tools && $this->tools->count() && $this->tools->contains($tool)) {
278            $this->tools->removeElement($tool);
279        }
280    }
281
282    public function getProofs(): ArrayCollection|Collection
283    {
284        return $this->proofs;
285    }
286
287    public function setProofs(ArrayCollection|Collection $proofs): void
288    {
289        $this->proofs = $proofs;
290        foreach ($proofs as $proof) {
291            $proof->addProof($this);
292        }
293    }
294
295    public function addProof(Proof $proof): void
296    {
297        $this->proofs->add($proof);
298    }
299}