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 (#277)
by Jérémiah
20:41
created

GlobalVariablesPass::process()   C

Complexity

Conditions 7
Paths 7

Size

Total Lines 29
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 6.7272
c 0
b 0
f 0
cc 7
eloc 17
nc 7
nop 1
1
<?php
2
3
namespace Overblog\GraphQLBundle\DependencyInjection\Compiler;
4
5
use Overblog\GraphQLBundle\Definition\GlobalVariables;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Reference;
9
10
final class GlobalVariablesPass implements CompilerPassInterface
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    public function process(ContainerBuilder $container)
16
    {
17
        $taggedServices = $container->findTaggedServiceIds('overblog_graphql.global_variable', true);
18
        $globalVariables = ['container' => new Reference('service_container')];
19
        $expressionLanguageDefinition = $container->findDefinition('overblog_graphql.expression_language');
20
21
        foreach ($taggedServices as $id => $tags) {
22
            foreach ($tags as $attributes) {
23
                if (empty($attributes['alias']) || !is_string($attributes['alias'])) {
24
                    throw new \InvalidArgumentException(
25
                        sprintf('Service "%s" tagged "overblog_graphql.global_variable" should have a valid "alias" attribute.', $id)
26
                    );
27
                }
28
                $globalVariables[$attributes['alias']] = new Reference($id);
29
30
                $isPublic = isset($attributes['public']) ? (bool) $attributes['public'] : true;
31
                if ($isPublic) {
32
                    $expressionLanguageDefinition->addMethodCall(
33
                        'addGlobalName',
34
                        [
35
                            sprintf('globalVariables->get(\'%s\')', $attributes['alias']),
36
                            $attributes['alias'],
37
                        ]
38
                    );
39
                }
40
            }
41
        }
42
        $container->findDefinition(GlobalVariables::class)->setArguments([$globalVariables]);
43
    }
44
}
45