Completed
Push — master ( 355f41...200862 )
by Mickael
06:25
created

GearmanExtension   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 5
dl 0
loc 56
ccs 24
cts 24
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B load() 0 43 1
1
<?php
2
3
/**
4
 * Gearman Bundle for Symfony2 / Symfony3
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * Feel free to edit as you please, and have fun.
10
 *
11
 * @author Marc Morera <[email protected]>
12
 */
13
14
namespace Mkk\GearmanBundle\DependencyInjection;
15
16
use Symfony\Component\Config\FileLocator;
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
19
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
20
21
/**
22
 * This is the class that loads and manages your bundle configuration
23
 */
24
class GearmanExtension extends Extension
25
{
26
    /**
27
     * Loads a specific configuration.
28
     *
29
     * @param array            $config    An array of configuration values
30
     * @param ContainerBuilder $container A ContainerBuilder instance
31
     *
32
     * @throws \InvalidArgumentException When provided tag is not defined in this extension
33
     *
34
     * @api
35
     */
36 1
    public function load(array $config, ContainerBuilder $container)
37
    {
38 1
        $configuration = new Configuration();
39 1
        $config = $this->processConfiguration($configuration, $config);
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $config. This often makes code more readable.
Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 8 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
40
41
        /**
42
         * Setting all config elements as DI parameters to inject them
43
         */
44 1
        $container->setParameter(
45 1
            'gearman.bundles',
46 1
            $config['bundles']
47
        );
48
49 1
        $container->setParameter(
50 1
            'gearman.servers',
51 1
            $config['servers']
52
        );
53
54 1
        $container->setParameter(
55 1
            'gearman.default.settings',
56 1
            $config['defaults']
57
        );
58
59 1
        $container->setParameter(
60 1
            'gearman.default.settings.generate_unique_key',
61 1
            $config['defaults']['generate_unique_key']
62
        );
63
64 1
        $loader = new YamlFileLoader(
65
            $container,
66 1
            new FileLocator(__DIR__ . '/../Resources/config')
67
        );
68
69
        /**
70
         * Loading DI definitions
71
         */
72 1
        $loader->load('classes.yml');
73 1
        $loader->load('services.yml');
74 1
        $loader->load('commands.yml');
75 1
        $loader->load('eventDispatchers.yml');
76 1
        $loader->load('generators.yml');
77 1
        $loader->load('externals.yml');
78 1
    }
79
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
80