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.

AkeneoMeasureExtension   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 0
cbo 7
dl 0
loc 48
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B load() 0 42 6
1
<?php
2
3
namespace Akeneo\Bundle\MeasureBundle\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
use Symfony\Component\Yaml\Yaml;
10
11
/**
12
 * Load measure bundle configuration from any bundles
13
 *
14
 * @author    Nicolas Dupont <[email protected]>
15
 * @copyright 2012 Akeneo SAS (http://www.akeneo.com)
16
 * @license   http://opensource.org/licenses/MIT MIT
17
 */
18
class AkeneoMeasureExtension extends Extension
19
{
20
    /**
21
     * {@inheritDoc}
22
     */
23
    public function load(array $configs, ContainerBuilder $container)
24
    {
25
        // retrieve each measure config from bundles
26
        $measuresConfig = [];
27
        foreach ($container->getParameter('kernel.bundles') as $bundle) {
28
            $reflection = new \ReflectionClass($bundle);
29
            if (is_file($file = dirname($reflection->getFilename()).'/Resources/config/measure.yml')) {
30
                // merge measures configs
31
                if (empty($measuresConfig)) {
32
                    $measuresConfig = Yaml::parse(file_get_contents(realpath($file)));
33
                } else {
34
                    $entities = Yaml::parse(file_get_contents(realpath($file)));
35
                    foreach ($entities['measures_config'] as $family => $familyConfig) {
36
                        // merge result with already existing family config to add custom units
37
                        if (isset($measuresConfig['measures_config'][$family])) {
38
                            $measuresConfig['measures_config'][$family]['units'] =
39
                                array_merge(
40
                                    $measuresConfig['measures_config'][$family]['units'],
41
                                    $familyConfig['units']
42
                                );
43
                        } else {
44
                            $measuresConfig['measures_config'][$family] = $familyConfig;
45
                        }
46
                    }
47
                }
48
            }
49
        }
50
        $configs[] = $measuresConfig;
51
        // process configurations to validate and merge
52
        $configuration = new Configuration();
53
        $config = $this->processConfiguration($configuration, $configs);
54
55
        // load service
56
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
57
        $loader->load('services.yml');
58
        // set measures config
59
        $container->setParameter('akeneo_measure.measures_config', $config);
60
61
        $container
62
            ->getDefinition('akeneo_measure.manager')
63
            ->addMethodCall('setMeasureConfig', $config);
64
    }
65
}
66