Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
66.67% covered (warning)
66.67%
6 / 9
50.00% covered (danger)
50.00%
2 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
ReponseMesureProtectionDictionaryExtension
66.67% covered (warning)
66.67%
6 / 9
50.00% covered (danger)
50.00%
2 / 4
4.59
0.00% covered (danger)
0.00%
0 / 1
 getFunctions
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 getFilters
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 getDictionary
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getValue
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace App\Domain\AIPD\Twig\Extension;
6
7use App\Application\Dictionary\SimpleDictionary;
8use App\Domain\AIPD\Dictionary\ReponseMesureProtectionDictionary;
9use App\Domain\AIPD\Model\AnalyseImpact;
10use Twig\Extension\AbstractExtension;
11use Twig\TwigFilter;
12use Twig\TwigFunction;
13
14class ReponseMesureProtectionDictionaryExtension extends AbstractExtension
15{
16    public function getFunctions()
17    {
18        return [
19            new TwigFunction('reponsedictionary', [$this, 'getDictionary']),
20        ];
21    }
22
23    public function getFilters()
24    {
25        return [
26            new TwigFilter('reponsedictionary', [$this, 'getValue']),
27        ];
28    }
29
30    public function getDictionary(AnalyseImpact $analyse): ?SimpleDictionary
31    {
32        return new ReponseMesureProtectionDictionary($analyse);
33    }
34
35    public function getValue($key, AnalyseImpact $analyse)
36    {
37        $dictionary = $this->getDictionary($analyse);
38
39        return $dictionary[$key];
40    }
41}