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
23:57
created

GraphQLServicesPass   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 16
dl 0
loc 33
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 0 28 7
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
        $serviceContainer = ['container' => new Reference('service_container')];
25
        $expressionLanguageDefinition = $container->findDefinition('overblog_graphql.expression_language');
26
27
        foreach ($taggedServices as $id => $tags) {
28
            foreach ($tags as $attributes) {
29
                if (empty($attributes['alias']) || !is_string($attributes['alias'])) {
30
                    throw new InvalidArgumentException(
31
                        sprintf('Service "%s" tagged "overblog_graphql.service" should have a valid "alias" attribute.', $id)
32
                    );
33
                }
34
                $serviceContainer[$attributes['alias']] = new Reference($id);
35
36
                $isPublic = isset($attributes['public']) ? (bool) $attributes['public'] : true;
37
                if ($isPublic) {
38
                    $expressionLanguageDefinition->addMethodCall(
39
                        'addGlobalName',
40
                        [
41
                            sprintf(TypeGenerator::GRAPHQL_SERVICES.'->get(\'%s\')', $attributes['alias']),
42
                            $attributes['alias'],
43
                        ]
44
                    );
45
                }
46
            }
47
        }
48
        $container->findDefinition(GraphQLServices::class)->addArgument($serviceContainer);
49
    }
50
}
51