SuggestMissingExtensionPass::process()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 11
ccs 0
cts 10
cp 0
crap 6
rs 10
1
<?php
2
3
/*
4
 * This file is part of ocubom/twig-extra-bundle
5
 *
6
 * © Oscar Cubo Medina <https://ocubom.github.io>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ocubom\TwigExtraBundle\DependencyInjection\Compiler;
13
14
use Ocubom\TwigExtraBundle\Extensions;
15
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
18
class SuggestMissingExtensionPass implements CompilerPassInterface
19
{
20
    public function process(ContainerBuilder $container): void
21
    {
22
        if ($container->getParameter('kernel.debug')) {
23
            $container->getDefinition('twig')
24
                ->addMethodCall(
25
                    'registerUndefinedFilterCallback',
26
                    [[Extensions::class, 'suggestFilter']]
27
                )
28
                ->addMethodCall(
29
                    'registerUndefinedFunctionCallback',
30
                    [[Extensions::class, 'suggestFunction']]
31
                )
32
            ;
33
        }
34
    }
35
}
36