Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
66.67% |
6 / 9 |
|
50.00% |
2 / 4 |
CRAP | |
0.00% |
0 / 1 |
ReponseMesureProtectionDictionaryExtension | |
66.67% |
6 / 9 |
|
50.00% |
2 / 4 |
4.59 | |
0.00% |
0 / 1 |
getFunctions | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
getFilters | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
getDictionary | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getValue | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace App\Domain\AIPD\Twig\Extension; |
6 | |
7 | use App\Application\Dictionary\SimpleDictionary; |
8 | use App\Domain\AIPD\Dictionary\ReponseMesureProtectionDictionary; |
9 | use App\Domain\AIPD\Model\AnalyseImpact; |
10 | use Twig\Extension\AbstractExtension; |
11 | use Twig\TwigFilter; |
12 | use Twig\TwigFunction; |
13 | |
14 | class 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 | } |