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

GlobalVariablesPass::process()   C

Complexity

Conditions 7
Paths 7

Size

Total Lines 29
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 18
CRAP Score 7

Importance

Changes 0
Metric Value
dl 0
loc 29
ccs 18
cts 18
cp 1
rs 6.7272
c 0
b 0
f 0
cc 7
eloc 17
nc 7
nop 1
crap 7
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 32
    public function process(ContainerBuilder $container)
16
    {
17 32
        $taggedServices = $container->findTaggedServiceIds('overblog_graphql.global_variable', true);
18 32
        $globalVariables = ['container' => new Reference('service_container')];
19 32
        $expressionLanguageDefinition = $container->findDefinition('overblog_graphql.expression_language');
20
21 32
        foreach ($taggedServices as $id => $tags) {
22 32
            foreach ($tags as $attributes) {
23 32
                if (empty($attributes['alias']) || !is_string($attributes['alias'])) {
24 6
                    throw new \InvalidArgumentException(
25 6
                        sprintf('Service "%s" tagged "overblog_graphql.global_variable" should have a valid "alias" attribute.', $id)
26
                    );
27
                }
28 26
                $globalVariables[$attributes['alias']] = new Reference($id);
29
30 26
                $isPublic = isset($attributes['public']) ? (bool) $attributes['public'] : true;
31 26
                if ($isPublic) {
32 26
                    $expressionLanguageDefinition->addMethodCall(
33 26
                        'addGlobalName',
34
                        [
35 26
                            sprintf('globalVariables->get(\'%s\')', $attributes['alias']),
36 26
                            $attributes['alias'],
37
                        ]
38
                    );
39
                }
40
            }
41
        }
42 26
        $container->findDefinition(GlobalVariables::class)->setArguments([$globalVariables]);
43 26
    }
44
}
45