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

Passed
Pull Request — master (#786)
by Timur
64:08 queued 62:37
created

GraphQLServicesPass   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
eloc 22
dl 0
loc 47
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 0 42 8
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Overblog\GraphQLBundle\DependencyInjection\Compiler;
6
7
use InvalidArgumentException;
8
use Overblog\GraphQLBundle\Definition\GraphQLServices;
9
use Overblog\GraphQLBundle\Generator\TypeGenerator;
10
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
11
use Symfony\Component\DependencyInjection\ContainerBuilder;
12
use Symfony\Component\DependencyInjection\Reference;
13
use function is_string;
14
use function sprintf;
15
16
final class GraphQLServicesPass implements CompilerPassInterface
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21
    public function process(ContainerBuilder $container): void
22
    {
23
        $taggedServices = $container->findTaggedServiceIds('overblog_graphql.service', true);
24
25
        // TODO: remove following code in 1.0
26
        // remove start
27
        $deprecatedTaggedServices = $container->findTaggedServiceIds('overblog_graphql.global_variable', true);
28
        if (count($deprecatedTaggedServices) > 0) {
29
            @trigger_error(
30
                "The tag 'overblog_graphql.global_variable' is deprecated since 0.14 and will be removed in 1.0. Use 'overblog_graphql.service' instead. For more info visit: https://github.com/overblog/GraphQLBundle/issues/775",
31
                E_USER_DEPRECATED
32
            );
33
34
            $taggedServices = array_merge($taggedServices, $deprecatedTaggedServices);
35
        }
36
        // remove end
37
38
        $serviceContainer = ['container' => new Reference('service_container')];
39
        $expressionLanguageDefinition = $container->findDefinition('overblog_graphql.expression_language');
40
41
        foreach ($taggedServices as $id => $tags) {
42
            foreach ($tags as $attributes) {
43
                if (empty($attributes['alias']) || !is_string($attributes['alias'])) {
44
                    throw new InvalidArgumentException(
45
                        sprintf('Service "%s" tagged "overblog_graphql.service" should have a valid "alias" attribute.', $id)
46
                    );
47
                }
48
                $serviceContainer[$attributes['alias']] = new Reference($id);
49
50
                $isPublic = isset($attributes['public']) ? (bool) $attributes['public'] : true;
51
                if ($isPublic) {
52
                    $expressionLanguageDefinition->addMethodCall(
53
                        'addGlobalName',
54
                        [
55
                            sprintf(TypeGenerator::GRAPHQL_SERVICES.'->get(\'%s\')', $attributes['alias']),
56
                            $attributes['alias'],
57
                        ]
58
                    );
59
                }
60
            }
61
        }
62
        $container->findDefinition(GraphQLServices::class)->addArgument($serviceContainer);
63
    }
64
}
65