Passed
Push — master ( ca367b...309dd5 )
by Damien
03:01
created

DisableAuditViewerPass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 15
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 13 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DH\DoctrineAuditBundle\DependencyInjection\Compiler;
6
7
use DH\DoctrineAuditBundle\Controller\AuditController;
8
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
11
class DisableAuditViewerPass implements CompilerPassInterface
12
{
13
    public function process(ContainerBuilder $container): void
14
    {
15
        if (!$container->hasDefinition('dh_doctrine_audit.configuration')) {
16
            return;
17
        }
18
19
        $config = $container->getParameter('dh_doctrine_audit.configuration');
20
        if (null === $config['enabled_viewer']) {
21
            return;
22
        }
23
24
        if (false === $config['enabled_viewer']) {
25
            $container->removeDefinition(AuditController::class);
26
        }
27
    }
28
}
29