Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
35.71% covered (danger)
35.71%
5 / 14
40.00% covered (danger)
40.00%
4 / 10
CRAP
0.00% covered (danger)
0.00%
0 / 1
AnswerSurvey
35.71% covered (danger)
35.71%
5 / 14
40.00% covered (danger)
40.00%
4 / 10
36.57
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 deserialize
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getAnswer
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setAnswer
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getSurvey
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setSurvey
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getMesurements
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getNonAppliedMesurements
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 setMesurements
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\Maturity\Model;
25
26use App\Domain\Registry\Dictionary\MesurementStatusDictionary;
27use App\Domain\Registry\Model\Mesurement;
28use JMS\Serializer\Annotation as Serializer;
29use Ramsey\Uuid\Uuid;
30use Ramsey\Uuid\UuidInterface;
31
32class AnswerSurvey
33{
34    /**
35     * @var UuidInterface
36     *
37     * @Serializer\Exclude
38     */
39    private $id;
40
41    private ?Survey $survey;
42
43    private ?Answer $answer;
44
45    /**
46     * @var Mesurement[]|iterable
47     *
48     * @Serializer\Exclude
49     */
50    private iterable $mesurements;
51
52    public function __construct()
53    {
54        $this->id          = Uuid::uuid4();
55        $this->mesurements = [];
56    }
57
58    public function deserialize(): void
59    {
60        $this->id = Uuid::uuid4();
61    }
62
63    public function getId(): UuidInterface
64    {
65        return $this->id;
66    }
67
68    public function getAnswer(): Answer
69    {
70        return $this->answer;
71    }
72
73    public function setAnswer(?Answer $answer): void
74    {
75        $this->answer = $answer;
76    }
77
78    public function getSurvey(): Survey
79    {
80        return $this->survey;
81    }
82
83    public function setSurvey(?Survey $survey): void
84    {
85        $this->survey = $survey;
86    }
87
88    public function getMesurements(): iterable
89    {
90        return $this->mesurements;
91    }
92
93    public function getNonAppliedMesurements()
94    {
95        return array_filter(\iterable_to_array($this->mesurements),
96            function (Mesurement $action) {
97                return MesurementStatusDictionary::STATUS_NOT_APPLIED === $action->getStatus();
98            });
99    }
100
101    public function setMesurements(iterable $mesurements): void
102    {
103        $this->mesurements = $mesurements;
104    }
105}