Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
8 / 8 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
Translation | |
100.00% |
8 / 8 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getFilters | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
getFunctions | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Engelsystem\Renderer\Twig\Extensions; |
6 | |
7 | use Engelsystem\Helpers\Translation\Translator; |
8 | use Twig\Extension\AbstractExtension as TwigExtension; |
9 | use Twig\TwigFilter; |
10 | use Twig\TwigFunction; |
11 | |
12 | class Translation extends TwigExtension |
13 | { |
14 | public function __construct(protected Translator $translator) |
15 | { |
16 | } |
17 | |
18 | public function getFilters(): array |
19 | { |
20 | return [ |
21 | new TwigFilter('trans', [$this->translator, 'translate']), |
22 | ]; |
23 | } |
24 | |
25 | /** |
26 | * @return TwigFunction[] |
27 | */ |
28 | public function getFunctions(): array |
29 | { |
30 | return [ |
31 | new TwigFunction('__', [$this->translator, 'translate']), |
32 | new TwigFunction('_e', [$this->translator, 'translatePlural']), |
33 | ]; |
34 | } |
35 | } |