Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
23.53% |
8 / 34 |
|
30.00% |
6 / 20 |
CRAP | |
0.00% |
0 / 1 |
Conformite | |
23.53% |
8 / 34 |
|
30.00% |
6 / 20 |
238.44 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getConformite | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setConformite | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getProcessus | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setProcessus | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getEvaluation | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setEvaluation | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getActionProtections | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getNonAppliedActionProtections | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
setActionProtections | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
addReponse | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
removeReponse | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
getReponses | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getPilote | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setPilote | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
__clone | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
cloneReponses | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
__toString | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
isInUserServices | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace App\Domain\Registry\Model\ConformiteOrganisation; |
4 | |
5 | use App\Application\Interfaces\CollectivityRelated; |
6 | use App\Application\Traits\Model\CollectivityTrait; |
7 | use App\Application\Traits\Model\HistoryTrait; |
8 | use App\Domain\Registry\Dictionary\MesurementStatusDictionary; |
9 | use App\Domain\Registry\Model\Mesurement; |
10 | use App\Domain\Reporting\Model\LoggableSubject; |
11 | use App\Domain\User\Model\User; |
12 | use Ramsey\Uuid\Uuid; |
13 | use Ramsey\Uuid\UuidInterface; |
14 | |
15 | /** |
16 | * Modelize the relation between Processus and Evaluation. |
17 | * Contain the conformité rating. |
18 | */ |
19 | class Conformite implements LoggableSubject, CollectivityRelated |
20 | { |
21 | use CollectivityTrait; |
22 | use HistoryTrait; |
23 | /** |
24 | * @var UuidInterface |
25 | */ |
26 | private $id; |
27 | |
28 | /** |
29 | * @var float|null |
30 | */ |
31 | private $conformite; |
32 | |
33 | /** |
34 | * @var Processus |
35 | */ |
36 | private $processus; |
37 | |
38 | /** |
39 | * @var Evaluation |
40 | */ |
41 | private $evaluation; |
42 | |
43 | /** |
44 | * @var iterable |
45 | */ |
46 | private $actionProtections; |
47 | |
48 | /** |
49 | * @var iterable |
50 | */ |
51 | private $reponses; |
52 | |
53 | /** |
54 | * @var string |
55 | */ |
56 | private $pilote; |
57 | |
58 | public function __construct() |
59 | { |
60 | $this->id = Uuid::uuid4(); |
61 | $this->reponses = []; |
62 | $this->actionProtections = []; |
63 | } |
64 | |
65 | public function getId(): UuidInterface |
66 | { |
67 | return $this->id; |
68 | } |
69 | |
70 | public function getConformite(): ?float |
71 | { |
72 | return $this->conformite; |
73 | } |
74 | |
75 | public function setConformite(?float $conformite): void |
76 | { |
77 | $this->conformite = $conformite; |
78 | } |
79 | |
80 | public function getProcessus(): Processus |
81 | { |
82 | return $this->processus; |
83 | } |
84 | |
85 | public function setProcessus(Processus $processus): void |
86 | { |
87 | $this->processus = $processus; |
88 | } |
89 | |
90 | public function getEvaluation(): Evaluation |
91 | { |
92 | return $this->evaluation; |
93 | } |
94 | |
95 | public function setEvaluation(Evaluation $evaluation): void |
96 | { |
97 | $this->evaluation = $evaluation; |
98 | } |
99 | |
100 | public function getActionProtections(): iterable |
101 | { |
102 | return $this->actionProtections; |
103 | } |
104 | |
105 | public function getNonAppliedActionProtections() |
106 | { |
107 | return array_filter(\iterable_to_array($this->actionProtections), |
108 | function (Mesurement $action) { |
109 | return MesurementStatusDictionary::STATUS_NOT_APPLIED === $action->getStatus(); |
110 | }); |
111 | } |
112 | |
113 | public function setActionProtections(iterable $actionProtections): void |
114 | { |
115 | $this->actionProtections = $actionProtections; |
116 | } |
117 | |
118 | public function addReponse(Reponse $reponse): void |
119 | { |
120 | $this->reponses[] = $reponse; |
121 | $reponse->setConformite($this); |
122 | } |
123 | |
124 | public function removeReponse(Reponse $reponse): void |
125 | { |
126 | $key = \array_search($reponse, $this->reponses, true); |
127 | |
128 | if (false === $key) { |
129 | return; |
130 | } |
131 | |
132 | unset($this->reponses[$key]); |
133 | } |
134 | |
135 | public function getReponses(): iterable |
136 | { |
137 | return $this->reponses; |
138 | } |
139 | |
140 | public function getPilote(): ?string |
141 | { |
142 | return $this->pilote; |
143 | } |
144 | |
145 | public function setPilote(?string $pilote): void |
146 | { |
147 | $this->pilote = $pilote; |
148 | } |
149 | |
150 | public function __clone() |
151 | { |
152 | $this->id = Uuid::uuid4(); |
153 | $reponses = $this->reponses; |
154 | $this->reponses = []; |
155 | $this->cloneReponses($reponses); |
156 | $this->actionProtections = \iterable_to_array($this->actionProtections); |
157 | } |
158 | |
159 | private function cloneReponses(iterable $reponses) |
160 | { |
161 | foreach ($reponses as $reponse) { |
162 | $this->addReponse(clone $reponse); |
163 | } |
164 | } |
165 | |
166 | public function __toString(): string |
167 | { |
168 | return 'Conformité ' . $this->processus->getNom(); |
169 | } |
170 | |
171 | public function isInUserServices(User $user): bool |
172 | { |
173 | return true; |
174 | } |
175 | } |