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 ( b5dfb6...a568a9 )
by Mario
40:05
created

NetgenInformationCollectionExtension   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 8

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 8
dl 0
loc 61
rs 10
c 0
b 0
f 0
ccs 25
cts 25
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
B load() 0 39 5
A prepend() 0 15 2
1
<?php
2
3
namespace Netgen\Bundle\InformationCollectionBundle\DependencyInjection;
4
5
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ConfigurationProcessor;
6
use Symfony\Component\Config\FileLocator;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
9
use Symfony\Component\DependencyInjection\Loader;
10
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
11
use Symfony\Component\Config\Resource\FileResource;
12
use Symfony\Component\Yaml\Yaml;
13
use function array_merge;
14
15
/**
16
 * This is the class that loads and manages your bundle configuration.
17
 *
18
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
19
 */
20
class NetgenInformationCollectionExtension extends Extension implements PrependExtensionInterface
21 1
{
22
    /**
23 1
     * {@inheritdoc}
24 1
     */
25
    public function load(array $configs, ContainerBuilder $container)
26 1
    {
27 1
        $configuration = new Configuration();
28 1
        $config = $this->processConfiguration($configuration, $configs);
29
30 1
        $bundleResourceLoader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
31
        $bundleResourceLoader->load('services.yml');
32 1
//        $loader->load('parameters.yml');
33 1
//        $loader->load('default_settings.yml');
34 1
35
36 1
        $libResourceLoader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../../lib/Resources/config'));
37
        $libResourceLoader->load('services.yml');
38 1
        $libResourceLoader->load('parameters.yml');
39 1
        $libResourceLoader->load('default_settings.yml');
40 1
41 1
        $processor = new ConfigurationProcessor($container, ConfigurationConstants::SETTINGS_ROOT);
42 1
        $configArrays = array(
43 1
            ConfigurationConstants::ACTIONS,
44 1
            ConfigurationConstants::ACTION_CONFIG,
45 1
        );
46 1
47
        $scopes = array_merge(array('default'), $container->getParameter('ezpublish.siteaccess.list'));
48 1
49 1
        foreach ($configArrays as $configArray) {
50 1
            $processor->mapConfigArray($configArray, $config);
51 1
            foreach ($scopes as $scope) {
52 1
                $paramName = ConfigurationConstants::SETTINGS_ROOT . '.' . $scope . '.' . $configArray;
53
                if (!$container->hasParameter($paramName)) {
54
                    continue;
55
                }
56
57
                $scopeConfig = $container->getParameter($paramName);
58
                foreach ((array) $scopeConfig as $key => $value) {
59
                    $container->setParameter($paramName . '.' . $key, $value);
60
                }
61
            }
62
        }
63
    }
64
65
    public function prepend(ContainerBuilder $container)
66
    {
67
        $configs = array(
68
            'twig.yml' => 'twig',
69
        );
70
71
        $activatedBundles = array_keys($container->getParameter('kernel.bundles'));
0 ignored issues
show
Unused Code introduced by
$activatedBundles is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
72
73
        foreach ($configs as $fileName => $extensionName) {
74
            $configFile = __DIR__ . '/../../lib/Resources/config/' . $fileName;
75
            $config = Yaml::parse(file_get_contents($configFile));
76
            $container->prependExtensionConfig($extensionName, $config);
77
            $container->addResource(new FileResource($configFile));
78
        }
79
    }
80
}
81