GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( be0626...df8c18 )
by Théo
33:01
created

HautelookAliceExtension   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 70
Duplicated Lines 22.86 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
B load() 16 24 3
A loadConfig() 0 12 2
A loadServices() 0 11 2

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
/*
4
 * This file is part of the Hautelook\AliceBundle package.
5
 *
6
 * (c) Baldur Rensch <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Hautelook\AliceBundle\DependencyInjection;
13
14
use Hautelook\AliceBundle\HautelookAliceBundle;
15
use Symfony\Component\Config\FileLocator;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
18
use Symfony\Component\Finder\Finder;
19
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
20
21
/**
22
 * @private
23
 *
24
 * @author Baldur Rensch <[email protected]>
25
 * @author Théo FIDRY <[email protected]>
26
 */
27
final class HautelookAliceExtension extends Extension
28
{
29
    const SERVICES_DIR = __DIR__.'/../../resources/config';
30
31
    /**
32
     * @inheritdoc
33
     */
34
    public function load(array $configs, ContainerBuilder $container)
35
    {
36
        $bundles = array_flip($container->getParameter('kernel.bundles'));
37
38 View Code Duplication
        if (false === array_key_exists('Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle', $bundles)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39
            throw new \LogicException(
40 27
                sprintf(
41
                    'Cannot register "%s" without "Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle".',
42 27
                    HautelookAliceBundle::class
43 27
                )
44 27
            );
45 27
        }
46 View Code Duplication
        if (false === array_key_exists('Doctrine\Bundle\DoctrineBundle\DoctrineBundle', $bundles)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
47
            throw new \LogicException(
48
                sprintf(
49
                    'Cannot register "%s" without "Doctrine\Bundle\DoctrineBundle\DoctrineBundle".',
50
                    HautelookAliceBundle::class
51
                )
52 27
            );
53
        }
54 27
55 27
        $this->loadConfig($configs, $container);
56
        $this->loadServices($container);
57 24
    }
58 24
59 24
    /**
60
     * Loads alice configuration and add the configuration values to the application parameters.
61 24
     *
62 24
     * @param array            $configs
63
     * @param ContainerBuilder $container
64
     *
65
     * @throws \InvalidArgumentException
66 24
     */
67 24
    private function loadConfig(array $configs, ContainerBuilder $container)
68 16
    {
69 16
        $configuration = new Configuration();
70 8
        $processedConfiguration = $this->processConfiguration($configuration, $configs);
71 8
72
        foreach ($processedConfiguration as $key => $value) {
73
            $container->setParameter(
74 24
                $this->getAlias().'.'.$key,
75 24
                $value
76 24
            );
77 24
        }
78 15
    }
79
80 15
    /**
81 15
     * Loads all the services declarations.
82 15
     *
83 15
     * @param ContainerBuilder $container
84 15
     */
85
    private function loadServices(ContainerBuilder $container)
86 15
    {
87 24
        $loader = new XmlFileLoader($container, new FileLocator(self::SERVICES_DIR));
88
        $finder = new Finder();
89 24
        $finder->files()->in(self::SERVICES_DIR);
90 24
        foreach ($finder as $file) {
91 24
            $loader->load(
92
                $file->getRelativePathname()
93 15
            );
94
        }
95
    }
96
}
97