Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
16.22% |
6 / 37 |
|
17.65% |
3 / 17 |
CRAP | |
0.00% |
0 / 1 |
Evaluation | |
16.22% |
6 / 37 |
|
17.65% |
3 / 17 |
280.37 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDate | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setDate | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getParticipants | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setParticipant | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
addParticipant | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
removeParticipant | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
__toString | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
addConformite | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
removeConformite | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
getConformites | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isDraft | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setIsDraft | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
__clone | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
cloneConformites | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
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\Reporting\Model\LoggableSubject; |
9 | use App\Domain\User\Model\User; |
10 | use Ramsey\Uuid\Uuid; |
11 | use Ramsey\Uuid\UuidInterface; |
12 | |
13 | class Evaluation implements LoggableSubject, CollectivityRelated |
14 | { |
15 | use HistoryTrait; |
16 | use CollectivityTrait; |
17 | |
18 | /** |
19 | * @var UuidInterface |
20 | */ |
21 | private $id; |
22 | |
23 | /** |
24 | * @var \DateTime|null |
25 | */ |
26 | private $date; |
27 | |
28 | /** |
29 | * @var iterable |
30 | */ |
31 | private $participants; |
32 | |
33 | /** |
34 | * @var iterable |
35 | */ |
36 | private $conformites; |
37 | |
38 | /** |
39 | * @var bool |
40 | */ |
41 | private $isDraft; |
42 | |
43 | public function __construct() |
44 | { |
45 | $this->id = Uuid::uuid4(); |
46 | $this->participants = []; |
47 | $this->conformites = []; |
48 | $this->isDraft = true; |
49 | } |
50 | |
51 | public function getId(): UuidInterface |
52 | { |
53 | return $this->id; |
54 | } |
55 | |
56 | public function getDate(): ?\DateTime |
57 | { |
58 | return $this->date; |
59 | } |
60 | |
61 | public function setDate(?\DateTime $date): void |
62 | { |
63 | $this->date = $date; |
64 | } |
65 | |
66 | public function getParticipants(): iterable |
67 | { |
68 | return $this->participants; |
69 | } |
70 | |
71 | public function setParticipant(array $participants): void |
72 | { |
73 | $this->participants = $participants; |
74 | } |
75 | |
76 | public function addParticipant(Participant $participant): void |
77 | { |
78 | $this->participants[] = $participant; |
79 | $participant->setEvaluation($this); |
80 | } |
81 | |
82 | public function removeParticipant(Participant $participant) |
83 | { |
84 | $key = \array_search($participant, iterable_to_array($this->participants), true); |
85 | |
86 | if (false === $key) { |
87 | return; |
88 | } |
89 | |
90 | unset($this->participants[$key]); |
91 | } |
92 | |
93 | public function __toString(): string |
94 | { |
95 | if (null !== $this->date) { |
96 | return $this->collectivity->getName() . ' ' . date_format($this->date, 'Y-m-d'); |
97 | } |
98 | |
99 | return $this->collectivity->getName(); |
100 | } |
101 | |
102 | public function addConformite(Conformite $conformite): void |
103 | { |
104 | $this->conformites[] = $conformite; |
105 | $conformite->setEvaluation($this); |
106 | } |
107 | |
108 | public function removeConformite(Conformite $conformite): void |
109 | { |
110 | $key = \array_search($conformite, $this->conformites, true); |
111 | |
112 | if (false === $key) { |
113 | return; |
114 | } |
115 | |
116 | unset($this->$conformite[$key]); |
117 | } |
118 | |
119 | public function getConformites(): iterable |
120 | { |
121 | return $this->conformites; |
122 | } |
123 | |
124 | public function isDraft(): bool |
125 | { |
126 | return $this->isDraft; |
127 | } |
128 | |
129 | public function setIsDraft(bool $isDraft): void |
130 | { |
131 | $this->isDraft = $isDraft; |
132 | } |
133 | |
134 | public function __clone() |
135 | { |
136 | $this->id = Uuid::uuid4(); |
137 | $tmpConformites = $this->conformites; |
138 | $this->conformites = []; |
139 | $this->participants = []; |
140 | $this->cloneConformites($tmpConformites); |
141 | $this->date = null; |
142 | $this->isDraft = true; |
143 | } |
144 | |
145 | private function cloneConformites(iterable $conformites) |
146 | { |
147 | foreach ($conformites as $conformite) { |
148 | $this->addConformite(clone $conformite); |
149 | } |
150 | } |
151 | |
152 | public function isInUserServices(User $user): bool |
153 | { |
154 | return true; |
155 | } |
156 | } |