Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
72.00% covered (warning)
72.00%
18 / 25
66.67% covered (warning)
66.67%
4 / 6
CRAP
0.00% covered (danger)
0.00%
0 / 1
ConformiteTraitementLevelDictionary
72.00% covered (warning)
72.00%
18 / 25
66.67% covered (warning)
66.67%
4 / 6
8.08
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getConformites
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
 getConformiteKeys
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getHexaConformitesColors
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
 getRgbConformitesColorsForChartView
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
2
 getConformitesWeight
0.00% covered (danger)
0.00%
0 / 6
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\Registry\Dictionary;
25
26use App\Application\Dictionary\SimpleDictionary;
27
28class ConformiteTraitementLevelDictionary extends SimpleDictionary
29{
30    public const CONFORME               = 'conforme';
31    public const NON_CONFORMITE_MINEURE = 'non_conformite_mineure';
32    public const NON_CONFORMITE_MAJEURE = 'non_conformite_majeure';
33    public const NON_EVALUE             = 'non_evalue';
34
35    public const HEX_COLOR_CONFORME               = '93D14E';
36    public const HEX_COLOR_NON_CONFORMITE_MINEURE = 'FEC100';
37    public const HEX_COLOR_NON_CONFORMITE_MAJEURE = 'C04F4D';
38    public const HEX_COLOR_NON_EVALUE             = 'DDDDDD';
39
40    public function __construct()
41    {
42        parent::__construct('conformite_traitement_level', self::getConformites());
43    }
44
45    /**
46     * @return array
47     */
48    public static function getConformites()
49    {
50        return [
51            self::CONFORME               => 'Conforme',
52            self::NON_CONFORMITE_MINEURE => 'Non-conformité mineure',
53            self::NON_CONFORMITE_MAJEURE => 'Non-conformité majeure',
54            self::NON_EVALUE             => 'Non évalué',
55        ];
56    }
57
58    /**
59     * @return array
60     */
61    public static function getConformiteKeys()
62    {
63        return \array_keys(self::getConformites());
64    }
65
66    public static function getHexaConformitesColors()
67    {
68        return [
69            self::CONFORME               => self::HEX_COLOR_CONFORME,
70            self::NON_CONFORMITE_MINEURE => self::HEX_COLOR_NON_CONFORMITE_MINEURE,
71            self::NON_CONFORMITE_MAJEURE => self::HEX_COLOR_NON_CONFORMITE_MAJEURE,
72            self::NON_EVALUE             => self::HEX_COLOR_NON_EVALUE,
73        ];
74    }
75
76    public static function getRgbConformitesColorsForChartView()
77    {
78        $rgbColors = [];
79        foreach (self::getHexaConformitesColors() as $key => $hex) {
80            list($r, $g, $b) = \sscanf($hex, '%02x%02x%02x');
81            $rgbColors[$key] = "rgba($r$g$b)";
82        }
83
84        return $rgbColors;
85    }
86
87    public static function getConformitesWeight()
88    {
89        return [
90            self::CONFORME               => 1,
91            self::NON_CONFORMITE_MINEURE => 2,
92            self::NON_CONFORMITE_MAJEURE => 3,
93            self::NON_EVALUE             => 4,
94        ];
95    }
96}