Completed
Push — master ( 14abe7...6c6b3a )
by Jeroen
12:41 queued 04:41
created

DeprecateClassParametersPass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 21
loc 21
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 18 18 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Kunstmaan\CacheBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
8
/**
9
 * @internal
10
 */
11 View Code Duplication
final class DeprecateClassParametersPass implements CompilerPassInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
{
13 2
    public function process(ContainerBuilder $container)
14
    {
15
        $expectedValues = [
16 2
            'kunstmaan_cache.menu_adaptor.varnish.class' => \Kunstmaan\CacheBundle\Helper\Menu\VarnishMenuAdaptor::class,
17
            'kunstmaan_cache.helper.varnish.class' => \Kunstmaan\CacheBundle\Helper\VarnishHelper::class,
18
        ];
19
20 2
        foreach ($expectedValues as $parameter => $expectedValue) {
21 2
            if (false === $container->hasParameter($parameter)) {
22 2
                continue;
23
            }
24
25 1
            $currentValue = $container->getParameter($parameter);
26 1
            if ($currentValue !== $expectedValue) {
27 1
                @trigger_error(sprintf('Using the "%s" parameter to change the class of the service definition is deprecated in KunstmaanCacheBundle 5.2 and will be removed in KunstmaanCacheBundle 6.0. Use service decoration or a service alias instead.', $parameter), E_USER_DEPRECATED);
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...
28
            }
29
        }
30 2
    }
31
}
32