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 (#682)
by
unknown
41:38 queued 16:31
created

outputFieldsSection()   B

Complexity

Conditions 3
Paths 1

Size

Total Lines 74
Code Lines 61

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 54
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 61
dl 0
loc 74
ccs 54
cts 54
cp 1
rs 8.8509
c 0
b 0
f 0
cc 3
nc 1
nop 0
crap 3

How to fix   Long Method   

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;
6
7
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
8
9
abstract class TypeWithOutputFieldsDefinition extends TypeDefinition
10
{
11
    protected function outputFieldsSection(): NodeDefinition
12
    {
13
        $node = self::createNode('fields');
14
        $node
15
            ->isRequired()
16
            ->requiresAtLeastOneElement();
0 ignored issues
show
Bug introduced by
The method requiresAtLeastOneElement() does not exist on Symfony\Component\Config...\Builder\NodeDefinition. It seems like you code against a sub-type of Symfony\Component\Config...\Builder\NodeDefinition such as Symfony\Component\Config...der\ArrayNodeDefinition. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

16
            ->/** @scrutinizer ignore-call */ requiresAtLeastOneElement();
Loading history...
17 47
18
        $prototype = $node->useAttributeAsKey('name', false)->prototype('array');
0 ignored issues
show
Bug introduced by
The method useAttributeAsKey() does not exist on Symfony\Component\Config...\Builder\NodeDefinition. It seems like you code against a sub-type of Symfony\Component\Config...\Builder\NodeDefinition such as Symfony\Component\Config...der\ArrayNodeDefinition. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
        $prototype = $node->/** @scrutinizer ignore-call */ useAttributeAsKey('name', false)->prototype('array');
Loading history...
Bug introduced by
The method prototype() does not exist on Symfony\Component\Config...\Builder\NodeDefinition. It seems like you code against a sub-type of Symfony\Component\Config...\Builder\NodeDefinition such as Symfony\Component\Config...der\ArrayNodeDefinition. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
        $prototype = $node->useAttributeAsKey('name', false)->/** @scrutinizer ignore-call */ prototype('array');
Loading history...
19 47
20
        $prototype
21 47
            ->beforeNormalization()
22 47
                // Allow field type short syntax (Field: Type => Field: {type: Type})
23
                ->ifTrue(fn ($options) => \is_string($options))
24 47
                ->then(fn ($options) => ['type' => $options])
25
            ->end()
26
            ->validate()
27
                // Remove empty entries
28 47
                ->always(function ($value) {
29
                    if (empty($value['validationGroups'])) {
30 37
                        unset($value['validationGroups']);
31 47
                    }
32
33 3
                    if (empty($value['args'])) {
34 47
                        unset($value['args']);
35 47
                    }
36 47
37
                    return $value;
38 37
                })
39 37
            ->end()
40
            ->children()
41
                ->append($this->typeSection())
42 37
                ->append($this->validationSection(self::VALIDATION_LEVEL_CLASS))
43 47
                ->arrayNode('validationGroups')
44 47
                    ->beforeNormalization()
45 47
                        ->castToArray()
46 47
                    ->end()
47 47
                    ->prototype('scalar')
48 47
                        ->info('List of validation groups')
49 47
                    ->end()
50 47
                ->end()
51 47
                ->arrayNode('args')
52 47
                    ->info('Array of possible type arguments. Each entry is expected to be an array with following keys: name (string), type')
53 47
                    ->useAttributeAsKey('name', false)
54 47
                    ->prototype('array')
55 47
                        // Allow arg type short syntax (Arg: Type => Arg: {type: Type})
56 47
                        ->beforeNormalization()
57
                            ->ifTrue(fn ($options) => \is_string($options))
58 47
                            ->then(fn ($options) => ['type' => $options])
59
                        ->end()
60 28
                        ->children()
61 47
                            ->append($this->typeSection(true))
62
                            ->append($this->descriptionSection())
63 4
                            ->append($this->defaultValueSection())
64 47
                            ->append($this->validationSection(self::VALIDATION_LEVEL_PROPERTY))
65 47
                        ->end()
66 47
                    ->end()
67 47
                ->end()
68 47
                ->variableNode('resolve')
69 47
                    ->info('Value resolver (expression language can be used here)')
70 47
                ->end()
71 47
                ->append($this->descriptionSection())
72 47
                ->append($this->deprecationReasonSection())
73 47
                ->variableNode('access')
74 47
                    ->info('Access control to field (expression language can be used here)')
75 47
                ->end()
76 47
                ->variableNode('public')
77 47
                    ->info('Visibility control to field (expression language can be used here)')
78 47
                ->end()
79 47
                ->variableNode('complexity')
80 47
                    ->info('Custom complexity calculator.')
81 47
                ->end()
82 47
            ->end();
83 47
84 47
        return $node;
85 47
    }
86 47
87 47
    protected function fieldsBuilderSection()
88 47
    {
89
        $node = self::createNode('builders');
90 47
91
        $prototype = $node->prototype('array');
92
93 47
        $prototype
94
            ->children()
95 47
                ->variableNode('builder')->isRequired()->end()
96
                ->variableNode('builderConfig')->end()
97 47
            ->end();
98
99
        return $node;
100 47
    }
101
}
102