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
Push — 0.12 ( dbba9e...54d1e8 )
by Jérémiah
14s queued 11s
created

ResolverMethodAliasesPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
cc 3
nc 3
nop 1
crap 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Overblog\GraphQLBundle\DependencyInjection\Compiler;
6
7
use Overblog\GraphQLBundle\Definition\Resolver\AliasedInterface;
8
use Overblog\GraphQLBundle\Definition\Resolver\MutationInterface;
9
use Overblog\GraphQLBundle\Definition\Resolver\ResolverInterface;
10
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
11
use Symfony\Component\DependencyInjection\ContainerBuilder;
12
use Symfony\Component\DependencyInjection\Definition;
13
14
final class ResolverMethodAliasesPass implements CompilerPassInterface
15
{
16
    private const SERVICE_SUBCLASS_TAG_MAPPING = [
17
        MutationInterface::class => 'overblog_graphql.mutation',
18
        ResolverInterface::class => 'overblog_graphql.resolver',
19
    ];
20
21
    /**
22
     * {@inheritdoc}
23
     */
24 32
    public function process(ContainerBuilder $container): void
25
    {
26 32
        foreach ($container->getDefinitions() as $definition) {
27 32
            foreach (self::SERVICE_SUBCLASS_TAG_MAPPING as $tagName) {
28 32
                $this->addDefinitionTagsFromClassReflection($definition, $tagName);
29
            }
30
        }
31 32
    }
32
33 32
    private function addDefinitionTagsFromClassReflection(Definition $definition, string $tagName): void
34
    {
35 32
        if ($definition->hasTag($tagName)) {
36 32
            foreach ($definition->getTag($tagName) as $tag => $attributes) {
37 32
                if (!isset($attributes['method'])) {
38 32
                    $reflectionClass = new \ReflectionClass($definition->getClass());
39
40 32
                    if (!$reflectionClass->isAbstract()) {
41 32
                        $publicReflectionMethods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC);
42 32
                        $isAliased = $reflectionClass->implementsInterface(AliasedInterface::class);
43 32
                        foreach ($publicReflectionMethods as $publicReflectionMethod) {
44 32
                            if ('__construct' === $publicReflectionMethod->name || $isAliased && 'getAliases' === $publicReflectionMethod->name) {
45 32
                                continue;
46
                            }
47 32
                            $definition->addTag($tagName, ['method' => $publicReflectionMethod->name]);
48
                        }
49
                    }
50 32
                    continue;
51
                }
52
            }
53
        }
54 32
    }
55
}
56