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 (#593)
by
unknown
21:25
created

outputFieldsSelection()   B

Complexity

Conditions 2
Paths 1

Size

Total Lines 74
Code Lines 60

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 59
CRAP Score 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 60
c 3
b 0
f 0
dl 0
loc 74
ccs 59
cts 59
cp 1
rs 8.8727
cc 2
nc 1
nop 1
crap 2

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\ArrayNodeDefinition;
8
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
9
10
abstract class TypeWithOutputFieldsDefinition extends TypeDefinition
11
{
12
    /**
13
     * @param string $name
14
     *
15
     * @return ArrayNodeDefinition|NodeDefinition
16
     */
17 47
    protected function outputFieldsSelection(string $name = 'fields')
18
    {
19 47
        $node = self::createNode($name);
20
        $node
21 47
            ->isRequired()
22 47
            ->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

22
            ->/** @scrutinizer ignore-call */ requiresAtLeastOneElement();
Loading history...
23
        /* @var ArrayNodeDefinition $prototype */
24 47
        $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

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

97
        /** @scrutinizer ignore-call */ 
98
        $prototype = $node->prototype('array');
Loading history...
98
99
        $prototype
100 47
            ->children()
101 47
                ->variableNode('builder')->isRequired()->end()
102 47
                ->variableNode('builderConfig')->end()
103 47
            ->end();
104
105 47
        return $node;
106
    }
107
}
108