Completed
Push — master ( 1b260f...3c8aea )
by Dominik
03:07
created

AzineSocialBarExtension   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 27.03 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 5
dl 10
loc 37
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B load() 10 24 6

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 Azine\SocialBarBundle\DependencyInjection;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\Config\FileLocator;
7
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
8
use Symfony\Component\DependencyInjection\Loader;
9
10
/**
11
 * This is the class that loads and manages your bundle configuration
12
 *
13
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
14
 */
15
class AzineSocialBarExtension extends Extension
16
{
17
    const PREFIX = "azine_social_bar_";
18
    const FB_PROFILE = "fb_profile_url";
19
    const XING_PROFILE = "xing_profile_url";
20
    const LINKED_IN_PROFILE ="linked_in_company_id";
21
    const GOOGLE_PLUS_PROFILE = "google_plus_profile_url";
22
    const TWITTER_PROFILE ="twitter_username";
23
24
    /**
25
     * {@inheritDoc}
26
     */
27 3
    public function load(array $configs, ContainerBuilder $container)
28
    {
29 3
        $configuration = new Configuration();
30 3
        $config = $this->processConfiguration($configuration, $configs);
31
32 3 View Code Duplication
        if(array_key_exists(self::FB_PROFILE, $config))
33 3
            $container->setParameter(self::PREFIX.self::FB_PROFILE, $config[self::FB_PROFILE]);
34
35 3 View Code Duplication
        if(array_key_exists(self::XING_PROFILE, $config))
36 3
            $container->setParameter(self::PREFIX.self::XING_PROFILE, $config[self::XING_PROFILE]);
37
38 3 View Code Duplication
        if(array_key_exists(self::LINKED_IN_PROFILE, $config))
39 3
            $container->setParameter(self::PREFIX.self::LINKED_IN_PROFILE, $config[self::LINKED_IN_PROFILE]);
40
41 3 View Code Duplication
        if(array_key_exists(self::GOOGLE_PLUS_PROFILE, $config))
42 3
            $container->setParameter(self::PREFIX.self::GOOGLE_PLUS_PROFILE, $config[self::GOOGLE_PLUS_PROFILE]);
43
44 3 View Code Duplication
        if(array_key_exists(self::TWITTER_PROFILE, $config))
45 3
            $container->setParameter(self::PREFIX.self::TWITTER_PROFILE, $config[self::TWITTER_PROFILE]);
46
47 3
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
48 3
        $loader->load('services.yml');
49
50 3
    }
51
}
52