Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#21)
by Jérémiah
08:56
created

setSchemaBuilderArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
/*
4
 * This file is part of the OverblogGraphQLBundle package.
5
 *
6
 * (c) Overblog <http://github.com/overblog/>
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 Overblog\GraphQLBundle\DependencyInjection;
13
14
use Symfony\Component\Config\FileLocator;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
17
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
18
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
19
20
class OverblogGraphQLExtension extends Extension implements PrependExtensionInterface
21
{
22 36
    public function load(array $configs, ContainerBuilder $container)
23
    {
24 36
        $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
25 36
        $loader->load('services.yml');
26 36
        $loader->load('graphql_types.yml');
27 36
        $loader->load('graphql_fields.yml');
28 36
        $loader->load('graphql_args.yml');
29
30 36
        $configuration = $this->getConfiguration($configs, $container);
31 36
        $config = $this->processConfiguration($configuration, $configs);
32
33 36
        $this->setServicesAliases($config, $container);
34 36
        $this->setSchemaBuilderArguments($config, $container);
35 36
        $this->setSchemaArguments($config, $container);
36 36
        $this->setErrorHandlerArguments($config, $container);
37 36
        $this->setGraphiQLTemplate($config, $container);
38 36
        $this->setSecurity($config, $container);
39 36
    }
40
41 36
    public function prepend(ContainerBuilder $container)
42
    {
43 36
        $configs = $container->getExtensionConfig($this->getAlias());
44 36
        $configs = $container->getParameterBag()->resolveValue($configs);
45 36
        $configuration = $this->getConfiguration($configs, $container);
46 36
        $config = $this->processConfiguration($configuration, $configs);
47
48
        /** @var OverblogGraphQLTypesExtension $typesExtension */
49 36
        $typesExtension = $container->getExtension($this->getAlias().'_types');
50 36
        $typesExtension->containerPrependExtensionConfig($config, $container);
51 36
    }
52
53 36 View Code Duplication
    private function setSecurity(array $config, ContainerBuilder $container)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
54
    {
55 36
        if (isset($config['security']['query_max_depth'])) {
56
            $container
57 36
                ->getDefinition($this->getAlias().'.request_validator_rule_max_query_depth')
58 36
                ->addMethodCall('setMaxQueryDepth', [$config['security']['query_max_depth']])
59 36
                ->setPublic(true)
60
            ;
61 36
        }
62 36
    }
63
64 36
    private function setGraphiQLTemplate(array $config, ContainerBuilder $container)
65
    {
66 36
        if (isset($config['templates']['graphiql'])) {
67 36
            $container->setParameter('overblog_graphql.graphiql_template', $config['templates']['graphiql']);
68 36
        }
69 36
    }
70
71 36 View Code Duplication
    private function setErrorHandlerArguments(array $config, ContainerBuilder $container)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
72
    {
73 36
        if (isset($config['definitions']['internal_error_message'])) {
74
            $container
75
                ->getDefinition($this->getAlias().'.error_handler')
76
                ->replaceArgument(0, $config['definitions']['internal_error_message'])
77
                ->setPublic(true)
78
            ;
79
        }
80 36
    }
81
82 36
    private function setSchemaBuilderArguments(array $config, ContainerBuilder $container)
83
    {
84 36
        $container->getDefinition($this->getAlias().'.schema_builder')
85 36
            ->replaceArgument(1, $config['definitions']['config_validation']);
86 36
    }
87
88 36
    private function setSchemaArguments(array $config, ContainerBuilder $container)
89
    {
90 36
        if (isset($config['definitions']['schema'])) {
91
            $container
92 36
                ->getDefinition($this->getAlias().'.schema')
93 36
                ->replaceArgument(0, $config['definitions']['schema']['query'])
94 36
                ->replaceArgument(1, $config['definitions']['schema']['mutation'])
95 36
                ->replaceArgument(2, $config['definitions']['schema']['subscription'])
96 36
                ->setPublic(true)
97
            ;
98 36
        }
99 36
    }
100
101 36
    private function setServicesAliases(array $config, ContainerBuilder $container)
102
    {
103 36
        if (isset($config['services'])) {
104 36
            foreach ($config['services'] as $name => $id) {
105 36
                $alias = sprintf('%s.%s', $this->getAlias(), $name);
106 36
                $container->setAlias($alias, $id);
107 36
            }
108 36
        }
109 36
    }
110
111 36
    public function getAlias()
112
    {
113 36
        return 'overblog_graphql';
114
    }
115
116 36
    public function getConfiguration(array $config, ContainerBuilder $container)
117
    {
118 36
        return new Configuration($container->getParameter('kernel.debug'));
119
    }
120
}
121