Completed
Push — master ( 9e9a0d...740d0f )
by Rafael
04:13
created

YnloGraphQLExtension::load()   B

Complexity

Conditions 6
Paths 4

Size

Total Lines 20
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 42

Importance

Changes 0
Metric Value
cc 6
eloc 12
nc 4
nop 2
dl 0
loc 20
ccs 0
cts 17
cp 0
crap 42
rs 8.8571
c 0
b 0
f 0
1
<?php
2
3
/*******************************************************************************
4
 *  This file is part of the GraphQL Bundle package.
5
 *
6
 *  (c) YnloUltratech <[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 Ynlo\GraphQLBundle\DependencyInjection;
13
14
use Symfony\Component\Config\FileLocator;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
17
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
18
19
/**
20
 * Class YnloGraphQLExtension
21
 */
22
class YnloGraphQLExtension extends Extension
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function load(array $configs, ContainerBuilder $container)
28
    {
29
        $configuration = new Configuration($container->getParameter('kernel.debug'));
0 ignored issues
show
Unused Code introduced by
The call to Ynlo\GraphQLBundle\Depen...guration::__construct() has too many arguments starting with $container->getParameter('kernel.debug'). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
        $configuration = /** @scrutinizer ignore-call */ new Configuration($container->getParameter('kernel.debug'));

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
30
        $config = $this->processConfiguration($configuration, $configs);
31
32
        if (!isset($config['definitions']['extensions']['namespaces']['bundles']['aliases']['GraphQLBundle'])) {
33
            $config['definitions']['extensions']['namespaces']['bundles']['aliases']['GraphQLBundle'] = 'AppBundle';
34
        }
35
36
        $container->setParameter('graphql.config', $config);
37
        if (isset($config['definitions']['extensions'])) {
38
            foreach ($config['definitions']['extensions'] as $extension => $config) {
39
                $config = isset($config['enabled']) && $config['enabled'] ? $config : [];
40
                $container->setParameter('graphql.extension_config.'.$extension, $config ?? []);
41
            }
42
        }
43
44
        $configDir = __DIR__.'/../Resources/config';
45
        $loader = new YamlFileLoader($container, new FileLocator($configDir));
46
        $loader->load('services.yml');
47
    }
48
49
    /**
50
     * {@inheritDoc}
51
     */
52
    public function getAlias()
53
    {
54
        return 'graphql';
55
    }
56
}
57