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 — 0.12 (#553)
by
unknown
19:08
created

RelayProcessor::processRelayConfigs()   C

Complexity

Conditions 12
Paths 130

Size

Total Lines 30
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 12

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 30
ccs 15
cts 15
cp 1
rs 6.7166
c 0
b 0
f 0
cc 12
nc 130
nop 3
crap 12

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Overblog\GraphQLBundle\Config\Processor;
6
7
use Overblog\GraphQLBundle\Definition\Builder\MappingInterface;
8
use Overblog\GraphQLBundle\Relay\Connection\ConnectionDefinition;
9
use Overblog\GraphQLBundle\Relay\Mutation\InputDefinition;
10
use Overblog\GraphQLBundle\Relay\Mutation\PayloadDefinition;
11
use Overblog\GraphQLBundle\Relay\Node\NodeDefinition;
12
13
final class RelayProcessor implements ProcessorInterface
14
{
15
    public const RELAY_DEFINITION_MAPPING = [
16
        'relay-connection' => ConnectionDefinition::class,
17
        'relay-node' => NodeDefinition::class,
18
        'relay-mutation-input' => InputDefinition::class,
19
        'relay-mutation-payload' => PayloadDefinition::class,
20
    ];
21
22
    /**
23
     * {@inheritdoc}
24
     */
25 42
    public static function process(array $configs): array
26
    {
27 42
        foreach (static::RELAY_DEFINITION_MAPPING as $typeName => $definitionBuilderClass) {
28 42
            $configs = self::processRelayConfigs($typeName, $definitionBuilderClass, $configs);
29
        }
30
31 42
        return $configs;
32
    }
33
34 42
    private static function processRelayConfigs($typeName, $definitionBuilderClass, array $configs)
35
    {
36 42
        foreach ($configs as $name => $config) {
37 42
            if (isset($config['type']) && \is_string($config['type']) && $typeName === $config['type']) {
38
39 19
                $configInherits = isset($config['inherits']) && \is_array($config['inherits']) ? $config['inherits'] : [];
40
41 19
                $config = isset($config['config']) && \is_array($config['config']) ? $config['config'] : [];
42
43 19
                if (empty($config['class_name'])) {
44 19
                    $config['class_name'] = \sprintf('%sType', $name);
45
                }
46 19
                if (empty($config['name'])) {
47 18
                    $config['name'] = $name;
48
                }
49
50
                /** @var MappingInterface $builder */
51 19
                $builder = new $definitionBuilderClass();
52
53 19
                $connectionDefinition = $builder->toMappingDefinition($config);
54
55 19
                if (!empty($configInherits)) {
56 1
                    $connectionDefinition[$name]['inherits'] = $configInherits;
57
                }
58
59 19
                $configs = \array_replace($configs, $connectionDefinition);
60
            }
61
        }
62
63 42
        return $configs;
64
    }
65
}
66