Completed
Push — master ( 770316...74fc07 )
by Jeroen
09:08 queued 02:44
created

ConsoleCompilerPass   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 46.67%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 34
ccs 7
cts 15
cp 0.4667
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 28 5
1
<?php
2
3
namespace Kunstmaan\AdminBundle\DependencyInjection\Compiler;
4
5
use Kunstmaan\AdminBundle\EventListener\ConsoleExceptionListener;
6
use Kunstmaan\AdminBundle\EventListener\ConsoleExceptionSubscriber;
7
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
10
/**
11
 * Class ConsoleCompilerPass.
12
 */
13
final class ConsoleCompilerPass implements CompilerPassInterface
14
{
15
    /**
16
     * @param ContainerBuilder $container
17
     */
18 3
    public function process(ContainerBuilder $container)
19
    {
20
        // if the old listener is no longer in use
21 3
        if (!$container->hasDefinition('kunstmaan_admin.consolelogger.listener')) {
22
            return;
23
        }
24
25 3
        $definition = $container->getDefinition('kunstmaan_admin.consolelogger.listener');
26
27
        // if the default setup is in use, the subscriber / listener take care of correctly handling the errors
28
        if (
29 3
            $container->hasParameter('kunstmaan_admin.consoleexception.class') &&
30 3
            ConsoleExceptionListener::class === $container->getParameter('kunstmaan_admin.consoleexception.class') &&
31 3
            '%kunstmaan_admin.consoleexception.class%' === $definition->getClass()
32
        ) {
33 3
            return;
34
        }
35
36
        // if the listener has been overwritten in any way, a deprecation warning is needed
37
        @trigger_error(
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
38
            sprintf(
39
                'The "%s" is deprecated and replaced by "%s" since KunstmaanAdminBundle 5.1 and will be removed in KunstmaanAdminBundle 6.0.',
40
                ConsoleExceptionListener::class,
41
                ConsoleExceptionSubscriber::class
42
            ),
43
            E_USER_DEPRECATED
44
        );
45
    }
46
}
47