Completed
Pull Request — master (#28)
by Yann
02:07
created

ConventionedEnumCollectorCompilerPass::process()   B

Complexity

Conditions 4
Paths 5

Size

Total Lines 24
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 4.0466

Importance

Changes 0
Metric Value
dl 0
loc 24
ccs 12
cts 14
cp 0.8571
rs 8.6845
c 0
b 0
f 0
cc 4
eloc 14
nc 5
nop 1
crap 4.0466
1
<?php
2
3
namespace Yokai\EnumBundle\DependencyInjection\CompilerPass;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
8
/**
9
 * @author Yann Eugoné <[email protected]>
10
 *
11
 * @deprecated
12
 */
13
class ConventionedEnumCollectorCompilerPass implements CompilerPassInterface
14
{
15
    /**
16
     * @inheritdoc
17
     */
18 3
    public function process(ContainerBuilder $container)
19
    {
20 3
        $bundles = $container->getParameter('enum.register_bundles');
21
22 3
        if (!$bundles) {
23
            return;
24
        }
25
26 3
        @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...
27 3
            '"' . __CLASS__ . '" is deprecated since v2.2. Please use Symfony\'s PSR4 Service discovery instead.',
28 3
            E_USER_DEPRECATED
29
        );
30
31 3
        if (true === $bundles) {
32
            $bundles = $container->getParameter('kernel.bundles');
33
        } else {
34 3
            $bundles = (array) $bundles;
35
        }
36
37 3
        foreach ($bundles as $bundleClass) {
38 3
            $declarativePass = new DeclarativeEnumCollectorCompilerPass($bundleClass);
0 ignored issues
show
Deprecated Code introduced by
The class Yokai\EnumBundle\Depende...umCollectorCompilerPass has been deprecated.

This class, trait or interface has been deprecated.

Loading history...
39 3
            $declarativePass->process($container);
40
        }
41 3
    }
42
}
43