YiiTwigExtension   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 15
ccs 7
cts 7
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A getFunctions() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\View\Twig\Extensions;
6
7
use Psr\Container\ContainerInterface;
8
use Twig\Extension\AbstractExtension;
9
use Twig\TwigFunction;
10
11
/**
12
 * YiiTwigExtension adds additional functionality to the Twig engine.
13
 */
14
final class YiiTwigExtension extends AbstractExtension
15
{
16 3
    public function __construct(private ContainerInterface $container)
17
    {
18 3
    }
19
20
    /**
21
     * @return TwigFunction[]
22
     */
23 3
    public function getFunctions(): array
24
    {
25 3
        return [
26 3
            new TwigFunction(
27 3
                'get',
28 3
                fn (string $id): mixed => $this->container->get($id),
29 3
            ),
30 3
        ];
31
    }
32
}
33