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

ConventionedEnumCollectorCompilerPass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 30
ccs 12
cts 14
cp 0.8571
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 0 24 4
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