Completed
Push — testDev1-rebased ( b23925 )
by Dominik
02:35
created

AzineMailgunWebhooksExtension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 19.35 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 25%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 5
dl 6
loc 31
ccs 3
cts 12
cp 0.25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 6 20 4

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\MailgunWebhooksBundle\DependencyInjection;
4
5
use Symfony\Component\Config\FileLocator;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Loader;
8
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
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 AzineMailgunWebhooksExtension extends Extension
16
{
17
    const PREFIX = 'azine_mailgun_webhooks';
18
    const API_KEY = 'api_key';
19
    const PUBLIC_API_KEY = 'public_api_key';
20
    const EMAIL_DOMAIN = 'email_domain';
21
22
    /**
23
     * {@inheritdoc}
24
     */
25 3
    public function load(array $configs, ContainerBuilder $container)
26
    {
27 3
        $configuration = new Configuration();
28 3
        $config = $this->processConfiguration($configuration, $configs);
29
30 View Code Duplication
        if (array_key_exists(self::API_KEY, $config)) {
31
            $container->setParameter(self::PREFIX.'_'.self::API_KEY, $config[self::API_KEY]);
32
        }
33
34 View Code Duplication
        if (array_key_exists(self::PUBLIC_API_KEY, $config)) {
35
            $container->setParameter(self::PREFIX.'_'.self::PUBLIC_API_KEY, $config[self::PUBLIC_API_KEY]);
36
        }
37
38 View Code Duplication
        if (array_key_exists(self::EMAIL_DOMAIN, $config)) {
39
            $container->setParameter(self::PREFIX.'_'.self::EMAIL_DOMAIN, $config[self::EMAIL_DOMAIN]);
40
        }
41
42
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
43
        $loader->load('services.yml');
44
    }
45
}
46