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 (#615)
by Stefano
44:23 queued 19:50
created

ResolverMapTaggedServiceMappingPass::process()   B

Complexity

Conditions 8
Paths 18

Size

Total Lines 29
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 29
rs 8.4444
cc 8
nc 18
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Overblog\GraphQLBundle\DependencyInjection\Compiler;
6
7
use Overblog\GraphQLBundle\EventListener\TypeDecoratorListener;
8
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
11
use Symfony\Component\DependencyInjection\Reference;
12
13
final class ResolverMapTaggedServiceMappingPass implements CompilerPassInterface
14
{
15
    private const SERVICE_TAG = 'overblog_graphql.resolver_map';
16
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function process(ContainerBuilder $container): void
21
    {
22
        $schemaIds = [];
23
        $typeDecoratorListenerDefinition = $container->getDefinition(TypeDecoratorListener::class);
24
25
        foreach ($container->findTaggedServiceIds('overblog_graphql.schema') as $serviceId => $tags) {
26
            $schemaIds[] = \substr($serviceId, \strlen('overblog_graphql.schema_'));
27
        }
28
29
        $resolverMapsBySchemas = [];
30
31
        foreach ($container->findTaggedServiceIds(self::SERVICE_TAG, true) as $serviceId => $tags) {
32
            foreach ($tags as $tag) {
33
                if (isset($tag['schema']) && !\in_array($tag['schema'], $schemaIds, true)) {
34
                    throw new RuntimeException(\sprintf('Invalid resolver map service "%s": schema "%s" specified on the tag "%s" does not exist (known ones are: "%s").', $serviceId, $tag['schema'], self::SERVICE_TAG, \implode('", "', $schemaIds)));
35
                }
36
37
                $resolverMapSchemas = (array) ($tag['schema'] ?? $schemaIds);
38
39
                foreach ($resolverMapSchemas as $resolverMapSchema) {
40
                    $resolverMapsBySchemas[$resolverMapSchema][] = new Reference($serviceId);
41
                }
42
            }
43
        }
44
45
        foreach ($resolverMapsBySchemas as $schemaName => $resolverMaps) {
46
            $typeDecoratorListenerDefinition->addMethodCall('addSchemaResolverMaps', [
47
                $schemaName,
48
                $resolverMaps,
49
            ]);
50
        }
51
    }
52
}
53