Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
85.71% covered (warning)
85.71%
24 / 28
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
TreatmentCompletion
85.71% covered (warning)
85.71%
24 / 28
50.00% covered (danger)
50.00%
1 / 2
22.29
0.00% covered (danger)
0.00%
0 / 1
 getPoints
85.19% covered (warning)
85.19%
23 / 27
0.00% covered (danger)
0.00%
0 / 1
21.30
 getMaxPoints
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
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\Calculator\Completion;
25
26use App\Domain\Registry\Model;
27
28class TreatmentCompletion extends AbstractCompletion
29{
30    /**
31     * {@inheritdoc}
32     * Get completion points for Treatment.
33     *
34     * @param Model\Treatment $object
35     */
36    protected function getPoints($object): int
37    {
38        $points = 0;
39
40        if ($object->getName()) {
41            ++$points;
42        }
43
44        if ($object->getGoal()) {
45            ++$points;
46        }
47
48        if ($object->getManager()) {
49            ++$points;
50        }
51
52        if (($object->getTools() && count($object->getTools())) || $object->isPaperProcessing()) {
53            ++$points;
54        }
55
56        if ($object->getLegalBasis()) {
57            ++$points;
58        }
59
60        if ($object->getLegalBasisJustification()) {
61            ++$points;
62        }
63
64        if ($object->getConcernedPeopleParticular()->isCheck() || $object->getConcernedPeopleUser()->isCheck()
65            || $object->getConcernedPeopleAgent()->isCheck() || $object->getConcernedPeopleElected()->isCheck()
66            || $object->getConcernedPeopleCompany()->isCheck() || $object->getConcernedPeoplePartner()->isCheck()
67            || $object->getConcernedPeopleOther()->isCheck()
68        ) {
69            ++$points;
70        }
71
72        if (!empty($object->getDataCategories())) {
73            ++$points;
74        }
75
76        if ($object->getDataCategoryOther()) {
77            ++$points;
78        }
79
80        if ($object->getRecipientCategory()) {
81            ++$points;
82        }
83
84        if (!empty($object->getContractors())) {
85            ++$points;
86        }
87
88        return $points;
89    }
90
91    protected function getMaxPoints(): int
92    {
93        return 12;
94    }
95}