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