Completed
Push — master ( 5524a5...bc12da )
by Jeroen
54:06 queued 48:17
created

DeprecateClassParametersPass::process()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 17

Duplication

Lines 17
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 4.0218

Importance

Changes 0
Metric Value
dl 17
loc 17
ccs 8
cts 9
cp 0.8889
rs 9.7
c 0
b 0
f 0
cc 4
nc 4
nop 1
crap 4.0218
1
<?php
2
3
namespace Kunstmaan\AdminListBundle\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 1
    public function process(ContainerBuilder $container)
14
    {
15
        $expectedValues = [
16 1
            'kunstmaan_adminlist.service.export.class' => \Kunstmaan\AdminListBundle\Service\ExportService::class,
17
        ];
18
19 1
        foreach ($expectedValues as $parameter => $expectedValue) {
20 1
            if (false === $container->hasParameter($parameter)) {
21
                continue;
22
            }
23
24 1
            $currentValue = $container->getParameter($parameter);
25 1
            if ($currentValue !== $expectedValue) {
26 1
                @trigger_error(sprintf('Using the "%s" parameter to change the class of the service definition is deprecated in KunstmaanAdminListBundle 5.2 and will be removed in KunstmaanAdminListBundle 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...
27
            }
28
        }
29 1
    }
30
}
31